Overview
BoxBilling automatically generates invoices based on subscription billing periods. The invoice generation pipeline handles charge calculation, tax application, coupon discounts, wallet credit consumption, and progressive billing credits.Invoice lifecycle
| Status | Description |
|---|---|
| Draft | Editable, not yet issued |
| Finalized | Issued to customer, due for payment |
| Paid | Fully settled |
| Voided | Canceled after finalization |
Invoice types
| Type | Description |
|---|---|
subscription | Regular periodic billing |
add_on | One-time add-on charge |
credit | Credit adjustment |
one_off | Manual one-time charge |
progressive_billing | Mid-period usage threshold billing |
Invoice generation pipeline
When an invoice is generated for a subscription billing period, the system executes these steps:1. Calculate charge fees
For each charge on the subscription’s plan:- Aggregate usage via the appropriate billable metric
- Apply the charge model calculator (standard, graduated, volume, etc.)
- Apply min/max price capping if configured
- Handle charge filters for segmented pricing
2. Generate commitment true-up fees
If the plan has minimum commitments and actual charges are below the minimum, a true-up fee is added for the difference.3. Apply taxes
Taxes are resolved hierarchically:- Charge-level taxes (most specific)
- Plan-level taxes
- Customer-level taxes
- Organization-level defaults
AppliedTax records. Fee-level taxes are aggregated into the invoice tax_amount.
4. Apply coupon discounts
Active coupons on the customer are applied:- Fixed amount — deducted directly, capped at remaining subtotal
- Percentage — calculated as
subtotal × rate / 100
once— terminated after single userecurring— decremented per billing periodforever— never consumed
5. Apply wallet credits
If the customer has active wallets, credits are consumed in priority order (lower priority number = consumed first). Wallet transactions and invoice settlements are recorded.6. Subtract progressive billing credits
If progressive billing invoices were issued during the period, their total is credited on the final period invoice to prevent double-billing.Automatic invoice generation
Thegenerate_periodic_invoices task runs hourly and creates invoices for:
- Active subscriptions whose billing period has ended (pay-in-arrear)
- Active subscriptions whose billing period is starting (pay-in-advance)
Manual operations
Finalize an invoice
draft to finalized. Applies wallet credits and sends an invoice.finalized webhook.
Mark as paid
paid. Sends an invoice.paid webhook.
Void an invoice
invoice.voided webhook.
Delete a draft
draft invoices can be deleted.
Fees
Fees are the individual line items on an invoice. Each fee represents a calculated charge:| Fee type | Description |
|---|---|
charge | Usage-based charge from a billable metric |
subscription | Base plan subscription fee |
add_on | One-time add-on charge |
credit | Credit adjustment |
commitment | Minimum commitment true-up |
Fee properties
Each fee records:amount_cents— pre-tax amounttaxes_amount_cents— tax amounttotal_amount_cents— amount + taxesunits— usage units consumedevents_count— number of eventsunit_amount_cents— price per unit
Invoice settlements
Invoices can be settled through multiple sources:| Settlement type | Description |
|---|---|
payment | Direct payment (Stripe, Adyen, etc.) |
credit_note | Applied credit from a credit note |
wallet_credit | Prepaid wallet credits |
paid when settlements equal or exceed the total.
Credit notes
Credit notes are issued against finalized invoices for adjustments, refunds, or corrections.Create a credit note
Credit note workflow
- Create (draft) → Finalize → Apply to invoice or Void
- Credit notes have a
balance_amount_centsthat decreases as credits are applied - Applying credit to an invoice creates an
InvoiceSettlementrecord
Webhooks
| Event | Trigger |
|---|---|
invoice.created | Invoice generated |
invoice.finalized | Invoice finalized |
invoice.paid | Invoice fully paid |
invoice.voided | Invoice voided |
API endpoints
| Method | Path | Description |
|---|---|---|
GET | /v1/invoices | List invoices |
GET | /v1/invoices/{id} | Get invoice details |
PUT | /v1/invoices/{id} | Update a draft invoice |
POST | /v1/invoices/{id}/finalize | Finalize an invoice |
POST | /v1/invoices/{id}/pay | Mark as paid |
POST | /v1/invoices/{id}/void | Void an invoice |
GET | /v1/invoices/{id}/settlements | List settlements |
DELETE | /v1/invoices/{id} | Delete a draft invoice |
GET | /v1/fees | List fees |
GET | /v1/fees/{id} | Get fee details |
GET | /v1/credit_notes | List credit notes |
POST | /v1/credit_notes | Create a credit note |
POST | /v1/credit_notes/{id}/finalize | Finalize a credit note |
POST | /v1/credit_notes/{id}/void | Void a credit note |