IDEMPOTENCY Zero double charges
Replay a call as often as needed with the same key: the customer is only charged once.
// API XoniPay v1
A REST API for Orange Money and MTN MoMo, test keys, clear code samples and webhooks that actually arrive. Every call is idempotent: a double click never charges twice.
# Request an Orange Money paymentcurl https://api.xonipay.com/v1/payments \ -H "Authorization: Bearer sk_test_••••" \ -H "Idempotency-Key: cmd-48213" \ -d amount=12500 \ -d currency=XAF \ -d operator=orange_money \ -d phone=+23769000041 \ -d callback_url=https://boutique.cm/webhook
// npm install @xonipay/nodeimport XoniPay from "@xonipay/node";const xp = new XoniPay(process.env.XONIPAY_KEY); const paiement = await xp.payments.create({ amount: 12500, currency: "XAF", operator: "auto", // smart routing phone: "+23769000041",}, { idempotencyKey: "cmd-48213" });
// composer require xonipay/xonipay-php$xp = new \XoniPay\Client(getenv("XONIPAY_KEY")); $paiement = $xp->payments->create([ "amount" => 12500, "currency" => "XAF", "operator" => "mtn_momo", "phone" => "+23767000041",], ["idempotency_key" => "cmd-48213"]);
# pip install xonipayimport os, xonipayxp = xonipay.Client(os.environ["XONIPAY_KEY"]) paiement = xp.payments.create( amount=12500, currency="XAF", operator="auto", phone="+23769000041", idempotency_key="cmd-48213")
201 Created · sample responseIdempotency-Key required
The details that spare you unhappy customer calls at 10 p.m.
IDEMPOTENCY Replay a call as often as needed with the same key: the customer is only charged once.
RETRY If the confirmation prompt does not arrive, XoniPay sends it again, then switches to another channel.
SANDBOX Simulate success, refusal, timeout and insufficient balance with test numbers.
STATUS Success rates and incidents published by operator, with email alerts on subscription.
Webhooks
Each event is signed (HMAC-SHA256), timestamped and resent with increasing delays until your server responds 2xx. You can also replay it by hand from the dashboard.
Event logSample
200 payment.succeeded 200 payout.paid 503 payment.succeeded 200 payment.pending 200 refund.created Your test keys are available right away, with no need to wait for verification.
sk_test_•••• Create a test payment with a sandbox number.
POST /v1/payments Enter the URL that will receive status changes.
payment.succeeded Once your KYC file is approved, replace the test key.
sk_live_•••• Statuses
created Your server has requested the payment.
pending The customer has received the USSD request on their phone.
succeeded The operator has confirmed. The funds move on to payout.
failed Insufficient balance or code refused. Never billed.
expired No response from the customer within the time limit.
A webhook is sent on every status change. A "pending" payment is rechecked automatically until it is resolved.
Test numbers
With an sk_test_ key, each number simulates a scenario.
| Number | Simulated result |
|---|---|
| +237 690 000 001 | Succeeded |
| +237 690 000 002 | Insufficient balance |
| +237 690 000 003 | Secret code refused |
| +237 670 000 004 | Late confirmation (3 min) |
| +237 670 000 005 | Expired, no response |
Verify a webhook signature
// Node.jsconst received = Buffer.from(req.headers["xonipay-signature"] ?? "");const expected = Buffer.from(crypto .createHmac("sha256", process.env.WEBHOOK_SECRET) .update(req.rawBody).digest("hex"));if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) { return res.sendStatus(401);}res.sendStatus(200); // XoniPay stops replaying