Billing Engine

Execute the Math. Route the Revenue.

The Billing Engine ingests billable units, applies your active rate plans, manages prepaid wallets in real time, and generates pixel-perfect invoices, or exports pre-calculated line items directly to your ERP. Absolute financial accuracy at scale.

This is the execution layer. Metering captures the events. Pricing defines the rules. Billing does the math, rating, proration, drawdowns, discounts, tax, settlement, across a 10-stage deterministic pipeline (QuotaCheck → Rollover → Aggregate → Allowance → Rate → Commit → Discount → Tax → Route → Settle). Use Aforo invoices natively, or route the calculated charges to QuickBooks, Xero, or NetSuite, or any other ERP via the Custom Webhook adapter (HMAC-signed).

10-Stage Pipeline Sequencer
LIVE
Rate
Prorate
Commit
Discount
Wallet
Overage
Tax
Route
Settle
Dunning
PREPAID WALLET
$12,400
Balance remaining
INVOICE TOTAL
$0
Revenue collected
FINAL INVOICE
INV-2026-0412, Acme Corp
SETTLED
Platform fee$2,000
Usage (1.2M calls)$4,832
Proration (upgrade)$603
Overage (160K tokens)$960
Discount (15%)−$1,259
Total$7,136
Architecture

Execute the Math. Automate the Collection.

INPUT 1
Metering Engine: Billable Units
Acme: 124K tokens
GlobalBank: 89K calls
DataSync: 312K events
INPUT 2
Pricing Studio: Active Offer Rules
Currency: USD
Overage: $0.003/call
Commit: $24K/yr
OUTPUT A
Aforo Invoices
SETTLED
Billing Engine: Apply Rules & Process Math
Wallet Mgmt
Overage Calcs
Proration
RateCommitDiscountTaxRouteSettle
OUTPUT A
Aforo Invoices
SETTLED
Platform + Usage + Overage$2,520
Tax (Avalara)$201
Discount (15%)−$378
Total$2,343
, OR -
OUTPUT B
ERP / General Ledger
SCHEDULED
QuickBooksPre-calculated line items
XeroPre-calculated line items
NetSuitePre-calculated line items
Custom WebhookPre-calculated line items

The Billing Engine is your deterministic revenue pipeline. It consumes processed usage data from the Metering Engine and applies the specific Offer rules defined in the Pricing Studio to calculate overages, manage wallets, and produce audit-ready output, either as native Aforo invoices with automated tax, or as pre-calculated line items exported directly to your ERP.

The Atomic Unit

Charge + Recognition. Two Halves of a Closed Book.

Every billable event in Aforo produces two outputs simultaneously. A Charge that hits the invoice and gets settled through 5 payment gateways. A Recognition that books revenue to the GL per ASC 606 and posts journals to your ERP. Stripe Billing handles the charge. Chargebee adds light recognition. Aforo does both, natively, with audit-grade lineage between them.

Money on the Wire
Charge

The settlement event. Rated, prorated, discounted, taxed, routed to the right gateway, retried on decline. Lands on the invoice as a line item with full provenance to the source event.

10-stage pipeline
QuotaCheck → Rollover → Aggregate → Allowance → Rate → Commit → Discount → Tax → Route → Settle
3 settlement modes
POSTPAID (invoice) · PREPAID (wallet drawdown) · HYBRID (split)
5 payment gateways
Stripe · PayPal · Razorpay · Adyen · Worldpay (uniform retry + reconciliation)
Tax automation
Avalara provider (live) + pluggable TaxProvider SPI for additional vendors
Adaptive Payment Retry
Smart Retries-style decline classification — RETRYABLE backs off 1h → 24h → 72h → 7d → 14d
+
= Closed Book
Booked to the GL
Recognition

The accounting event. Performance obligations identified at contract creation, ratable schedules pre-computed, journals auto-posted on issue and period close. ASC 606 / IFRS 15 compliant by construction, not by spreadsheet.

ASC 606 / IFRS 15
5-step model: identify contract → identify POs → determine price → allocate → recognize
4 contract entities
RevRecContract · PerformanceObligation · RecognitionSchedule · JournalEntry (V39 + V40)
3 modification treatments
SEPARATE_CONTRACT · PROSPECTIVE · CUMULATIVE_CATCHUP — per ASC 606 § 21
Double-entry journals
Auto-posted on invoice issue and period close — debit deferred / credit recognized
GL sync to ERP
Journals push to QuickBooks · Xero · NetSuite · Custom Webhook on configurable schedule

Bolt-on revenue recognition tools (Zuora RevRec, NetSuite ARM, custom Excel) cost six figures and take quarters to integrate. Aforo's atomic unit is the Charge AND its Recognition, so the books are closed the moment the invoice settles.

The Surface

