Create a refund
The call that returns funds on a succeeded payment, its parameters and its answer.
The payment is named by its Wajub id. Your own reference on the payment is not accepted here.
https://api.wajub.com/refundspaymentstringrequiredid, such as trx_test_CSUGajfv9xh0XQ5wu2lx. Your merchant reference is not accepted.reasonenumrequiredamountnumberoptionalcurrencystringoptionalfees_bearerenumoptionalmerchant or customer: who bears the payment's Wajub fee for the refunded share. Defaults to your refund settings, else to whoever paid the fee at payment time. See below.referencestringoptionalmetadataobjectoptionaldispute_settlement marks the refund Wajub creates when you accept a dispute, and is dropped if you send it.reason is required and closed. Sending anything outside this list is a 422, so pick the closest
match rather than inventing one.
| Reason | Use it when |
|---|---|
requested_by_customer | The customer asked, and you agreed |
duplicate | The same order was paid twice |
fraudulent | You believe the payment was not made by the cardholder or account owner |
product_not_received | Goods never arrived |
service_not_delivered | A service was paid for and not rendered |
wrong_amount | You charged more than you should have |
customer_complaint | A complaint you settled without assigning fault |
merchant_error | Your own mistake: wrong item, wrong price, wrong customer |
network_error | The payment went through on your side but not on theirs |
transaction_error | A technical failure in the payment itself |
reconciliation | Cleaning up a discrepancy found while reconciling |
Send the call from your server, with an Idempotency-Key if the refund can be triggered by
anything that retries.
curl https://api.wajub.com/refunds \
-H "Authorization: sk_test.xxxxxxxxxxxxxxxx…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: refund-order-4172" \
-d '{
"payment": "trx_test_CSUGajfv9xh0XQ5wu2lx",
"amount": 2000,
"reason": "product_not_received",
"reference": "rma-881"
}'Wajub answers 201 Created. Nothing has left your balance yet: the refund has been accepted, and
status tells you how far it has got.
The payment is carried in transaction, not payment. Reads also return a tax breakdown where
tax applies, a timeline of the status changes, and failure_reason with failure_message when
the refund failed. A refund that took money from your balance also returns
ledger_balance_currency, ledger_balance_before and ledger_balance_after: your balance just
before the refund and just after it, so the difference is what it took, the payment fee's share
included when it moved with the refund. In sandbox they are your sandbox balance's. The
refund.succeeded payload carries them too. A refund that took nothing, because a lost dispute already had, has none of the three.
Idempotency-Key, and what it keys on
The key never expires: the same key always returns the same refund, never a second one, and
reusing it for another payment or another amount answers 422. A key is spent for good, so derive it from this one refund, an order and a refund number,
not from the order alone: a second refund of the same amount would only hand you back the first.