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.
Why reconcile
Section titled “Why reconcile”- 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.
Search before recreating
Section titled “Search before recreating”- Generate an
ext_idunique per payment (for examplepayout-42) and save it before the call, with acreatingstatus. - Call the API. If the response arrives, save the
reference. A400or403refusal means nothing was created: fix the request. - After a timeout, a network failure or a
5xxerror, don’t resend right away. Wait 30 seconds (charge) to a minute (transfer), then list with?ext_id=. - Decide based on the result.
- If the object exists and is not
failed(for examplepending,in_transitorsuccess), 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 newext_id(for examplepayout-42-2), after checking that no other object for this payment is in progress or successful.
- If the object exists and is not
If the search itself fails, send nothing and retry the search later.
curl "https://api.senfenico.com/v1/payment/transfers/?ext_id=payout-42" \ -H "X-API-KEY: $SENFENICO_SECRET_KEY"// with senfenico() from the PHP guide$q = http_build_query(['ext_id' => 'payout-42']);$found = senfenico('GET', "/transfers/?$q")['data'];if ($found) { $transfer = $found[0]; // already created: don't resend}# with call() from the Django guidefound = call("GET", "/transfers/", params={"ext_id": "payout-42"})["data"]if found: transfer = found[0] # already created: don't resend// with senfenico() from the Node.js guideconst q = new URLSearchParams({ ext_id: 'payout-42' });const { data: found } = await senfenico('GET', `/transfers/?${q}`);if (found.length) { const transfer = found[0]; // already created: don't resend}{ "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.
Create a charge without duplicates
Section titled “Create a charge without duplicates”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 guidefunction 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}# with call() and SenfenicoError from the Django guideimport time
def create_charge_safely(payload: dict): try: return call("POST", "/charges/", json=payload)["data"] except SenfenicoError as exc: if exc.http and exc.http < 500: raise # refused: don't resend time.sleep(30) # outcome unknown found = call("GET", "/charges/", params={"ext_id": payload["ext_id"]})["data"] return found[0] if found else None # None: nothing created// with senfenico() and SenfenicoError from the Node.js guideexport async function createChargeSafely(payload) { try { return (await senfenico('POST', '/charges/', payload)).data; } catch (err) { const known = err instanceof SenfenicoError && err.http && err.http < 500; if (known) throw err; // refused: don't resend } await new Promise((r) => setTimeout(r, 30_000)); // unknown const q = new URLSearchParams({ ext_id: payload.ext_id }); const { data } = await senfenico('GET', `/charges/?${q}`); return data[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).
Other requests with no response
Section titled “Other requests with no response”- With no response to
POST /charges/submit, re-readGET /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.
List filters
Section titled “List filters”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 |
referenceis a partial match. For one specific object, useGET /charges/{reference}/orGET /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).
Find the order behind a checkout charge
Section titled “Find the order behind a checkout charge”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:
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.
Polling
Section titled “Polling”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,failedandcanceledfor a charge,successandfailedfor a transfer,successfor a checkout.in_transitis not final. - A
failedcharge can still move tosuccess(a late operator confirmation, or an OTP submitted anyway on thefailedcharge, which the API still accepts but you should not do: create a new charge instead). Always letsuccesswin, even after acharge.failed. - Senfenico doesn’t publish an expiry delay for
pay_offlinecharges, which depends on the operator.
Nightly reconciliation
Section titled “Nightly reconciliation”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']);# reconcile_nightly.py (with call() from the Django guide)from datetime import datetime, timedelta, timezone
day = (datetime.now(timezone.utc) - timedelta(days=1)).date()page = 1while True: res = call("GET", "/charges/", params={ "status": "success", "date_from": day.isoformat(), "date_to": day.isoformat(), "order_by": "created_at", "page": page, }) for charge in res["data"]: check_charge(charge) # your comparison if not res["pagination"]["has_next"]: break page += 1// reconcile-nightly.js (with senfenico() from the Node.js guide)const day = new Date(Date.now() - 86_400_000) .toISOString().slice(0, 10); // YYYY-MM-DD in UTC
for (let page = 1; ; page++) { const q = new URLSearchParams({ status: 'success', date_from: day, date_to: day, order_by: 'created_at', page: String(page), }); const res = await senfenico('GET', `/charges/?${q}`); for (const charge of res.data) await checkCharge(charge); if (!res.pagination.has_next) break;}What check_charge should verify:
- For a
successcharge unknown to you, find the order byext_id(direct charge) or byGET /checkouts/?charge_reference=(checkout), then confirm it. - If the amount differs from the order’s, raise an alert and don’t fulfill the order.
- Several
successcharges for one order signal a double payment. Refund the extra charge (see refunds). - The other way round, investigate
paidorders without asuccesscharge that day.
Do the same for transfers (GET /transfers/?date_from=…&date_to=…), checking that each internal payout has exactly one transfer.
Reconcile a bulk transfer
Section titled “Reconcile a bulk 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:
- Before sending, save each line with its
ext_idand statussubmitted. - Mark lines listed in
failed_transfersasrejected(matched byext_id). Fix them, then resend only those in a new batch. - For the others, fetch the reference with
GET /transfers/?ext_id=…per line, or with a date-filtered paginated list that you match byext_id. - Then track each transfer until
successorfailed(transfer.*webhooks or polling). - 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.
Checklist
Section titled “Checklist”- Every charge and transfer carries an
ext_idsaved before the call. - After a timeout or a
5xx, you search byext_idbefore any new create. - Each checkout’s reference is stored on the order.
- A scheduled task re-checks pending operations, and
in_transitisn’t treated as final. -
successalways wins over an earlierfailed. - 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.