From 0e1d2fb0d19362ad71e05036b53f4640a9ce2f2b Mon Sep 17 00:00:00 2001 From: Ronni Baslund Date: Sat, 30 May 2026 08:03:23 +0200 Subject: [PATCH] feat(billing): Stripe-backed billing engine (dark-launched) Add a lazy/guarded Stripe client (boots without keys), Invoice/Payout schemas, per-currency Price.stripePriceIds, and a BillingService deriving partner/platform summaries, invoices and a partner-cut payout ledger. Partner and operator billing controllers plus a signature-verified Stripe webhook (Fastify raw body). Frontend: partner and operator billing pages and the operator tenant billing/audit tabs on real data. Gated behind new_billing_engine and BILLING_STRIPE_ENABLED; live money paths stay off until keys are set. --- apps/operator/pages/billing.vue | 137 ++++++++- apps/operator/pages/tenants/[slug].vue | 80 ++++- .../server/api/billing/invoices.get.ts | 4 + .../server/api/billing/summary.get.ts | 4 + .../billing/tenants/[slug]/invoices.get.ts | 7 + apps/portal/pages/partner/billing.vue | 275 ++++++++++-------- .../api/partner/billing/invoices.get.ts | 19 ++ .../server/api/partner/billing/payouts.get.ts | 19 ++ .../server/api/partner/billing/summary.get.ts | 19 ++ services/platform-api/package.json | 3 +- services/platform-api/pnpm-lock.yaml | 79 +++++ services/platform-api/src/app.module.ts | 2 + .../src/billing/billing.module.ts | 34 +++ .../src/billing/billing.service.ts | 211 ++++++++++++++ .../billing/operator-billing.controller.ts | 26 ++ .../src/billing/partner-billing.controller.ts | 37 +++ .../src/billing/stripe-webhook.controller.ts | 46 +++ .../src/integrations/integrations.module.ts | 5 +- .../src/integrations/stripe.client.ts | 87 ++++++ services/platform-api/src/main.ts | 3 + .../src/schemas/invoice.schema.ts | 56 ++++ .../platform-api/src/schemas/payout.schema.ts | 38 +++ .../platform-api/src/schemas/price.schema.ts | 16 + 23 files changed, 1064 insertions(+), 143 deletions(-) create mode 100644 apps/operator/server/api/billing/invoices.get.ts create mode 100644 apps/operator/server/api/billing/summary.get.ts create mode 100644 apps/operator/server/api/billing/tenants/[slug]/invoices.get.ts create mode 100644 apps/portal/server/api/partner/billing/invoices.get.ts create mode 100644 apps/portal/server/api/partner/billing/payouts.get.ts create mode 100644 apps/portal/server/api/partner/billing/summary.get.ts create mode 100644 services/platform-api/src/billing/billing.module.ts create mode 100644 services/platform-api/src/billing/billing.service.ts create mode 100644 services/platform-api/src/billing/operator-billing.controller.ts create mode 100644 services/platform-api/src/billing/partner-billing.controller.ts create mode 100644 services/platform-api/src/billing/stripe-webhook.controller.ts create mode 100644 services/platform-api/src/integrations/stripe.client.ts create mode 100644 services/platform-api/src/schemas/invoice.schema.ts create mode 100644 services/platform-api/src/schemas/payout.schema.ts diff --git a/apps/operator/pages/billing.vue b/apps/operator/pages/billing.vue index bd65e64..60c6932 100644 --- a/apps/operator/pages/billing.vue +++ b/apps/operator/pages/billing.vue @@ -1,10 +1,133 @@ - + + + diff --git a/apps/operator/pages/tenants/[slug].vue b/apps/operator/pages/tenants/[slug].vue index 0519782..7a951a6 100644 --- a/apps/operator/pages/tenants/[slug].vue +++ b/apps/operator/pages/tenants/[slug].vue @@ -1,5 +1,6 @@