ASC 606 Recognition. Built In, Not Bolted On.

One contract. Three performance obligations. Pre-computed 12-month recognition schedule. Auto-posted journals to your ERP. What used to require a six-figure spreadsheet model is now a page in your billing console.

aforo.app / billing / revenue-recognition / contract / RR-2026-0412
ACTIVE
Contract
Acme Enterprise Plan
RR-2026-0412 · 24-month term · Apr 2026 → Mar 2028
Total ACV
$480,000
Recognized YTD
$200,000
Deferred Balance
$280,000
Performance Obligations (3)
Platform Access (subscription)
$240,000
Ratable monthlyRemaining: $140,000
AI Tokens (consumption)
$192,000
As consumedRemaining: $112,000
Premium Support (subscription)
$48,000
Ratable monthlyRemaining: $28,000
12-Month Schedule (Apr → Mar)
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Jan
Feb
Mar
Recognized ($200K)
Deferred ($280K)
Journal Entries (auto-posted)DOUBLE-ENTRY
DateAccountDebitCredit
Apr 30Deferred Revenue$40,000
Apr 30Recognized Revenue$40,000
May 31Deferred Revenue$40,000
May 31Recognized Revenue$40,000
ERP Sync: QuickBooks
Last: 2 min ago
Journals pushed
247 / 247
Retry queue
0
Modifications
3

Same V39 + V40 schema your auditor signed off on. Three modification treatments per ASC 606 § 21 (SEPARATE_CONTRACT, PROSPECTIVE, CUMULATIVE_CATCHUP). One click to close the period.

Five Execution Layers. Zero Manual Intervention.

The Billing Engine consumes metered events and Offer rules, then executes: rating, wallet management, invoice generation with tax, ERP sync, and revenue recognition per ASC 606. Every layer is deterministic and produces audit-grade output.

Automated Rating & Proration

Raw metered events arrive already enriched with customer and subscription context. The Billing Engine applies the correct active Offer rules, per-unit rates, graduated tiers, volume thresholds, and calculates the charge. Mid-cycle upgrades, downgrades, and overage calculations are handled automatically with deterministic proration math. No spreadsheets. No Finance tickets.

Prepaid Wallet Management

Prepaid customers fund a wallet. Usage draws it down in real time with atomic escrow holds, pessimistic locking ensures no overdraft, no double-debit. Balance tracking updates per billing event, not per cycle. Automated threshold alerts at 75%, 90%, and 100% consumption. When exhausted, the engine blocks, throttles, or spills to arrears, based on the Offer configuration.

Native Invoicing & Automated Tax

At period close, the engine consolidates every charge, recurring fees, one-time charges, metered usage, proration adjustments, overage surcharges, and discounts, into a single finalized invoice. Tax is calculated automatically via the Avalara tax adapter for global compliance across jurisdictions (pluggable SPI for additional providers). Failed payments trigger Adaptive Payment Retry with decline classification across all 5 gateways.

Bring Your Own Billing (ERP Sync)

Already have a billing system? Aforo does the hard math, rating, proration, overage calculation, discount application, wallet drawdown, and exports pre-calculated, dollar-value line item records on a configurable schedule. Import directly into QuickBooks, Xero, or NetSuite, or any other ERP via the Custom Webhook adapter (HMAC-signed). Your finance team keeps their existing tools and workflows. Aforo handles the usage-based complexity they cannot.

Revenue Recognition (ASC 606 / IFRS 15)

Every contract automatically creates performance obligations, ratable schedules, and double-entry journal entries on issue. The recognition pipeline executes the ASC 606 5-step model (identify contract → identify POs → determine transaction price → allocate to POs → recognize revenue) with three modification treatments (SEPARATE_CONTRACT / PROSPECTIVE / CUMULATIVE_CATCHUP). Journals post to QuickBooks, Xero, or NetSuite on close. SOX-ready audit trails by construction.

How It Works

From metered usage to paid invoice in four stages

Every contract term is enforced by the pipeline. Every charge is auditable. Every invoice is deterministic.

Aggregate Usage Instantly

Metered events arrive pre-enriched with billing context

The metering engine delivers validated, enriched usage events tagged with customer, subscription, and rate plan. The billing pipeline aggregates by billing period, applies quota checks and rollover credits. No manual data export, no CSV reconciliation, no scripts.

Apply Custom Contract Terms

RateStage → CommitStage → DiscountStage

Eight pricing models execute in the RateStage: per-unit, flat rate, percentage, included quota, graduated staircase, volume-tiered, staircase, and block overage. CommitStage enforces minimum spend true-ups and maximum spend caps. DiscountStage applies loyalty discounts, promotional pricing, and customer-redeemable coupons (PERCENTAGE / FIXED_AMOUNT / FREE_TRIAL_DAYS), all encoded in the rate plan, not in billing team spreadsheets.

