Payment lifecycle: statuses and webhooks
A Senfenico payment is always a charge, that is, the debit of the customer’s mobile money account. If you use the hosted page, a checkout groups one or more charges, one per customer attempt.
Charge statuses
Section titled “Charge statuses”send_otpWaiting for the OTPpay_offlineWaiting for the phonesuccessPaidfailedFailed
A charge is created in a waiting state that depends on the operator, then moves to success or failed.
| Status | Meaning | Webhook | Final | What to do |
|---|---|---|---|---|
send_otp |
The charge waits for an OTP. Orange, Coris, Sank, and Moov in OTP mode. | charge.send_otp |
No | Ask the customer for the OTP, then call POST /charges/submit. |
pay_offline |
The customer must approve on their phone. Moov in USSD mode, MTN Mobile Money and Moov Money in Benin. | charge.pay_offline |
No | Show display_text and wait for charge.success. Set your own timeout. |
success |
The operator confirmed the debit. | charge.success |
Yes | Check the amount, then fulfill the order. |
failed |
The operator rejected it, for example because of an OTP rejected at Orange in live mode, an insufficient balance or an invalid number. | charge.failed |
Treat as final | Don’t fulfill the order. Offer to pay again with a new charge. |
pending |
Reserved. No charge gets this status today. | charge.pending |
— | Treat as waiting. |
canceled |
Reserved. The API does not cancel charges automatically today. | charge.canceled |
Yes | Don’t fulfill the order. |
The charge.send_otp or charge.pay_offline webhook is sent as soon as the charge is created. It only confirms that the request is in progress.
If a response contains a status value you don’t know (for example waiting_webpayment, used for an operator outside Burkina and Benin), treat it as waiting and don’t fulfill the order.
A wait may never end
Section titled “A wait may never end”There is no automatic expiry. A send_otp charge whose OTP never arrives stays send_otp. A pay_offline charge that the customer ignores or declines can stay pay_offline without ever receiving charge.failed.
So decide yourself when an order is abandoned (for example after 15 minutes without success), and release the stock or cart at that point. Before offering a new charge, re-read the status of the old one to avoid a double debit.
Checkout statuses
Section titled “Checkout statuses”pendingCreatedsuccessPaid on the pagefailedPhone approval failed
| Status | Meaning | Webhook | What to do |
|---|---|---|---|
pending |
Checkout created, no payment confirmed on the page. A checkout often stays pending after a failed attempt. |
checkout.pending, sent at creation |
Wait. If the order stays pending, check the linked charge (charge_reference). |
success |
The payment was confirmed on the page. | checkout.success |
Check the amount and live_mode, then fulfill the order. |
failed |
The page saw a phone approval fail. | checkout.failed |
Wait. The customer can retry on the same page, and the checkout can then become success. |
A checkout status is updated by the payment page itself. If the customer closes the page before the end, the charge can be success while the checkout is still pending, and checkout.success is not sent. Also subscribe to charge.success (see Confirm the payment server-side).
Which webhooks, in which order
Section titled “Which webhooks, in which order”Here are sample sequences your server receives. Each event carries the full object in data (a JSON string to decode, see Webhooks).
| Scenario | Events received |
|---|---|
| Successful Orange Money charge | charge.send_otp → charge.success |
| Orange Money charge, OTP rejected in live mode | charge.send_otp → charge.failed |
| Successful Moov Money charge in USSD mode | charge.pay_offline → charge.success |
| Successful Benin charge (MTN or Moov) | charge.pay_offline → charge.success |
| Checkout paid with Orange on the first try | checkout.pending → charge.send_otp → charge.success → checkout.success |
| Checkout: one failure, then a success | checkout.pending → charge.send_otp → charge.failed → charge.send_otp (new charge) → charge.success → checkout.success |
You only receive the events you subscribed to in the dashboard. For most shops, charge.success, charge.failed and checkout.success are enough.
Arrival order is not guaranteed, because of retries and the network. Rely on the object’s status, not on the order of events.
Confirm a payment server-side
Section titled “Confirm a payment server-side”Only fulfill an order after reading status: "success" from the Senfenico API, with your secret key, from your server. The customer landing on success_url, a message from your mobile app or a screenshot of the SMS prove nothing.
- Find the order using the reference you stored (charge
reference, checkoutreferenceor yourext_id). - Read the object from the API with
GET /v1/payment/charges/{reference}/orGET /v1/payment/checkouts/{reference}/. - Check the object.
statusmust besuccess,amountmust match the order,live_modemust match your environment and the reference must be the order’s. - Fulfill only once. Mark the order paid inside a transaction, and ignore later confirmations (duplicate webhooks, retries).
curl https://api.senfenico.com/v1/payment/charges/CH261126-101431-ORANGE_BF-1a2b3c4d5e/ \ -H "X-API-KEY: $SENFENICO_KEY"# fulfill only if data.status == "success"# and data.amount == the order amount<?phpfunction chargeIsPaid(string $ref, int $amount, bool $live): bool{ $ch = curl_init( "https://api.senfenico.com/v1/payment/charges/{$ref}/"); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => [ 'X-API-KEY: ' . getenv('SENFENICO_KEY')], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, ]); $raw = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code !== 200) return false;
$c = json_decode($raw, true)['data']; return $c['status'] === 'success' && $c['amount'] === $amount && $c['live_mode'] === $live;}import osimport requests
def charge_is_paid(ref: str, amount: int, live: bool) -> bool: r = requests.get( f"https://api.senfenico.com/v1/payment/charges/{ref}/", headers={"X-API-KEY": os.environ["SENFENICO_KEY"]}, timeout=30, ) if r.status_code != 200: return False c = r.json()["data"] return (c["status"] == "success" and c["amount"] == amount and c["live_mode"] == live)async function chargeIsPaid(ref, amount, live) { const r = await fetch( `https://api.senfenico.com/v1/payment/charges/${ref}/`, { headers: { 'X-API-KEY': process.env.SENFENICO_KEY } }, ); if (r.status !== 200) return false; const { data: c } = await r.json(); return c.status === 'success' && c.amount === amount && c.live_mode === live;}For a checkout, the full check (checkout, then linked charge) is in Confirm a checkout payment.
Webhooks and API: use both
Section titled “Webhooks and API: use both”A webhook is fast, but it can arrive twice, late, or not at all if your server is down for more than an hour. Verify its signature. The API is always up to date, but you have to call it.
What to show the customer
Section titled “What to show the customer”Suggested messages for each error are in Error codes. While a charge is send_otp or pay_offline, show display_text.