Refunds: give back a mobile money payment
A refund gives your customer back all or part of a successful charge, for example after a canceled order, an item out of stock or a duplicate payment. You create the request through the API, then Senfenico processes it.
How a refund is processed
Section titled “How a refund is processed”- You create the refund. It is recorded as
pending, and the amount is immediately removed from your deposit balance (available) and shown inpending(see Balances). - The Senfenico team processes the request and moves the refund to
successorfailed. - You receive the
refund.successorrefund.failedwebhook. If it fails, the amount goes back toavailable.
The refund is taken from the deposit balance of the operator that collected the charge (Burkina, Moov Benin or MTN Benin). The collection fee of the original charge is not returned, so refunding 10,000 XOF costs your balance 10,000 XOF.
Create a refund
Section titled “Create a refund”/v1/payment/refunds/| Parameter | Type | Required | Description |
|---|---|---|---|
charge |
string | yes | reference of the charge to refund. It must be success, belong to you and have been created in the same mode (test or live) as the key used. |
amount |
integer | yes | Amount to give back, in XOF, greater than 0. May be lower than the charge amount (partial refund). |
reason |
string | no | requested_by_customer, fraudulent or abandoned. |
note |
string | no | Free text explaining the context (visible to the team processing the request). |
ext_id |
string | no | Your own reference (max 200 characters), for example the support ticket number. Not unique. |
curl https://api.senfenico.com/v1/payment/refunds/ \ -H "X-API-KEY: sk_test_..." \ -H "Content-Type: application/json" \ -d '{ "charge": "CH261126-101512-ORANGE_BF-7c41e9a0b2", "amount": 1000, "reason": "requested_by_customer", "note": "Order 5531 canceled by the customer", "ext_id": "support-5531" }'$client = new \GuzzleHttp\Client([ 'base_uri' => 'https://api.senfenico.com/v1/payment/', 'headers' => ['X-API-KEY' => getenv('SENFENICO_KEY')], 'http_errors' => false,]);
$res = $client->post('refunds/', ['json' => [ 'charge' => 'CH261126-101512-ORANGE_BF-7c41e9a0b2', 'amount' => 1000, 'reason' => 'requested_by_customer', 'note' => 'Order 5531 canceled by the customer', 'ext_id' => 'support-5531',]]);$body = json_decode($res->getBody(), true);
if ($res->getStatusCode() === 201 && $body['status']) { $reference = $body['data']['reference'];}import osimport requests
res = requests.post( "https://api.senfenico.com/v1/payment/refunds/", headers={"X-API-KEY": os.environ["SENFENICO_KEY"]}, json={ "charge": "CH261126-101512-ORANGE_BF-7c41e9a0b2", "amount": 1000, "reason": "requested_by_customer", "note": "Order 5531 canceled by the customer", "ext_id": "support-5531", }, timeout=30,)body = res.json()
if res.status_code == 201 and body["status"]: reference = body["data"]["reference"]const res = await fetch( 'https://api.senfenico.com/v1/payment/refunds/', { method: 'POST', headers: { 'X-API-KEY': process.env.SENFENICO_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ charge: 'CH261126-101512-ORANGE_BF-7c41e9a0b2', amount: 1000, reason: 'requested_by_customer', note: 'Order 5531 canceled by the customer', ext_id: 'support-5531', }), },);const body = await res.json();
if (res.status === 201 && body.status) { const { reference } = body.data;}A 201 response means the request is recorded but not yet executed.
{ "status": true, "message": "Refund attempted", "data": { "reference": "re_8d2f6a1c0b9e4d7fa3c5e1b2d4f6a8c0", "charge": "CH261126-101512-ORANGE_BF-7c41e9a0b2", "amount": 1000, "reason": "requested_by_customer", "status": "pending", "live_mode": false, "note": "Order 5531 canceled by the customer", "ext_id": "support-5531", "created_at": "2026-11-26T11:40:09.512330Z" }}Refund a checkout
Section titled “Refund a checkout”A checkout payment creates a charge, and that charge is what you refund. The charge field doesn’t accept the checkout reference (CHK…).
- Read the checkout with
GET /v1/payment/checkouts/{reference}/and take itscharge_reference. - Create the refund with that value in
charge.
curl https://api.senfenico.com/v1/payment/checkouts/CHK261126-101431--3f9a0c1d2e/ \ -H "X-API-KEY: sk_test_..."
# then, with data.charge_reference:curl https://api.senfenico.com/v1/payment/refunds/ \ -H "X-API-KEY: sk_test_..." \ -H "Content-Type: application/json" \ -d '{ "charge": "CH261126-101502-ORANGE_BF-8b41079ee8", "amount": 1000, "reason": "requested_by_customer", "ext_id": "support-5531" }'$chk = 'CHK261126-101431--3f9a0c1d2e';$res = $client->get("checkouts/{$chk}/");$checkout = json_decode($res->getBody(), true)['data'];
$res = $client->post('refunds/', ['json' => [ 'charge' => $checkout['charge_reference'], 'amount' => $checkout['amount'], // or less 'reason' => 'requested_by_customer', 'ext_id' => 'support-5531',]]);$body = json_decode($res->getBody(), true);
if ($res->getStatusCode() === 201 && $body['status'] === true) { $reference = $body['data']['reference']; // re_…}BASE = "https://api.senfenico.com/v1/payment/"HEADERS = {"X-API-KEY": os.environ["SENFENICO_KEY"]}chk = "CHK261126-101431--3f9a0c1d2e"
checkout = requests.get( f"{BASE}checkouts/{chk}/", headers=HEADERS, timeout=30).json()["data"]
res = requests.post( f"{BASE}refunds/", headers=HEADERS, json={ "charge": checkout["charge_reference"], "amount": checkout["amount"], # or less "reason": "requested_by_customer", "ext_id": "support-5531", }, timeout=30,)body = res.json()if res.status_code == 201 and body["status"] is True: reference = body["data"]["reference"] # re_…const BASE = 'https://api.senfenico.com/v1/payment/';const headers = { 'X-API-KEY': process.env.SENFENICO_KEY, 'Content-Type': 'application/json',};const chk = 'CHK261126-101431--3f9a0c1d2e';
const { data: checkout } = await ( await fetch(`${BASE}checkouts/${chk}/`, { headers })).json();
const res = await fetch(`${BASE}refunds/`, { method: 'POST', headers, body: JSON.stringify({ charge: checkout.charge_reference, amount: checkout.amount, // or less reason: 'requested_by_customer', ext_id: 'support-5531', }),});const body = await res.json();if (res.status === 201 && body.status === true) { const { reference } = body.data; // re_…}Response from GET /v1/payment/checkouts/{reference}/ (excerpt):
{ "status": true, "message": "Checkout details retrieved", "data": { "reference": "CHK261126-101431--3f9a0c1d2e", "charge_reference": "CH261126-101502-ORANGE_BF-8b41079ee8", "amount": 1000, "phone": "76000000", "provider": "orange_bf", "live_mode": false, "status": "success" }}The refund responds as shown in Create a refund, with a 201 and the status pending.
charge_referenceisnullif no payment was attempted, and points to the last attempt made on the page. If that charge isn’tsuccess, the refund is rejected (Only successful charges can be refunded.).- The API takes no destination number. The refund is tied to the charge, which carries the customer’s number (
phone) and operator (provider). Senfenico copies that operator into the refund’smmofield (visible in the webhook) and debits the matching deposit balance. The Senfenico team then pays the customer back by hand. If the customer has changed numbers, write tocontact@senfenico.combefore creating the refund.
Refund fields
Section titled “Refund fields”| Field | Type | Description |
|---|---|---|
reference |
string | Refund ID, re_ prefix. |
charge |
string | Reference of the refunded charge. |
amount |
integer | Amount given back, in XOF. |
reason |
string or null |
requested_by_customer, fraudulent or abandoned. |
status |
string | pending, success or failed. |
live_mode |
boolean | Mode of the key used. |
note |
string or null |
Your note. |
ext_id |
string or null |
Your reference. |
created_at |
ISO 8601 date (UTC) | Creation date. |
Partial refunds
Section titled “Partial refunds”You can refund the same charge in several steps. The total of a charge’s pending and success refunds cannot exceed its amount. failed refunds do not count.
For a 5,000 XOF charge, a first refund of 2,000 and then a second of 3,000 are accepted. A third one, even of 100, is refused:
{ "status": false, "message": "Invalid data provided. Please check the input and try again.", "error_code": "INVALID_DATA", "errors": { "amount": ["Refund amount exceeds the remaining charge balance."] }}The charge’s amount_refunded field only counts success refunds. It therefore only goes up once the refund has been processed.
Refund lifecycle
Section titled “Refund lifecycle”pendingamount reserved, waitingsuccesscustomer refundedfailedamount returned
| Status | Meaning | Webhook |
|---|---|---|
pending |
Request recorded, amount reserved on your deposit balance. | refund.pending |
success |
The customer has been refunded. Final status. | refund.success |
failed |
The refund could not be made. The amount goes back to your balance. | refund.failed |
See Webhooks to subscribe and verify the signature.
In the data of a refund.* webhook, the format differs from the API’s. charge is the charge’s internal numeric id (for example 48213) rather than its reference, and an mmo field (the charge’s operator) is added. Match the event on reference, the re_… reference returned at creation, or on your ext_id.
Retrieve a refund
Section titled “Retrieve a refund”/v1/payment/refunds/{reference}/curl https://api.senfenico.com/v1/payment/refunds/re_8d2f6a1c0b9e4d7fa3c5e1b2d4f6a8c0/ \ -H "X-API-KEY: sk_test_..."$ref = 're_8d2f6a1c0b9e4d7fa3c5e1b2d4f6a8c0';$res = $client->get("refunds/{$ref}/");$body = json_decode($res->getBody(), true);echo $body['data']['status'];ref = "re_8d2f6a1c0b9e4d7fa3c5e1b2d4f6a8c0"res = requests.get( f"https://api.senfenico.com/v1/payment/refunds/{ref}/", headers={"X-API-KEY": os.environ["SENFENICO_KEY"]}, timeout=30,)print(res.json()["data"]["status"])const ref = 're_8d2f6a1c0b9e4d7fa3c5e1b2d4f6a8c0';const res = await fetch( `https://api.senfenico.com/v1/payment/refunds/${ref}/`, { headers: { 'X-API-KEY': process.env.SENFENICO_KEY } },);const { data } = await res.json();console.log(data.status);An unknown reference, or one from the other mode, returns 404 with error_code: "TRANSACTION_NOT_FOUND".
List refunds
Section titled “List refunds”/v1/payment/refunds/50 refunds per page (not 10 like the other lists), newest first by default. The response contains data and pagination (count, total_pages, current_page, page_size, has_next, has_previous).
| Parameter | Description |
|---|---|
page |
Page number. A page past the end returns the last one, so stop when has_next is false. |
charge_reference |
Refunds of a specific charge (exact match). |
refund_reference |
Refund reference containing this text. |
ext_id |
Exact match on your reference. |
status |
pending, success or failed. |
reason |
requested_by_customer, fraudulent or abandoned. |
date_from, date_to |
YYYY-MM-DD dates (UTC), inclusive. |
amount_min, amount_max |
Amount bounds, inclusive. |
order_by |
created_at, -created_at, amount, -amount, status, -status. |
curl "https://api.senfenico.com/v1/payment/refunds/?charge_reference=CH261126-101512-ORANGE_BF-7c41e9a0b2" \ -H "X-API-KEY: sk_test_..."Errors
Section titled “Errors”Refusals return 400, error_code: "INVALID_DATA" and details in errors:
Field in errors |
Message | Cause |
|---|---|---|
charge |
The charge with the provided reference does not exist. |
Unknown reference. |
charge |
This charge does not belong to you. |
The charge belongs to another account. |
charge |
This charge is in the wrong mode. |
Test charge refunded with a live key, or the reverse. |
charge |
Only successful charges can be refunded. |
The charge is not success. |
amount |
This field is required. |
amount missing or equal to 0. |
amount |
Refund amount exceeds the remaining charge balance. |
Exceeds the remaining amount. |
reason |
"…" is not a valid choice. |
Reason not in the list. |
See also Error codes.
First create a successful test charge with an sk_test_ key, for example with these values:
Then refund it with the same key. The test refund is recorded as pending and stays there, which is enough to check your integration (response, refund.pending webhook received, test balance reduced).
The move to success or failed depends on manual processing by the Senfenico team. No API call triggers it, and you can’t get refund.success or refund.failed on demand in test mode. Test those handlers with simulated responses.