Documentation
¶
Overview ¶
Package seed wires @hanzo/plans entries to payment-processor catalogs.
SyncStripe is called at commerce bootstrap when STRIPE_SECRET_KEY is configured. It walks the static plan catalog loaded by api/billing (via the json:billing/plans/subscription.json embed) and ensures that every priced plan has a matching Stripe Product and Price.
The sync is idempotent: Products are keyed by plan slug, Prices are keyed by {slug}-month / {slug}-year lookup_keys.
Free plans (priceMonthly == 0) are skipped for Price creation because Stripe rejects zero-amount recurring prices. A Product is still created so the plan appears in the catalog for reporting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Plan ¶
type Plan struct {
Slug string
Name string
Description string
Category string
PriceMonth int64 // cents / month (0 = free)
PriceYear int64 // cents / month when billed annually (0 = free)
Currency string
}
Plan is the minimal catalog shape the seeder operates on. It mirrors billing.SeedPlan so the api/billing package can feed us without either side importing the other.
type SyncResult ¶
SyncResult summarises what the seeder did.
func SyncStripe ¶
func SyncStripe(ctx context.Context, provider *stripe.Provider, plans []Plan, categoryFilter string) (*SyncResult, error)
SyncStripe ensures every plan in `plans` has a Stripe Product (and per- interval Price where pricing is non-zero).
categoryFilter, when non-empty, restricts the sync to plans whose Category matches. Use "world" for Hanzo World products, or "" to sync everything.