Generate Tax-Compliant Invoices

TaxStage → RouteStage → SettleStage

Tax calculations applied per jurisdiction. The RouteStage decides the settlement path: postpaid customers receive invoices, prepaid customers see wallet drawdowns, hybrid customers split automatically. Every invoice carries line-item detail traceable to source events, ready for audit, ready for the customer portal.

Automate Collections & Reconciliation

Dunning scheduler + automatic recovery

Failed payments enter an automatic retry sequence with configurable intervals and escalation rules. Subscriptions suspend after maximum retries. Payment recovery triggers immediate reactivation. Finance sees a clean reconciliation report, settled, pending, recovered, and written-off, without chasing down individual transactions.

Payment Resilience

Settle First Time. Reconcile Every Night.

Two production-grade controls run on top of the settlement pipeline. Adaptive retry classifies every decline and recovers 87% of failed payments automatically. Nightly reconciliation catches gateway-vs-local drift within 24 hours, not at quarter-end audit.

Adaptive Payment Retry

Smart Retries · 5 gateways

Stripe Smart Retries-style decline classification across Stripe, PayPal, Razorpay, Adyen, and Worldpay. Each decline is classified as RETRYABLE (exponential backoff 1h → 24h → 72h → 7d → 14d), NON_RETRYABLE (bail and dunning), or ESCALATE_NOW (page on-call). Per-tenant and per-gateway schedule overrides for enterprise customers.

5 gateways uniform3 decline classesPer-tenant overrideIdempotent backoff
Retry schedule (RETRYABLE)
1h
24h
72h
7d
14d
87% auto-recoveredFinal = mark UNCOLLECTIBLE

Payment Reconciliation

Daily run · 5 mismatch types

Every gateway hands you a different truth. Aforo runs a nightly reconciliation across all 5 gateways, classifies each delta into 5 mismatch types (STATUS_DIVERGED, AMOUNT_MISMATCH, MISSING_LOCALLY, MISSING_AT_GATEWAY, OTHER), and queues them for operator review. Operator decides: accept gateway, accept local, force-resolve, or escalate. Drift caught within 24h, not at quarter-end.

5 mismatch typesPer-gateway adapterOperator queue UI24h max drift
Nightly recon · 5 mismatch types
STATUS_DIVERGED
Stripe says paid, local says pending
3
AMOUNT_MISMATCH
Gateway $480.50 vs local $480.00
1
MISSING_LOCALLY
Charge in gateway, not in Aforo
0
MISSING_AT_GATEWAY
Local says charged, gateway says no
0
OTHER
Operator review required
1

Most teams discover gateway drift at quarter-end audit. Aforo catches it within 24h with an operator queue and four resolution paths (accept gateway, accept local, force-resolve, escalate).

The billing pipeline, in detail

10 stages. Three settlement modes. Automatic recovery. Every charge auditable.

10-Stage Pipeline

Each stage executes in sequence. Every stage is deterministic, auditable, and generates structured logs for finance review.

Quota
Rollover
Aggregate
Allowance
Rate
Commit
Discount
Tax
Route
Settle

Invoice with Line Items

Graduated pricing, minimum spend true-ups, loyalty discounts, and tax, all computed by the pipeline.

INVOICE #INV-2026-0847
Acme Corp, Enterprise Plan
API calls (37.2K graduated)$284.00
Min. spend true-up$16.00
Loyalty discount (15%)-$45.00
Tax$25.50
Total$280.50

Prepaid Wallet & Escrow

Real-time balance tracking with atomic escrow holds. Auto-suspend when depleted, auto-resume on top-up.

PREPAID WALLET, DATASYNC
$2,450.00
$180.00 in escrow holds
Available: $2,270Held: $180

Dunning & Recovery

Automatic payment retry sequences with configurable intervals. Finance sees recovered revenue as a separate line.

DUNNING, GLOBALBANK INV-0812
Charge attempt
Mar 1
Failed
Retry (+3 days)
Mar 4
Failed
Retry (+7 days)
Mar 11
Recovered
$4,200 recovered automatically

Three Settlement Modes

Postpaid invoicing, prepaid wallet drawdowns, or hybrid split. One pipeline routes all three.

PostpaidUsage → Invoice
PrepaidUsage → Wallet
HybridWallet first → Invoice
CFO Surface

Many Entities. Many Books. One Console.

Enterprises bill from multiple legal entities (Acme US Inc, Acme EU GmbH, Acme APAC Pte Ltd) with different currencies, addresses, and tax IDs. Aforo handles per-entity invoice numbering, FX consolidation, and per-entity branding natively. The CFO Analytics suite then layers MRR Movements, Cohort Retention, Customer LTV, and Forecast on top of the consolidated ledger.

