The ledger
Every collection, payout and refund is a transaction. How they're typed, how they resolve, and how references keep retries safe.
RazPay keeps one ledger per project. Each row is a transaction: money in, or money out.
type |
direction |
What it is |
|---|---|---|
collection |
in |
A customer paid you: a payment request, a charge under a pre-approval, or a paid invoice. |
payout |
out |
You sent money from your disbursement account to someone. |
refund |
out |
You returned money for an earlier collection. |
Lifecycle
Every transaction starts pending and ends successful or failed. It never changes after that.
- You create it (collect, pay out or refund). RazPay records it as
pendingand sends the instruction to the provider. - The provider resolves it. MTN tells RazPay through a callback, and RazPay also checks every pending transaction in the background, so a missed callback never leaves one stuck.
- RazPay records the result and sends your project a webhook.
If the provider rejects the request outright (an unknown number, for example), the API call itself fails and the transaction is recorded as failed.
A transaction the provider still can’t resolve after 24 hours is closed as failed with the reason expired: provider returned no terminal status within the reconciliation window. In practice a customer has about 5 minutes to approve a MoMo prompt.
References and retries
You give every transaction an external_reference: your own order id, payout id or similar. It’s unique within your project, across every type: a payout can’t reuse a collection’s reference.
The reference makes every write safe to retry. Sending the same request again with the same external_reference returns the original transaction instead of charging or paying twice. If your request times out, retry it with the same reference.
Look any transaction up by its reference with GET /payments/{reference}.
The transaction object
external_referencestringrequiredYour reference for this transaction.
typestringrequiredcollection, payout or refund.
directionstringrequiredin for collections, out for payouts and refunds.
provider_idstringrequiredThe provider it went through, e.g. momo.
provider_refstringThe reference RazPay gave the provider (MoMo’s X-Reference-Id). Quote it when you contact the provider.
amountnumberrequiredAmount in major units, e.g. 30.00.
currencystringrequiredISO 4217 code, e.g. SZL.
statusstringrequiredpending, successful or failed.
financial_tx_idstringThe provider’s financial transaction id, once successful.
failure_reasonstringWhy it failed, in plain words. Only when status is failed. See Errors.
payer_phonestringThe number that paid. Collections only.
payee_phonestringThe number that received the money. Payouts and refunds only.
party_namestringThe wallet owner’s name, when RazPay looked it up (payouts, and refunds of those payments).
descriptionstringThe description you sent.
refund_ofstringFor a refund, the external_reference of the collection it returns.
metadataobjectrequiredYour own data, stored and returned exactly as sent. RazPay never reads it.
created_atintegerrequiredUnix time (seconds) it was created.
updated_atintegerrequiredUnix time (seconds) of its last change.
