Open Source|All improvements go through Pull Requests with automated CI checks before review by@Leo-Galli|Join Discord|Contributing guide
Invoicing and dunning

Billing — Invoicing

Invoice generation, proration, dunning and webhooks.

Invoice generation

Invoices are created by the billing BullMQ queue:

curl -sS http://127.0.0.1:8000/api/billing/invoices \
  -H "Authorization: Bearer $TOKEN"

Proration

When a plan changes mid-cycle, the invoice is prorated:

  • New plan costs more → credit remaining time, charge difference.
  • New plan costs less → credit the difference to next invoice.

Dunning cycle

DayAction
0Invoice created, pending
Due dateoverdue — first retry email
+1 daySecond retry attempt
+3 daysThird retry, server suspended
+7 daysFinal attempt
+14 daysInvoice marked failed, server terminated

Coupons

Create in Admin → Billing → Coupons:

curl -sS http://127.0.0.1:8000/api/billing/coupons \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"code":"SUMMER20","type":"percentage","value":20,"max_uses":100}'

Webhooks

Payment events trigger outbound webhooks:

EventWhen
invoice.createdInvoice generated
invoice.paidPayment received
invoice.overduePast due date
server.suspendedDunning exhausted

See also: Webhooks, Billing plans.