Record a payment
Record money a customer paid you outside Flex Malipo against an open invoice, in part or in full.
A customer can pay an invoice by bank transfer, in cash, by cheque, to your own mobile money till or by a method you
name. Flex Malipo never sees that money, so you tell it: call
Record a payment on an invoice with a key that has the
billing.write scope.
Only an open invoice takes a recorded payment. The payment is a payment record: it is permanent, it takes no fee
and it does not change your balance.
Record a payment
curl -X POST "https://api-malipo.flex.co.tz/api/v1/invoices/<invoice id>/payments" \
-H "Authorization: Bearer <token>" \
-H "Idempotency-Key: 3b9f6c2e-7d41-4a58-8e0c-5a1d2f9b7c64" \
-H "Content-Type: application/json" \
-d '{
"amount": 4000,
"paidAt": "2026-12-01T09:30:00Z",
"payment_method_data": { "type": "bank_transfer" },
"reference": "TRF-20261201-0042",
"note": "Paid to the accountant, ledger page 12"
}'| Field | Meaning |
|---|---|
amount | What the customer paid, an integer in the currency's minor unit. More than zero and at most amountRemaining. |
paidAt | When the customer paid, in UTC. Not in the future and not before the invoice was created. |
payment_method_data.type | bank_transfer, cash, cheque, mobile_money (your own till) or custom. |
payment_method_data.custom.display_name | The name of the method, such as Barter. Required with custom, and only then. |
reference | A reference your customer sees on the receipt, 1 to 100 characters. Optional. |
note | Your own note, 1 to 1000 characters. Optional. |
The Idempotency-Key header is required. The answer is 201 with the invoice as it is now: the new payment is the
last item of payments, and amountRemaining is what is still to pay.
Your note is private. No invoice, receipt, email or event carries it, and the API does not return it.
Part payments and the rest
The amount may be the whole amountRemaining or part of it. Take an invoice of TZS 10,000:
- You record
4000. The invoice staysopen,amountRemainingis6000, and you getinvoice.updated. The customer gets a receipt by email, and the pay link now asks for6000. - You record
6000. The invoice ispaidandamountRemainingis0. It settles the way a payment through the pay link does: you getinvoice.paid, a subscription that waspast_duebecomesactive, and the subscription renews. Both payments are inpayments.
A renewal invoice opens at the period end and is due daysToPay days later. See
Renewals and days to pay.
The remainder rule
- An amount above
amountRemainingis refused with400and the codeamount_too_large.limit.maximumis the most you can record. - A part payment that would leave less to pay than the smallest amount a customer can pay online is refused with
400and the codeamount_too_small.limit.minimumis that smallest amount. The customer pays the rest through the pay link, so the rest has to be an amount the link can take. Record the wholeamountRemaining, or a smaller part. See Amount limits.
{
"error": {
"type": "invalid_request_error",
"code": "amount_too_small",
"message": "This payment would leave 200 TZS to pay, which is less than the smallest amount a customer can pay, 500 TZS. Record the full 15000 TZS or a smaller part",
"param": "amount",
"limit": { "minimum": 500, "currency": "TZS", "operation": "collection" },
"requestId": "req_0123456789abcdef0123456789abcdef"
}
}An invoice for an upgrade that must be paid first
An UPGRADE invoice whose upgrade applies only once it is paid takes only its full remaining amount. That is an invoice
of a subscription collected by checkout, or collected by invoice when your invoiceStartAccess setting is
after_payment. Any other amount is refused with 400 and the code amount_too_small, and limit.minimum and
limit.maximum both hold the full amount. Credit notes and the customer's credit still lower what is owed. After the
invoice's expiresAt it takes no payment and answers 409 with the code invoice_not_open: the upgrade was not applied.
Refusals
| Status | Code | Why |
|---|---|---|
400 | amount_too_large, amount_too_small | The amount breaks the remainder rule above. |
400 | parameter_invalid | A field is not valid, or paidAt is in the future or before the invoice was created. |
400 | idempotency_key_reused | The Idempotency-Key was already used with another body. |
404 | resource_missing | You have no invoice with this ID in the mode of your key. |
409 | invoice_not_open | The invoice is paid or void, its subscription takes no payment, or it is an expired invoice for an upgrade. |
409 | payment_in_progress | Your customer has a payment on the invoice in progress through the pay link. Nothing was recorded. Try again when that payment has completed. |
503 | service_unavailable | The payment could not be recorded right now and nothing changed. Try again in a moment. |
To retry safely, send the same request with the same Idempotency-Key: you get the first answer back with
Idempotent-Replayed: true and the payment is recorded once. A payment_in_progress or 503 answer is not kept, so the
same key can be sent again. See Idempotency.
A payment is permanent: it cannot be changed or removed, and an invoice with a payment cannot be voided. If the invoice is paid or voided while your request runs, the request is refused and the payment record stays without an invoice.
Read your payment records
Every recorded payment is also a payment record.
List payment records returns them, the most recently paid
first, one page at a time, and
Retrieve a payment record returns one. Both need the
payments.read scope and answer for the mode of your key. See Pagination.
{
"id": "3c9d2f4e-7a1b-4e8c-9f2d-5b6a7c8d9e0f",
"amount": 150000,
"currency": "TZS",
"paidAt": "2026-12-01T09:30:00Z",
"payment_method_details": { "type": "bank_transfer" },
"reference": "TRF-20261201-0042",
"customerId": "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"livemode": false,
"createdAt": "2026-12-01T10:02:11Z"
}payment_method_details.type is bank_transfer, cash, cheque, mobile_money or custom. With custom it also
holds custom.display_name. A payment record has no fee and no network. reference is left out when you sent none.
Tell customers how to pay
A customer who pays outside Flex Malipo needs to know where to send the money. Save your bank details or any other
instructions in paymentInstructions with
Update billing settings:
{
"paymentInstructions": "Pay by bank transfer to Example Bank, account 0123456789, and quote the invoice number.",
"supportEmail": "billing@example.com"
}paymentInstructionsis plain text of up to 1000 characters. It is shown as text, never as markup.- It shows on the payment page and on the PDF of an open invoice, and in the invoice email of a subscription collected by invoice.
supportEmailis the address a customer is told to write to about an invoice above the largest mobile money payment when you set no payment instructions.
The call replaces all your settings, so send every field you want to keep, and leave paymentInstructions out only to
clear it. See Renewals and days to pay.
Once the customer has paid, record the payment. Their receipt is described in Receipts and payment history.