Billing & invoices

Backed by billing.py (~1,315 lines), against saas.invoice.

GET /api/billing

Tenant billing summary — current plan cost, next renewal date, payment method on file.

GET /api/invoices

List invoices for the caller’s tenant.

GET /api/invoices/<id>

Single invoice detail.

GET /api/invoices/<id>/download

Returns the invoice as a downloadable file (PDF).

All four routes require auth and are tenant-scoped the same way instances and backups are — an invoice belonging to another tenant returns 404 rather than 403, to avoid confirming the invoice ID exists at all.

For how invoices get created in the first place, see M-Pesa integration — successful STK Push callbacks create an account.payment that reconciles against the tenant’s subscription invoice.