Billing — the module and its seams

Billing — the module and its seams An architecture diagram generated by Archify. tenant · Deps.Tenants: jobs.TenantLister · Deps · other modules' contracts/ · Deps tenant Deps.Tenants: jobs.TenantLister Deps billing.Manual() · a private provider · Deps.Payments: contracts.PaymentProvider · Deps · other modules' contracts/ · Deps billing.Manual() · a private provider Deps.Payments: contracts.PaymentProvider Deps admin · native shell · screens.Mount per Resource · consumers · consumer admin · native shell screens.Mount per Resource consumer a private payment provider · Provider embeds contracts.PaymentProvider · consumers · consumer a private payment provider Provider embeds contracts.PaymentProvider consumer contracts/ · Plan, Subscription · 7 events, 3 permissions · modules/billing contracts/ Plan, Subscription · 7 events, 3 permissions module.go · Module(Deps{Tenants, Payments, RenewEvery}) · modules/billing module.go Module(Deps{Tenants, Payments, RenewEvery}) internal/ · Service: Subscribe · Cancel · Renew · Settle · modules/billing internal/ Service: Subscribe · Cancel · Renew · Settle Spec.Mount · Singleton.Mount · …/plans · …/subscription · subscribe · cancel · kit/ seams Spec.Mount · Singleton.Mount …/plans · …/subscription · subscribe · cancel admin screens · admin: /admin/billing/plans · kit/ seams admin screens admin: /admin/billing/plans events · billing.plan.* · subscribed · cancelled · renewed · past_due · kit/ seams events · billing.plan.* subscribed · cancelled · renewed · past_due jobs · Renew · nightly at 02:15 · kit/ seams jobs Renew · nightly at 02:15 migrations/000016_billing · plans · subscriptions · FORCE RLS · kit/ seams migrations/000016_billing plans · subscriptions · FORCE RLS Spec · Events NewService Spec.Mount · RegisterRoutes crud over Tx[Tenant] events.Publish Renew Resource Deps Deps api.Resources() payments.Charge, no tx open modules/billing kit/ seams Deps · other modules' contracts/ consumers Legend Frontend Backend Database Message bus

Promises

  • • billing:read guards the plan list and the subscription; billing:manage the two commands; billing:catalog, operator-only, the plan writes
  • • billing.plan.* from the routes; subscribed, cancelled from the commands; renewed, past_due from the renewal, once each

Needs

  • • Tenants: jobs.TenantLister, the tenant module's Active lister; Payments: contracts.PaymentProvider, Manual in main or a private provider
  • • No Immutable: a plan edit applies from the next period, the price is stamped on the subscription; no PUT on the singleton

Proof

  • • contracts/billingtest: fake and real service pass one conformance suite; module_test: the price list is the operator's, renewal charges outside a tx
  • • No browser journey: e2e/admin-tasks.spec.ts exercises tasks only