seed

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

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

func LogResult

func LogResult(w io.Writer, res *SyncResult, err error, started time.Time)

LogResult prints a concise seeder summary to w.

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

type SyncResult struct {
	Products []string
	Prices   []string
	Skipped  []string
}

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.

Jump to

Keyboard shortcuts

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