Skip to content

Reconciliation and duplicates: ext_id, lists, retries

Your database must always agree with Senfenico. A paid order has a success charge, and a courier is paid only once, even when a request times out or a webhook is lost.

  • Webhooks are retried 10 times over about an hour, then dropped. A longer outage on your side means missed events.
  • A request can time out on the client while Senfenico processed it.
  • A checkout’s status is only updated if the customer stays on the payment page. Its charge can therefore succeed while the checkout stays pending.

ext_id: useful, but neither unique nor idempotent

Section titled “ext_id: useful, but neither unique nor idempotent”

ext_id is your reference (up to 200 characters), accepted when creating charges and transfers. It is returned in responses and webhooks, and works as a list filter (?ext_id=, exact match).

What ext_id does What ext_id doesn’t do
Find your objects with GET …/?ext_id=… Prevent duplicates, since two requests with the same ext_id create two objects
Link a charge or transfer to your order Replay the response of an earlier request (no idempotency)

Checkout doesn’t accept ext_id. Store its reference on your order as soon as initialization responds.

  1. Generate an ext_id unique per payment (for example payout-42) and save it before the call, with a creating status.
  2. Call the API. If the response arrives, save the reference. A 400 or 403 refusal means nothing was created: fix the request.
  3. After a timeout, a network failure or a 5xx error, don’t resend right away. Wait 30 seconds (charge) to a minute (transfer), then list with ?ext_id=.
  4. Decide based on the result.
    • If the object exists and is not failed (for example pending, in_transit or success), continue with it without resending the request.
    • If the list is empty, the request was lost. Check a second time a few seconds later, then resend it with the same ext_id.
    • If the object is failed, its amount has been returned. Create a new object with a new ext_id (for example payout-42-2), after checking that no other object for this payment is in progress or successful.

If the search itself fails, send nothing and retry the search later.

Fenêtre de terminal
curl "https://api.senfenico.com/v1/payment/transfers/?ext_id=payout-42" \
-H "X-API-KEY: $SENFENICO_SECRET_KEY"
{
"status": true,
"message": "Transfer list retrieved",
"data": [
{
"reference": "TR261126-180002-ORANGE_BF-5d6e7f8a9b",
"amount": 2500,
"fees": "1.500",
"currency": "XOF",
"ip_address": "203.0.113.10",
"status": "success",
"live_mode": false,
"recipient_wallet": "orange_bf",
"recipient_phone": "76000000",
"ext_id": "payout-42",
"created_at": "2026-11-26T18:00:02.418210Z"
}
],
"pagination": {
"count": 1,
"total_pages": 1,
"current_page": 1,
"page_size": 10,
"has_next": false,
"has_previous": false
}
}

On charges and transfers, fees is your fee rate in percent ("1.500" = 1.5%), not an amount.

If the list holds several objects for one ext_id, a duplicate already happened. Alert your team.

Creating a charge calls the operator and can take several tens of seconds. When your request times out, an OTP or approval request may already be on the customer’s phone. The function below applies the procedure. A refusal (4xx) is raised as is, and an unknown outcome triggers a search by ext_id after 30 seconds.

// with senfenico() and SenfenicoError from the PHP guide
function create_charge_safely(array $payload): ?array
{
try {
return senfenico('POST', '/charges/', $payload)['data'];
} catch (SenfenicoError $e) {
if ($e->http !== 0 && $e->http < 500) {
throw $e; // refused: don't resend
}
}
sleep(30); // outcome unknown
$q = http_build_query(['ext_id' => $payload['ext_id']]);
$found = senfenico('GET', "/charges/?$q")['data'];
return $found[0] ?? null; // null: nothing created
}

If the charge is found and is not failed, its status tells you what to show. It has no display_text, which is only returned on creation: show your own instruction based on provider and status (see Mobile app).

  • With no response to POST /charges/submit, re-read GET /charges/{reference}/ before asking for another OTP.
  • With no response to POST /checkouts/initialize/, you can create another checkout, since an unpaid checkout costs nothing. Keep only the latest reference on the order.
  • Reads (GET) can always be retried, with a growing delay of 1 s, 2 s, then 4 s.

Lists return 10 items per page (50 for refunds, with ?page=2 for the next one) and a pagination object. An invalid filter (malformed date, unknown status) returns HTTP 400, error_code: "INVALID_DATA" and details in errors.

Filter Charges GET /charges/ Transfers GET /transfers/ Checkouts GET /checkouts/
ext_id (exact) yes yes no
reference (contains) yes yes yes
status pending, send_otp, pay_offline, success, failed, canceled pending, in_transit, success, failed pending, success, failed
date_from, date_to (YYYY-MM-DD, inclusive, UTC) yes yes yes
amount_min, amount_max yes yes yes
provider / recipient_wallet provider recipient_wallet provider
phone / recipient_phone phone recipient_phone phone
others operator_trans_id operator_trans_id charge_reference, email
order_by created_at, -created_at (default), amount, -amount, status, -status same same
  • reference is a partial match. For one specific object, use GET /charges/{reference}/ or GET /transfers/{reference}/ instead.
  • Dates are compared on the UTC creation date. Burkina Faso is on UTC and Benin on UTC+1, so a charge made in Benin at 00:30 counts for the previous day.
  • Lists only show objects in your key’s mode (test or live).

