Two paths, one core
You model what you sell once and attach customers to it. From there, usage flows down one of two paths: The difference is when money settles:| Dollar billing | Credit billing | |
|---|---|---|
| Settles | At invoice time — usage aggregates and is billed at the end of the cycle | At track time — the balance is deducted the moment usage is reported |
| Customer holds | A running tab that becomes an invoice | A prepaid balance that draws down |
| Runs out of money by | Non-payment of an invoice | Hitting a zero balance |
| Real-time gate | Entitlement check | check against remaining balance |
The credit path, step by step
Track
Your app reports what happened — a message sent, a token consumed, an API call made — with
track. This is the same call the dollar path uses; UnitPay routes it by how the plan is priced. See the two verbs.Resolve the charge
UnitPay converts the raw usage into a credit cost. In a credit system, each feature has a credit cost per unit — 6 premium messages at 3 credits each resolves to 18 credits.
Deduct FIFO
The resolved cost is deducted from the customer’s open grants in priority order, FIFO within a priority. Expiring grants are spent before permanent ones, so nothing is wasted.
Ledger
Every grant and every deduction is written to the append-only ledger. The customer’s balance is always the sum of their open grants — never a number you mutate directly.
When to reach for credits
Credits fit when the customer pays (or is granted) before they use, and value is consumed action-by-action:- Recurring allowances — “1,000 credits/month” that refill each cycle, burned per message or per action (Lovable-style).
- Prepaid balances — “$10 of credit” bought upfront and drawn down per token in dollars (Anthropic-API-style). See Denominations for the unit-vs-fiat distinction.
- Daily free drips on top of a paid allowance.
- Metered work with an unknown cost — reserve a budget, then reconcile. See Reserving before you spend.
Explore the credit path
Denominations
Unit credits vs. fiat credits — and the rule never to mix them.
Grants & priority
What a grant is, the priority convention, and FIFO tie-breaks.
Wallets & the ledger
Credit accounts, their lifecycle, and the append-only record.
Top-ups
Refill a balance manually, automatically, or by credit package.
Run it end to end
The Quickstart: grant credits, spend them, read the ledger.
React credit hooks
Render balances, ledger, top-ups, and burn in your app.