Prepaid credits

Prepaid credits that customers spend down

Some products are easier to sell as a balance than as a bill: buy 10,000 credits, use them as you go. TenaBill keeps the balance, the expiry and the history for each customer, and your app spends credits with one call.

The situation

A balance has to be exact. Two requests that arrive together must not spend the same credit, and a retry must not charge a customer twice. TenaBill takes an idempotency key on every spend, so a repeated request returns the first answer.

Credits can also expire. When a customer has several lots, TenaBill spends the lot that expires first, and lots that never expire last.

How it works in TenaBill

  1. Define packsThrough the console API, create packs. A pack has a name, a number of credits, a price, a currency and an optional expiry from 1 to 3,650 days. Credits, price and expiry are fixed when the pack is created; create a new pack to change what a purchase delivers.
  2. Give a customer creditsAn operator can grant credits through the console API with a written reason. A grant carries no payment, is bounded, and is recorded in the audit log.
  3. Spend credits from your appCall drawdown with the number of credits and an idempotency key. If the balance cannot cover it, TenaBill answers 402 with insufficient_credits so your app can refuse the work or offer a top-up.
  4. Warn before the balance runs outSet a low-balance threshold on the customer wallet. TenaBill sends a prepaid_credits.low_balance webhook once, then re-arms it when the balance recovers.
  5. Refund a pack fairlyRefunding a lot reverses only what is unspent and unexpired. Credits already spent are never clawed back, and the money refund goes through the normal refund flow.
POST /api/v1/prepaid-credits/customers/<customer id>/drawdown
X-TenaBill-Api-Key: <your merchant API key>
Content-Type: application/json

{
  "credits": 25,
  "idempotencyKey": "job-7741-run-1",
  "referenceType": "job",
  "referenceId": "7741",
  "description": "Report generation"
}

// 200: { "accepted": true, "replayed": false, "spendable": 975, "overdraftCredits": 0 }
// 402: { "error": "insufficient_credits", "spendable": 10, "requested": 25 }

Planned, not available yet

What is still to come

  • Buying a pack by card from the API and automatic top-up use a card charge step that is built but not switched on in the current release. Until it is, you give credits by operator grant, and the money side stays in your invoices.
  • There is no console screen for packs, wallets or the credit ledger yet. They are managed and read through the API.

Good to know

Limits to plan around

  • Credits are a balance inside TenaBill. They are not a stored-value account, and they are not money you can withdraw.
  • Usage billed through meters is separate: meters bill after the period, credits are spent as you go. Use whichever fits the product, or both.
  • Overdraft is off unless you allow it for a customer wallet, with a limit you set.

Keep reading

Try it with test cards