Multi-Entity Billing

P24 · billing_entities table

Each legal entity gets its own invoice number sequence, currency, registered address, tax registration number, and branding on the rendered invoice. FX engine consolidates multi-currency reporting at the tenant level. Sales picks the issuing entity at quote time; the rest is automatic.

Per-entity sequenceFX consolidationPer-entity brandingTax-ID per entity
3 entities · 3 sequences · 3 currencies
Acme US IncINV-US-002847$42,800.00USD
Acme EU GmbHINV-EU-001284€38,200.00EUR
Acme APAC Pte LtdINV-APAC-000412S$54,600.00SGD
Consolidated tenant MRR (FX → USD)$128,476.20

CFO Analytics

4 endpoints · /api/v1/invoice-stats

Four pre-built finance dashboards on top of the consolidated ledger. MRR Movements (New / Expansion / Contraction / Churn waterfall). Cohort Retention (monthly cohorts × 12-month retention triangle). Customer LTV (projected lifetime value per account). Forecast (12-month MRR projection from current cohort behavior).

MRR MovementsCohort RetentionCustomer LTVForecast
MRR Movements (Apr 2026)
NRR: 117%
Start
+New
+Exp
−Con
−Ch
End
$1.18M → $1.38M+$200K net new

Most billing platforms force a separate analytics tool (Mixpanel, ChartMogul, ProfitWell) for cohort + LTV + forecast. Aforo ships them on top of the source-of-truth ledger, so the CFO sees the same numbers the auditor sees.

The Buying Committee

One Engine. Four Stakeholders. Zero Friction.

Engineering, Product, Finance, and RevOps each get the controls they need to enforce contract terms, recognize revenue, and recover failed payments without stepping on each other. One 10-stage pipeline. One closed book per period. One source of truth for every audit.

Engineering

VP Engineering · Platform Lead

Billing math doesn’t live in our codebase anymore.

The Workflow
  1. 1Platform team launches a new product with usage-based pricing.
  2. 2Pricing Studio configures the rate plan + offering. Zero billing code.
  3. 3Metered events route through the 10-stage pipeline automatically.
  4. 4First invoice fires on next hourly bill run. Engineering ticket count for billing logic: zero.
0 billing-logic tickets per product launch

Product

VP Product · Pricing Strategist

Launch usage-based pricing in a sprint, not a quarter.

The Workflow
  1. 1PM tests consumption pricing on a new tier (GRADUATED + INCLUDED_QUOTA).
  2. 2Bill Simulator projects revenue impact across customer cohorts before publish.
  3. 3Versioned Offering published; existing customers grandfather automatically.
  4. 4A/B comparison against control cohort visible in CFO Analytics within 14 days.
Pricing experiments shipped in 5 days, not 5 months

Finance / CFO

CFO · FP&A · Controller

Close the books in 3 days. ASC 606 compliant by construction.

The Workflow
  1. 1Bill run fires hourly. 847 finalized invoices by month-end, zero manual reconciliation.
  2. 2Auto-RevRec creates performance obligations and posts journal entries to QuickBooks.
  3. 3CFO Analytics shows MRR Movements, Cohort Retention, and LTV in real time.
  4. 4Acme disputes a $24K invoice. Drill to source events via bill_run_event_index in 4 hours.
Month-end close in 3 days, audit defense in hours

RevOps / Customer Success

Head of RevOps · CS Lead

Auto-recover 87% of failed payments, reconcile every night.

The Workflow
  1. 1Customer’s card declines on a $24K invoice.
  2. 2Adaptive Payment Retry classifies as RETRYABLE, schedules 1h → 24h → 72h → 7d → 14d.
  3. 3Recovers at the 24h retry. No churn, no support ticket, no manual intervention.
  4. 4Nightly Payment Reconciliation catches a $480 STATUS_DIVERGED with Stripe. Auto-flagged for operator review.
87% auto-recovery, payment drift caught within 24h
0
Pipeline Stages
Quota · Rollover · Aggregate · Allowance · Rate · Commit · Discount · Tax · Route · Settle
0
Payment Gateways
Stripe · PayPal · Razorpay · Adyen · Worldpay
0
ERP Adapters
QuickBooks · Xero · NetSuite · Custom Webhook (HMAC-signed)
0
Settlement Modes
POSTPAID (invoice) · PREPAID (wallet) · HYBRID (split)

Your contracts deserve
a billing engine that enforces them.

Stop reconciling invoices manually. Stop missing contract terms. Start with a pipeline that turns every deal into accurate, auditable revenue.

Related Reading
CFO PlaybookASC 606 Spreadsheet Hell: Why Revenue Recognition Breaks at Scale
ProductAutomated Invoicing: From Contract to Cash in Under 60 Seconds