Fase 4 — Billing & Admin Panel

 

Fase 4 — Billing & Admin Panel ✅

Backend (backend/)

New files:

  • backend/src/lib/midtrans.ts — Midtrans Snap API helper (createSnapTokenverifyMidtransSignature)
  • backend/src/routes/billing.ts — tenant billing routes:
    • GET /billing/subscriptions — per-outlet subscription status
    • GET /billing/invoices — invoice history
    • POST /billing/invoices/:id/snap — creates Midtrans Snap token, records pending payment row
    • POST /billing/midtrans/notify — webhook: verifies signature, marks invoice paid, extends subscription period
  • backend/src/routes/admin.ts — saas_owner-only routes:
    • GET /admin/dashboard — MRR, active/trialing/past_due counts, unpaid invoices
    • GET /admin/tenants — paginated tenant list with subscription summary
    • GET /admin/tenants/:id — tenant detail with outlets, subscriptions, invoices
    • POST /admin/tenants/:id/extend — manual 1-month extension (marks any pending invoice paid)
    • POST /admin/invoices/generate — generates invoices for subscriptions expiring within 7 days

Modified:

Web (web/)

New files:

Modified:

Setup sebelum testing Midtrans

  1. Daftar di dashboard.sandbox.midtrans.com
  2. Ambil Server Key → isi MIDTRANS_SERVER_KEY di backend/.env
  3. Ambil Client Key → isi NUXT_PUBLIC_MIDTRANS_CLIENT_KEY di web/.env
  4. Di Midtrans dashboard, set Payment Notification URL ke http://your-domain/billing/midtrans/notify

Comments

Popular posts from this blog

roadmap / tahapan pembuatan aplikasi

tahap 2