billing

package
v1.39.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package billing embeds the Next.js-built billing admin SPA into the commerce binary. Source lives at github.com/hanzoai/billing and builds into out/ via `pnpm build`. The Dockerfile billing-build stage clones the repo and copies out/ into ui/dist, which is then go:embed'd here. Local Go test runs only need .gitkeep in ui/dist/ so the directive resolves.

Mirrors the admin/embed.go + checkout/embed.go pattern. All three SPAs (commerce admin, pay, billing) ship in a single commerce binary.

Billing admin SPA HTTP handler.

The embedded SPA (ui/dist, populated by the Dockerfile billing-build stage from github.com/hanzoai/billing) is served at /admin/billing/*. Access is gated on IAM roles: admin, billing_admin, owner, or superadmin — and the legacy IsAdmin claim. Non-admin callers (including unauthenticated) get a plain 404 so the route's existence does not leak.

IAM auth is performed here, not by the global /v1/commerce middleware chain: this handler sits under /admin, outside that group. We accept the Bearer token, parse the IAM JWT, and check roles.

Index

Constants

This section is empty.

Variables

View Source
var UIFS embed.FS

UIFS is the embedded billing admin SPA bundle.

Functions

func UIHandler

func UIHandler(prefix string, iam *auth.IAMClient) gin.HandlerFunc

UIHandler returns a gin handler that serves the embedded billing admin SPA at the given mount prefix (typically "/admin/billing"). Unauthorized requests get a plain 404 — no existence leak.

The IAMClient is optional in test harnesses; a nil client (IAM disabled) means every request is treated as unauthorized, which produces the same 404 — safer fail-closed default.

func UISub

func UISub() fs.FS

UISub returns the ui/dist subtree as an fs.FS — ready for http.FS.

Types

This section is empty.

Directories

Path Synopsis
Package credit provides reusable starter credit logic.
Package credit provides reusable starter credit logic.
Package engine provides core billing business logic: usage aggregation, payment collection, and subscription lifecycle management.
Package engine provides core billing business logic: usage aggregation, payment collection, and subscription lifecycle management.
Package grant implements manual subscription grants — used for gifting Pro subscriptions, comp'ing beta users, and admin overrides.
Package grant implements manual subscription grants — used for gifting Pro subscriptions, comp'ing beta users, and admin overrides.
Package ledger implements a double-entry accounting ledger for the billing engine.
Package ledger implements a double-entry accounting ledger for the billing engine.
Package tier defines the tiered credit system for Hanzo billing.
Package tier defines the tiered credit system for Hanzo billing.
Package workflows provides Temporal workflow definitions for automated recurring billing, subscription lifecycle management, and dunning retry logic.
Package workflows provides Temporal workflow definitions for automated recurring billing, subscription lifecycle management, and dunning retry logic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL