Credits and balances
The two kinds of credit: a money balance that pays future invoices, and prepaid credits your app spends.
Two different things are called credit. They never mix.
| Credit balance | Prepaid credits | |
|---|---|---|
| Unit | money, in the invoice's currency | a currency of your own, in whole units |
| Used by | Payrudder, on the next invoice | your app, when it spends them |
| Tied to invoices | yes | no, separate from meters and invoices |
A credit balance in money
When an invoice has to be reduced without refunding a card, the amount goes to the customer's credit balance, in the invoice's currency, and pays their next invoices. It comes from:
- a credit note (Invoices),
- the unused part of a fee when a subscription ends with
credit_unused=trueor moves to a cheaper price, - late-usage corrections that come to more than the invoice.
It is applied automatically when the next invoice is finalized, as a CREDIT line. You see it in GET /v1/customers/{external_id}/upcoming-invoice: credit_minor is what the invoice would use, credit_surplus_minor what would be added.
Giving money back to a card is a different act: a credit note with refund_to_card (Invoices).
Prepaid credits
Credits are a currency of your own: a customer buys or is given a number of them and your app spends them (generated pages, API calls, anything you count in whole units).
Balance
GET /v1/customers/{external_id}/credits returns what the customer can spend now (credits whose time has passed are left out) and lots, where it comes from, the ones that expire first at the top. A lot has a source:
| Source | Meaning |
|---|---|
purchase | a pack that was paid for |
promo | a promotion |
manual | given by hand |
Give
POST /v1/customers/{external_id}/credits/grant, for a promotion, a goodwill gesture or a sale made outside Payrudder.
With an idempotency_key (or the Idempotency-Key header) a repeat adds nothing and answers replayed: true. The same key with other values is billing.credits.key_reused.
Spend
POST /v1/customers/{external_id}/credits/consume takes the credits that expire first. With too few credits nothing is taken and the answer is 409 billing.credits.insufficient.
An idempotency key is required on consume, so a retried call returns the first result instead of charging twice (Idempotency).
History
GET /v1/customers/{external_id}/credits/ledger lists every change, newest first. Each row has a kind:
| Kind | Meaning |
|---|---|
grant | credits were added |
consume | credits were spent |
expire | credits passed their time |
revoke | the credits of a credit pack whose invoice was voided or credited were taken back; it never takes the balance below 0, and the part that was already spent is written in the row's note |
Sell
A credit pack is a number of credits for a price in one currency (POST /v1/credit-packs). POST /v1/credit-packs/{id}/activate puts it on sale and POST /v1/credit-packs/{id}/deactivate withdraws it; credits already sold are not touched.
A customer buys a pack through a payment link, and the credits are granted when the payment is confirmed (webhook credits.purchased).
Warn
PUT /v1/credits/settings sets a low_threshold. A consume that takes a customer's balance from at least that number to fewer announces credits.low once (Webhooks). 0, the default, turns it off.
In the console this is Credits: a customer's balance, the packs you sell and the low-balance alert.