Customer credit

How a customer's credit is made, used and paid back.

A customer can hold credit with you. It is kept per currency, in two kinds:

KindWhere it comes fromCan be paid out
RefundableMoney the customer paid, such as a payment that was not needed.Yes, by refunding the payment it came from.
PromotionalCredit you grant.No. It is never paid out as money.

Refundable credit

A payment becomes refundable credit when it succeeds and the customer's subscription cannot use it:

  • It lands on an invoice that is already paid. The invoice stays paid.
  • It is a first payment for a subscription that is already running, such as a second prompt that also succeeded.
  • It pays for a second subscription that the one-subscription rule stops.

You get invoice.overpaid with the paymentId, the amount and the currency. It names the invoiceId when an invoice was paid twice. For a second subscription there is no invoiceId, and subscriptionId is the subscription the customer holds. A customer.balance.updated event follows.

A payment in another currency than the invoice's is not credit. You get invoice.payment_mismatched for it.

Promotional credit

Call Grant credit to a customer with a key that has the billing.write scope:

curl -X POST "https://api-malipo.flex.co.tz/api/v1/customers/<id>/credit-grants" \
  -H "Authorization: Bearer <token>" \
  -H "Idempotency-Key: 3a8d1f6b-7c2e-4b9a-a5d4-0e1f2a3b4c5d" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "currency": "TZS",
    "reason": "Apology for the late renewal",
    "expiresAt": "2026-12-31T23:59:59Z"
  }'
  • amount is an integer in the minor unit and above zero. Only TZS is accepted.
  • reason is 1 to 500 characters.
  • expiresAt is optional and must be in the future. Without it the credit never expires.
  • You get 201 and the grant. Repeating the request with the same Idempotency-Key returns the same grant.

When expiresAt passes, the part of the grant that was not used expires and the balance goes down by that part. An expired grant is never used on an invoice. Refundable credit never expires.

How credit is used

When a renewal or an upgrade invoice opens, the customer's credit in the invoice's currency is applied up to the amount due. Promotional credit goes first, the grant that expires soonest first. Refundable credit follows, the oldest first. Nothing is asked of the customer for the part that credit covers.

  • The invoice shows creditApplied, and amountRemaining is what is left to pay. The pay link asks for amountRemaining.
  • Credit never leaves less to pay than the smallest payment the mobile money networks accept. If it would, less credit is used.
  • An invoice that credit covers in full is paid at once with amountPaid of 0, and the subscription renews or upgrades as for any paid invoice. It has no pay link, and you get invoice.paid without a paymentId.
  • If the invoice is voided, the credit it used goes back to where it came from. Promotional credit that has expired by then does not come back.

Pay refundable credit back

Refund the payment the credit came from with Create a refund. The customer's credit from that payment goes down by the refunded amount, or by what is left of it if the customer already used some. Promotional credit is not paid out.

Read a balance

Retrieve a customer's credit balance with billing.read returns balances, one entry per currency with refundable and promotional. A customer who never had credit has an empty balance.

List a customer's credit entries returns every change, newest first, and pages like other lists. See Pagination. Each entry has a kind:

kindMeaning
overpaymentA payment became refundable credit.
grantedYou granted promotional credit.
usedAn invoice used credit. The amount is negative.
returnedCredit went back after an invoice was voided. A refund or reversal of the invoice's payment leaves the credit it used as used.
expiredThe unused part of a grant expired. The amount is negative.
refundedCredit left the balance because its payment was refunded or reversed. The amount is negative.

More kinds may be added, so do not treat an unknown kind as an error.

Webhooks

customer.balance.updated arrives whenever a balance changes. It carries customerId, currency, the balance after the change as refundable and promotional, the change, and the kind of the change.

{
  "customerId": "4f1d7c2e-8a3b-4c5d-9e6f-0a1b2c3d4e5f",
  "currency": "TZS",
  "refundable": 15000,
  "promotional": 0,
  "change": 15000,
  "kind": "overpayment"
}

Credit notes

A credit note against a paid invoice splits its amount into refundedAmount, creditedAmount and outOfBandAmount. The three add up to amount. A credit note for a refund carries the refundId.

On this page