Skip to Content
Payrudder

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 balancePrepaid credits
Unitmoney, in the invoice's currencya currency of your own, in whole units
Used byPayrudder, on the next invoiceyour app, when it spends them
Tied to invoicesyesno, 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=true or 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:

SourceMeaning
purchasea pack that was paid for
promoa promotion
manualgiven 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:

KindMeaning
grantcredits were added
consumecredits were spent
expirecredits passed their time
revokethe 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.

Next steps