A charge created by the payment page has no ext_id. To find the checkout, and therefore your order, from a charge reference (for example in a charge.success webhook), filter by charge_reference:

Fenêtre de terminal
curl "https://api.senfenico.com/v1/payment/checkouts/?charge_reference=CH261126-101502-ORANGE_BF-8b41079ee8" \
-H "X-API-KEY: $SENFENICO_SECRET_KEY"

The other way round, GET /checkouts/{reference}/ returns charge_reference. If the customer switches operator on the page, a new charge is created and charge_reference only keeps the last one. An earlier charge that succeeds anyway, for example an abandoned pay_offline, then escapes the charge_reference search. Your nightly reconciliation will see it as a success charge with no order. Review it by hand, using its phone, amount and time.

Webhooks remain the primary source. Polling the API only catches what’s missing:

Situation When to poll Call
Customer back on success_url immediately, once GET /checkouts/{ref}/ then GET /charges/{charge_reference}/
pay_offline charge, app open every 3 to 5 s for 3 min, through your backend GET /charges/{ref}/ if no webhook after 15 s
Order pending for over 10 min every 15 min for 48 h (scheduled task) same confirmation as on return
Transfer pending or in_transit every 30 min GET /transfers/{ref}/
  • Final statuses are success, failed and canceled for a charge, success and failed for a transfer, success for a checkout. in_transit is not final.
  • A failed charge can still move to success (a late operator confirmation, or an OTP submitted anyway on the failed charge, which the API still accepts but you should not do: create a new charge instead). Always let success win, even after a charge.failed.
  • Senfenico doesn’t publish an expiry delay for pay_offline charges, which depends on the operator.

Every night, walk through all of yesterday’s success charges and compare them with your database. On a closed day, order_by=created_at (ascending) gives stable pagination.

// reconcile-nightly.php (with senfenico() from the PHP guide)
$day = (new DateTimeImmutable('yesterday', new DateTimeZone('UTC')))
->format('Y-m-d');
$page = 1;
do {
$q = http_build_query([
'status' => 'success', 'date_from' => $day,
'date_to' => $day, 'order_by' => 'created_at',
'page' => $page,
]);
$res = senfenico('GET', "/charges/?$q");
foreach ($res['data'] as $charge) {
check_charge($charge); // your comparison
}
$page++;
} while ($res['pagination']['has_next']);

What check_charge should verify:

  1. For a success charge unknown to you, find the order by ext_id (direct charge) or by GET /checkouts/?charge_reference= (checkout), then confirm it.
  2. If the amount differs from the order’s, raise an alert and don’t fulfill the order.
  3. Several success charges for one order signal a double payment. Refund the extra charge (see refunds).
  4. The other way round, investigate paid orders without a success charge that day.

Do the same for transfers (GET /transfers/?date_from=…&date_to=…), checking that each internal payout has exactly one transfer.

POST /v1/payment/transfers/bulk/ accepts up to 100 transfers and answers HTTP 202. The response gives the number of transfers queued and the rejected items, but not the references of the transfers created:

{
"status": true,
"message": "2 transfers queued for processing",
"failed_transfers": [
{
"data": {
"amount": 1500,
"recipient_phone": "7600",
"ext_id": "payroll-2026-11-courier-17"
},
"errors": {
"recipient_phone": ["Burkina Faso phone numbers must be 8 digits long."]
}
}
]
}

Procedure:

  1. Before sending, save each line with its ext_id and status submitted.
  2. Mark lines listed in failed_transfers as rejected (matched by ext_id). Fix them, then resend only those in a new batch.
  3. For the others, fetch the reference with GET /transfers/?ext_id=… per line, or with a date-filtered paginated list that you match by ext_id.
  4. Then track each transfer until success or failed (transfer.* webhooks or polling).
  5. If the bulk request times out, some transfers may have been created. Don’t resend the whole batch. Search each ext_id, then resend only the lines not found.

More details in Bulk transfers.

  • Every charge and transfer carries an ext_id saved before the call.
  • After a timeout or a 5xx, you search by ext_id before any new create.
  • Each checkout’s reference is stored on the order.
  • A scheduled task re-checks pending operations, and in_transit isn’t treated as final.
  • success always wins over an earlier failed.
  • The nightly reconciliation walks every page, ascending, over a closed UTC day.
  • Each bulk transfer item has a unique ext_id, and a timed-out batch is never resent whole.