مرجع الواجهة البرمجية
The Sonco Pay API lets your server create crypto payments, follow them until they are paid, read your balance and withdraw it. Every request and response is JSON over HTTPS.
https://soncopay.example
Endpoints
| Endpoint | Description |
|---|---|
POST/v1/payments | إنشاء دفعة |
GET/v1/payments | سرد المدفوعات |
GET/v1/payments/{id} | استرجاع دفعة |
GET/v1/payments/{id}/methods | طرق الدفع المتاحة لدفعة ما |
POST/v1/payments/{id}/method | اختيار وسيلة الدفع |
POST/v1/payments/{id}/simulate | محاكاة دفعة (وضع الاختبار) |
GET/v1/payments/{id}/timeline | التسلسل الزمني للدفعة |
GET/v1/methods | وسائل الدفع والأصول والشبكات المتاحة |
GET/v1/rates | الأسعار الحالية بالدولار الأمريكي |
GET/v1/balances | الرصيد لكل أصل |
GET/v1/ledger | حركات الرصيد |
GET/v1/statements | كشف الحساب |
GET/v1/statements.csv | كشف الحساب (CSV) |
POST/v1/payouts | إنشاء سحب |
GET/v1/payouts | سرد السحوبات |
GET/v1/payouts/{id} | استرجاع سحب |
GET/v1/payouts/{id}/timeline | التسلسل الزمني للسحب |
GET/v1/payout-fees | رسوم الشبكة والحد الأدنى للسحب |
GET/v1/payout-destinations | عرض وجهات السحب |
POST/v1/payout-destinations | حفظ وجهة سحب |
GET/v1/payout-destinations/{id} | عرض وجهة سحب |
PATCH/v1/payout-destinations/{id} | إعادة تسمية وجهة سحب |
DELETE/v1/payout-destinations/{id} | تعطيل وجهة سحب |
POST/v1/refunds | إنشاء عملية استرداد |
GET/v1/refunds | عرض قائمة عمليات الاسترداد |
GET/v1/refunds/{id} | قراءة عملية استرداد |
POST/v1/refunds/{id}/cancel | إلغاء عملية استرداد |
POST/v1/refunds/preview | معاينة عملية استرداد |
GET/v1/payments/{id}/refund-options | خيارات الاسترداد لدفعة ما |
GET/v1/settlement | وضع التسوية والوجهات |
GET/v1/settlement/items | مدفوعات قيد التسوية |
PUT/v1/settlement/routes | اختيار وجهة التسوية |
GET/v1/fees | رسومك وحدودك |
POST/v1/customers | العملاء، الفواتير، الاشتراكات |
GET/v1/customers | الفواتير والاشتراكات |
POST/v1/invoices | إنشاء فاتورة |
GET/v1/invoices | الفواتير والاشتراكات |
POST/v1/invoices/{id}/send | الفواتير والاشتراكات |
POST/v1/invoices/{id}/remind | الفواتير والاشتراكات |
POST/v1/invoices/{id}/void | الفواتير والاشتراكات |
POST/v1/subscriptions | إنشاء اشتراك |
POST/v1/subscriptions/{id}/pause | الفواتير والاشتراكات |
POST/v1/subscriptions/{id}/cancel | الفواتير والاشتراكات |
GET/v1/billing/summary | ملخص الفوترة وساعة الاختبار |
SDKs
Official libraries for Node.js, PHP and Python call the API for you: authentication with your key, JSON errors turned into exceptions, and webhook signature checks.
Version 2.2.0 adds customers, invoices and subscriptions (customers, plans, invoices, subscriptions and billing resources, invoice.* and subscription.* events). It is backward compatible with 2.0.0, the first release under the Sonco Pay name.
Version 2.3.0 adds fee_paid_by when creating a payment (who pays the service fee) and documents the new fields fee_paid_by, amount_due and fee_quote.
Version 2.12.1 changes no call: it documents the amount the payer really pays. For mobile money, show payer_total or next_action.amount (operator fee included), never pay_amount alone; payment methods give estimated_payer_total.
Version 2.12.0 completes billing through the API: invoices.pdf returns the exact bytes of the PDF (a Buffer in Node.js; now in Python too), billing.previewMessage shows a message, and in test mode billing.testClock and customers.simulateStop. It adds settlement.settleNow and types every invoice.* and subscription.* event. It is backward compatible, except invoices.pdf in Node.js, which returns a Buffer instead of a string.
Version 2.11.0 adds fees_percent to GET /v1/payout-fees: the percentage part of the mobile money payout fees per currency and method (XOF:mtn_bj). The fee of a payout is the fixed part plus the amount times this percentage, rounded up. It is backward compatible.
Version 2.10.0 adds refunds to the number that paid (destination kind original), the fields available and on_hold of the balances and funded_by of a payout, and the error codes payment_already_withdrawn, payout_funds_on_hold, refund_above_maximum and refunds_paused. It is backward compatible.
Version 2.9.0 adds the events payout_destination.created, payout_destination.removed and payment.settlement_held, and the error code payout_method_not_allowed. It is backward compatible.
Version 2.8.0 adds the field from_address of a payout (the address the money left from, when Sonco Pay knows it, otherwise null) and the events payout_destination.confirmed and payout_destination.usable. It is backward compatible.
Version 2.7.0 adds refunds and cancellations: refunds.create, list, retrieve, cancel, preview and payments.refundOptions (in Python: refund_options), the payment statuses partially_refunded and refunded and the events refund.* and payment.refunded.
Version 2.6.0 runs your own payment page without redirection: payments.methods (methods of a payment, with fees and amounts), chooseCrypto, chooseMobileMoney, chooseCard, chooseBinancePay (in Python: choose_crypto, choose_mobile_money, choose_card, choose_binance_pay), poll, the field next_action and the events payment.attempt_failed and payment.failed.
Version 2.5.0 verifies the timestamped webhook signature (t=…,v1=…, 5 minute window, protection against replays) and keeps accepting the legacy signature while your account uses it. Pass all the request headers to constructEvent.
Version 2.4.0 documents multi-approval of payouts: the status awaiting_approval, the field approval, the errors policy_denied and multisig_quorum_unreachable, and the events payout.awaiting_approval, payout.approved, payout.rejected, payout.expired and pendingapproval.
Using WordPress? See WordPress and WooCommerce: no code needed.
npm install https://soncopay.example/assets/sdk/soncopay-node-2.12.1.tgz
curl -O https://soncopay.example/assets/sdk/soncopay-php-2.12.1.zip
unzip soncopay-php-2.12.1.zip
pip install https://soncopay.example/assets/sdk/soncopay-2.12.1-py3-none-any.whl
import SoncoPay from 'soncopay-node'; // const { SoncoPay } = require('soncopay-node'); const sp = new SoncoPay(process.env.SONCOPAY_API_KEY); const payment = await sp.payments.create({ amount: '25.00', currency: 'USD', order_id: 'demo-1042', return_url: 'https://shop.example/thanks', }); res.redirect(303, payment.checkout_url);
require __DIR__ . '/soncopay-php/autoload.php'; use SoncoPay\Client; $sp = new Client(getenv('SONCOPAY_API_KEY')); $payment = $sp->payments->create([ 'amount' => '25.00', 'currency' => 'USD', 'order_id' => 'demo-1042', 'return_url' => 'https://shop.example/thanks', ]); header('Location: ' . $payment['checkout_url'], true, 303);
import os from soncopay import SoncoPay sp = SoncoPay(os.environ["SONCOPAY_API_KEY"]) payment = sp.payments.create( amount="25.00", currency="USD", order_id="demo-1042", return_url="https://shop.example/thanks", ) return redirect(payment["checkout_url"], code=303)
التحقق من webhook
sp_test_… key while you build: the SDKs work the same way in both modes.app.post('/webhooks/soncopay', express.raw({ type: 'application/json' }), (req, res) => { let event; try { event = SoncoPay.webhooks.constructEvent(req.body, req.headers, process.env.SONCOPAY_WEBHOOK_SECRET); } catch (err) { return res.status(400).send('invalid signature'); } if (event.event === 'payment.paid') { // deliver event.data.order_id } res.sendStatus(200); });
use SoncoPay\Webhook; use SoncoPay\Exception\SignatureVerificationException; $payload = file_get_contents('php://input'); $signature = getallheaders(); // all headers: timestamped signature checked first (2.5.0) try { $event = Webhook::constructEvent($payload, $signature, getenv('SONCOPAY_WEBHOOK_SECRET')); } catch (SignatureVerificationException $e) { http_response_code(400); exit('invalid signature'); } if ($event->event === 'payment.paid') { // deliver $event->data['order_id'] } http_response_code(200);
from soncopay import construct_event, SignatureVerificationError @app.post("/webhooks/soncopay") def soncopay_webhook(): try: event = construct_event(request.get_data(), request.headers, SECRET) except SignatureVerificationError: abort(400) if event.event == "payment.paid": # deliver event.data["order_id"] return "", 200
ووردبريس و WooCommerce
The Sonco Pay extension adds Sonco Pay to the WooCommerce checkout and a payment button to any WordPress page, without writing code. It needs WordPress 6.2 and PHP 8.1 or later. WooCommerce is only needed for the shop checkout.
تنزيل الإضافة soncopay-wordpress-1.0.0.zip
- Download the extension and install the zip from Plugins, Add New, Upload Plugin, then activate it.
- Open the Sonco Pay menu, paste your
sp_test_…key and your webhook signing secret, then click Test the API key of the current mode. - For a shop, enable Sonco Pay in WooCommerce, Settings, Payments. It works with the classic checkout and the block checkout.
- Place a test order. When it is confirmed, paste your
sp_live_…key and switch the mode to Live.
Orders are confirmed by a signed webhook. The extension gives Sonco Pay its own address (/wp-json/soncopay/v1/webhook) with every payment: there is nothing to set up in the dashboard. Your site must be on a public https address; otherwise the order is confirmed when the customer comes back to your shop. Refunds are made from the WooCommerce order screen: the customer receives a link to choose where the money goes.
The [soncopay_button] shortcode adds a payment button to any page or post, with or without WooCommerce. Options: amount, currency (XOF, XAF, USD, EUR), description, label, min, max and ask_email="yes". Without amount, the visitor types the amount (donations). Payments made with the button are listed under Sonco Pay, Button payments.
<!-- fixed amount --> [soncopay_button amount="5000" currency="XOF" description="Workshop ticket"] <!-- amount typed by the visitor --> [soncopay_button currency="XOF" min="1000" label="Donate" ask_email="yes"]
Authentication
Send your API key in the X-Api-Key header. Create keys in your dashboard under Developers.
Each key has scopes: payments (payments, methods, rates, customers, invoices) and payouts (payouts and payout destinations), and an optional list of allowed IP addresses. A live key with the payouts scope needs at least one allowed address. A call outside the scopes of the key fails with 403 and the code api_key_scope; from an address that is not allowed, with 403 and api_key_ip_not_allowed. Keys created before October 6, 2026 keep both scopes and accept any address until you edit them.
Moves real money. Use it only on your production server. Live keys work once your business verification is approved.
Works on separate test data: no real payment is taken and payments can be simulated.
curl https://soncopay.example/v1/balances -H "X-Api-Key: sp_test_…"
import SoncoPay from 'soncopay-node'; const sp = new SoncoPay(process.env.SONCOPAY_API_KEY); // sp_test_… or sp_live_… const { balances } = await sp.balances();
$sp = new SoncoPay\Client(getenv('SONCOPAY_API_KEY')); // sp_test_… or sp_live_… $b = $sp->balances();
from soncopay import SoncoPay sp = SoncoPay() # reads SONCOPAY_API_KEY: sp_test_… or sp_live_… b = sp.balances()
مسار الدفع
- Your server creates a payment with the amount and your order ID.
- You show the payment on your own page with the API (see Your own payment page), or, as an option, you redirect your customer to
checkout_url. - The customer pays in crypto on the chosen network (the exact amount), with Binance Pay, by mobile money or by bank card where it is available.
- We confirm the payment, send you a
payment.paidwebhook and credit your balance, minus the fee.
25.0137 USDT). That is how a deposit is matched to its order: tell your customer to send exactly this amount.صفحة الدفع الخاصة بك (من دون إعادة توجيه)
The redirection to checkout_url is optional. Your server can run the whole payment through the API while your own page shows each step to the payer: every method offered on the payment page works this way (crypto on each network offered, including TRX and BNB, Binance Pay, mobile money and bank card). Your API key stays on your server: your page calls your server, which calls the API.
- Create the payment (
POST /v1/payments), with the payer information you already have. - List the methods offered for this payment (
GET /v1/payments/{id}/methods): each one gives its service fee, the estimated amount in its currency, thefieldsto ask the payer and thechoosebody to send. - Send the choice of the payer (
POST /v1/payments/{id}/method). You can also create and choose in one call withmethodon creation. - Show what
next_actionsays (table below), then follow the payment with the webhooks and by reading it (GET /v1/payments/{id}). - Fulfil the order on
payment.paid.
طرق الدفع المتاحة لدفعة ما
GET/v1/payments/{id}/methods
Answers payment_id, status, amount, currency, fee_paid_by, expires_at, payer_requirements (the fields your account collects and the missing fields to send in payer) and methods. Each method has method, code, label, asset and network (crypto), pay_currency, service_fee (in the currency of the payment, when the payer pays it), estimated_pay_amount (total in pay_currency, service fee included), and for mobile money operator_fee_percent, estimated_operator_fee and estimated_payer_total (what the phone will ask, operator fee included: show this amount), fields, redirect and choose. The exact amount is set when the method is chosen. The list is empty once the payment is no longer open.
fee_paid_by): the amount in next_action is always the exact total to pay, fee included. Never add anything to it.ما يجب عرضه بعد ذلك
| الإجراء التالي | ما يُعرض على صفحتك |
|---|---|
choose_method | No method yet, or the last request was declined (retry is true, last_error says why). Show the methods; the payer may retry the same one. |
send_crypto | Show address, network_label, amount and a QR code of qr_content, with the time left until expires_at. amount_rule exact: the payer sends exactly this amount, which identifies the payment. at_least: the address belongs to this payment. Show memo when there is one. |
wait_for_confirmation | A transaction was seen on the network (tx_hash). Show that the payment is being confirmed; never ask to send again. |
open_wallet | Binance Pay: a button to url and a QR code of qr_content, with amount and asset. |
approve_on_phone | Mobile money: ask the payer to approve the request on the phone phone (operator operator) for amount currency. Until change_method_after, another method or a new request is refused with 409. |
redirect | Bank card or mobile money on the operator page: send the payer to url (secure page). Add return_url to the choice so that the payer comes straight back to your page. |
null | Nothing left for the payer to do: paid, expired, failed or partially paid. Read status. |
Mobile money: amount in next_action is what the phone of the payer will ask, operator fee included (operator_fee, null when there is none; base_amount is the amount without it). Show this amount to the payer, never pay_amount. The payment also carries payer_total (the same total) and operator_fee; pay_amount and amount_due stay the amount to pay without the operator fee (the amount credited and reconciled).
curl https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/methods -H "X-Api-Key: sp_test_…"
const { methods, payer_requirements } = await sp.payments.methods(payment.id);
// methods[i].choose is the body to send for this method
const usdt = methods.find((m) => m.method === 'crypto' && m.asset === 'USDT' && m.network === 'TRON');
$offer = $sp->payments->methods($payment['id']);
// $offer['methods'][$i]['choose'] is the body to send for this method
$missing = $offer['payer_requirements']['missing'];
offer = sp.payments.methods(payment["id"])
# offer["methods"][i]["choose"] is the body to send for this method
missing = offer["payer_requirements"]["missing"]
{
"object": "payment_methods",
"payment_id": "pay_3f9a5c0d21e4b7a6c8d1",
"status": "new", "amount": "25", "currency": "USD", "fee_paid_by": "payer",
"payer_requirements": { "fields": [{ "key": "name", "required": true, "provided": false }], "missing": ["name"] },
"methods": [
{ "method": "crypto", "code": "crypto", "label": "USDT · Tron (TRC-20)", "asset": "USDT", "network": "TRON",
"pay_currency": "USDT", "service_fee": "0.13", "estimated_pay_amount": "25.13", "fields": [], "redirect": false,
"choose": { "method": "crypto", "asset": "USDT", "network": "TRON" } },
{ "method": "mobile_money", "code": "orange_ci", "label": "Orange Money", "operator": "ORANGE",
"pay_currency": "XOF", "service_fee": "0.13", "estimated_pay_amount": "15074", "operator_fee_percent": "2.75", "estimated_operator_fee": "415", "estimated_payer_total": "15489", "fields": ["phone"],
"redirect": false, "choose": { "method": "mobile_money", "code": "orange_ci" } },
{ "method": "card", "code": "card", "label": "Bank card", "pay_currency": "XOF", "redirect": true,
"choose": { "method": "card", "code": "card" } }
]
}
{
"type": "send_crypto", "asset": "USDT", "network": "TRON", "network_label": "Tron (TRC-20)",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", "memo": null,
"amount": "25.1337", "amount_rule": "exact", "underpaid": false, "received_amount": null,
"qr_content": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"expires_at": "2026-10-07T15:30:00+00:00", "quote_expires_at": null
}
{
"type": "send_crypto", "asset": "USDT", "network": "BSC", "network_label": "BNB Smart Chain (BEP-20)",
"address": "0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE", "memo": null,
"amount": "10.4", "amount_rule": "at_least", "underpaid": true, "received_amount": "30",
"qr_content": "0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE",
"expires_at": "2026-10-08T15:30:00+00:00", "quote_expires_at": null
}
{
"type": "approve_on_phone", "phone": "+2250700000000", "operator": "ORANGE",
"amount": "15489", "currency": "XOF", "base_amount": "15074", "operator_fee": "415",
"instructions": "Approve the payment request on your phone.",
"change_method_after": "2026-10-07T15:10:00+00:00", "expires_at": "2026-10-07T15:30:00+00:00"
}
{
"type": "redirect", "url": "https://soncopay.example/pay/pay_3f9a5c0d21e4b7a6c8d1/redirect",
"amount": "15074", "currency": "XOF", "expires_at": "2026-10-07T15:30:00+00:00"
}
{
"type": "open_wallet", "url": "https://…", "qr_content": "https://…",
"amount": "25.13", "asset": "USDT", "expires_at": "2026-10-07T15:30:00+00:00"
}
كل طريقة دفع على صفحتك
Crypto: {"method": "crypto", "asset": "USDT", "network": "TRON"} (or BSC and every network offered for this payment, TRX on TRON, BNB on BSC). For TRX and BNB, the amount is guaranteed until quote_expires_at, then updated on the same address: read the payment again at that time.
Partial crypto payment: the status becomes underpaid and next_action.amount is what is left to send to the same address before expires_at, as one amount (underpaid is true, received_amount gives what arrived). Show this amount as it is. Without the rest in time, the status becomes partially_paid.
Mobile money: {"method": "mobile_money", "code": "orange_ci", "phone": "+2250700000000"}, plus operator when fields asks for it. The request reaches the phone of the payer (approve_on_phone), or the payer confirms on the operator page (redirect). A declined request brings the payment back to new with last_error and the webhook payment.attempt_failed: send the request again (another number if needed) or offer another method.
Bank card, where available: {"method": "card", "return_url": "https://shop.example/pay/1042"}. Card details are entered on the secure card page only (redirect); the payer then comes back to return_url.
Binance Pay: {"method": "binance_pay"}, then open_wallet.
Change of method: send another choice while the payment is new or waiting. After a partial payment, the method can no longer change.
curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/method \ -H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \ -d '{"method":"crypto","asset":"USDT","network":"TRON","payer":{"name":"Demo Customer"}}' # or create and choose in one call curl -X POST https://soncopay.example/v1/payments -H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \ -d '{"amount":"25","currency":"USD","order_id":"1042","method":"crypto","asset":"TRX","network":"TRON"}'
const p = await sp.payments.chooseCrypto(payment.id, { asset: 'USDT', network: 'TRON',
payer: { name: 'Demo Customer' } });
const a = p.next_action; // type: 'send_crypto'
show({ address: a.address, network: a.network_label, amount: `${a.amount} ${a.asset}`,
exact: a.amount_rule === 'exact', qr: a.qr_content, until: a.expires_at, rateUntil: a.quote_expires_at });
$p = $sp->payments->chooseCrypto($payment['id'], ['asset' => 'USDT', 'network' => 'TRON',
'payer' => ['name' => 'Demo Customer']]);
$a = $p['next_action']; // type: send_crypto
// show $a['address'], $a['network_label'], $a['amount'] . ' ' . $a['asset'],
// "exactly" when $a['amount_rule'] === 'exact', a QR code of $a['qr_content'], $a['expires_at']
p = sp.payments.choose_crypto(payment["id"], "USDT", "TRON", payer={"name": "Demo Customer"})
a = p["next_action"] # type: send_crypto
# show a["address"], a["network_label"], f'{a["amount"]} {a["asset"]}',
# "exactly" when a["amount_rule"] == "exact", a QR code of a["qr_content"], a["expires_at"]
curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/method \ -H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \ -d '{"method":"mobile_money","code":"orange_ci","phone":"+2250700000000"}' # declined (status "new", last_error): send it again, or choose another method
const p = await sp.payments.chooseMobileMoney(payment.id, { code: 'orange_ci', phone: '+2250700000000' });
if (p.next_action.type === 'approve_on_phone') {
// "Approve the request on +225 07 00 00 00 00"
} else if (p.next_action.type === 'redirect') {
// operator page: send the payer to p.next_action.url (add return_url to come back to your page)
}
const done = await sp.payments.poll(payment.id, { interval: 3000, timeout: 180000 });
$p = $sp->payments->chooseMobileMoney($payment['id'], ['code' => 'orange_ci', 'phone' => '+2250700000000']); // $p['next_action']['type']: approve_on_phone (wait for the approval) or redirect (operator page) $done = $sp->payments->poll($payment['id'], ['interval' => 3, 'timeout' => 180]); if ($done['status'] === 'new') { // declined: $done['last_error'], offer to retry or another method }
p = sp.payments.choose_mobile_money(payment["id"], "orange_ci", phone="+2250700000000")
# p["next_action"]["type"]: approve_on_phone (wait for the approval) or redirect (operator page)
done = sp.payments.poll(payment["id"], interval=3, timeout=180)
if done["status"] == "new":
pass # declined: done["last_error"], offer to retry or another method
curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/method \ -H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \ -d '{"method":"card","return_url":"https://shop.example/pay/1042"}' # next_action: {"type":"redirect","url":"…/pay/pay_3f9a5c0d21e4b7a6c8d1/redirect"}
const p = await sp.payments.chooseCard(payment.id, { return_url: 'https://shop.example/pay/1042' });
res.redirect(303, p.next_action.url); // secure card page, then back to return_url
// on return_url: read the payment (retrieve) and show its status
$p = $sp->payments->chooseCard($payment['id'], ['return_url' => 'https://shop.example/pay/1042']);
header('Location: ' . $p['next_action']['url'], true, 303); // secure card page, then back to return_url
p = sp.payments.choose_card(payment["id"], return_url="https://shop.example/pay/1042") return redirect(p["next_action"]["url"], code=303) # secure card page, then back to return_url
curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/method \
-H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \
-d '{"method":"binance_pay"}'
const p = await sp.payments.chooseBinancePay(payment.id);
// a button to p.next_action.url and a QR code of p.next_action.qr_content
$p = $sp->payments->chooseBinancePay($payment['id']);
// a button to $p['next_action']['url'] and a QR code of $p['next_action']['qr_content']
p = sp.payments.choose_binance_pay(payment["id"])
# a button to p["next_action"]["url"] and a QR code of p["next_action"]["qr_content"]
متابعة الدفعة
Webhooks: payment.confirming, payment.paid, payment.underpaid, payment.attempt_failed, payment.expired and payment.failed carry the whole payment, next_action included.
From your page, ask your server every few seconds; your server reads GET /v1/payments/{id}. Each read also checks a pending mobile money or card request, applies an expiry that is due and updates the TRX or BNB amount of an expired rate, exactly like the payment page. The SDKs offer poll, which reads until the status or the next action changes.
POST /v1/payments/{id}/simulate pays the chosen method. Mobile money test numbers: ending in 99 is declined, ending in 98 stays waiting, any other number is paid after a few seconds.
curl https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1 -H "X-Api-Key: sp_test_…" # status, next_action, amount_remaining (partial payment), last_error
// your page asks your server; your server reads the payment
app.get('/orders/:id/payment', async (req, res) => {
const p = await sp.payments.retrieve(req.params.paymentId);
res.json({ status: p.status, next_action: p.next_action, error: p.last_error });
});
// your page asks your server; your server reads the payment
$p = $sp->payments->retrieve($paymentId);
echo json_encode(['status' => $p['status'], 'next_action' => $p['next_action'], 'error' => $p['last_error']]);
# your page asks your server; your server reads the payment
p = sp.payments.retrieve(payment_id)
return {"status": p["status"], "next_action": p["next_action"], "error": p["last_error"]}
إنشاء دفعة
POST/v1/payments
| Field | Description |
|---|---|
amountrequiredنص أو رقم | Amount to collect. |
currencyrequiredstring | USD, EUR, XOF, XAF, or a crypto asset (USDT, USDC, BTC, ETH, BNB, TRX, LTC). Fiat amounts are converted at the current rate when the customer chooses a method. |
order_idstring | Your reference. Sending the same order_id again returns the same payment, so retries are safe. |
descriptionstring | Shown to the customer on the payment page. |
customer_emailstring | Your customer's email, for your records. |
return_urlstring | Where the customer goes back after paying. |
callback_urlstring | Webhook URL for this payment only, as a public HTTPS address. By default, the webhook of the API key that created the payment is used, or else the URL of your account. |
lifetime_minutesinteger | Between 10 and 1440. By default, the lifetime set by Sonco Pay. |
methodsarray | Restrict the choices, for example ["USDT"], ["binance_pay"], ["USDT:TRON"], ["mobile_money"] or a method code such as ["orange_ci"]. |
metadataobject | Any JSON object, returned as is. |
countrystring | Customer country (ISO alpha-2, for example CI, SN or CM): only the methods of this country are offered. |
methodstring | Starts the payment right away, without redirection: crypto (with asset and network), binance_pay, card or a mobile money method code (see Mobile money). The payment then carries next_action. |
assetstring | With method set to crypto: the asset to receive, for example USDT. |
networkstring | With method set to crypto: the network, for example TRON or BSC. |
phonestring | With method: the mobile money number, in international format. |
operatorstring | With method: the operator, when the method needs one. |
payerobject | Information about the payer, all optional: name, email, phone (international format), country (ISO alpha-2) and reference (your own customer reference). See Payer information. |
fee_paid_bystring | Who pays the service fee for this payment: payer (the customer pays the amount plus the fee, you receive the full amount) or merchant (the fee is deducted from what you receive). By default, the choice made in your dashboard (Settings, Service fee). |
بيانات الدافع
In the dashboard (Settings), choose for each field whether it is not collected, optional or required. A required field that your call does not send is asked to the customer on the payment page, before they choose how to pay. An email address also receives the payment receipt. Only the fields you collect are stored; they are kept for a limited time and never shown to anyone else.
The payment object carries payer (the collected fields, or null) in every response and in the signed webhooks. If you choose the method yourself with the API while a required field is missing, the call fails with 422 and the code payer_required (with fields); an invalid value fails with payer_invalid (with field).
curl -X POST https://soncopay.example/v1/payments \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"amount":"25","currency":"USD","order_id":"1042","return_url":"https://shop.example/thanks", "payer":{"name":"Demo Customer","email":"[email protected]","reference":"client-42"}}'
const payment = await sp.payments.create({ amount: '25', currency: 'USD', order_id: '1042', return_url: 'https://shop.example/thanks', payer: { name: 'Demo Customer', email: '[email protected]', reference: 'client-42' }, }); payment.checkout_url;
$payment = $sp->payments->create([
'amount' => '25',
'currency' => 'USD',
'order_id' => '1042',
'return_url' => 'https://shop.example/thanks',
'payer' => ['name' => 'Demo Customer', 'email' => '[email protected]', 'reference' => 'client-42'],
]);
$payment['checkout_url'];
payment = sp.payments.create(
amount="25",
currency="USD",
order_id="1042",
return_url="https://shop.example/thanks",
payer={"name": "Demo Customer", "email": "[email protected]", "reference": "client-42"},
)
payment["checkout_url"]
{
"id": "pay_3f9a5c0d21e4b7a6c8d1",
"object": "payment",
"livemode": false,
"status": "new",
"amount": "25", "currency": "USD",
"order_id": "1042",
"checkout_url": "…/pay/pay_3f9a5c0d21e4b7a6c8d1",
"payer": { "name": "Demo Customer", "email": "[email protected]", "reference": "client-42" },
"expires_at": "2026-10-01T15:30:00+00:00",
…
}
اختيار وسيلة الدفع
Skip this step if you redirect to checkout_url: the customer chooses on our page. On your own page, list the methods of the payment (GET /v1/payments/{id}/methods), then send the choice. GET /v1/methods gives the methods of your account in general.
The list depends on your account: Sonco Pay can enable or disable payment methods for each account. GET /v1/methods and GET /v1/payments/{id}/methods only return the methods open to your account. A method that is not open, sent in methods or chosen with POST /v1/payments/{id}/method, is refused with 422 and the code method_not_allowed. A payment already started on a method keeps working.
GET/v1/methods
Each entry of methods has a method (crypto, binance_pay, mobile_money or card), a code and a kind. Mobile money entries add operator, countries, currency, redirect and fields (what to send: phone, sometimes operator). The payment_methods list gives the methods usable by your account, with your effective fees.
curl https://soncopay.example/v1/methods -H "X-Api-Key: sp_test_…"
const { methods, payment_methods } = await sp.methods();
$m = $sp->methods(); $m['methods']; $m['payment_methods'];
m = sp.methods() m["methods"], m["payment_methods"]
POST/v1/payments/{id}/method
| Field | Description |
|---|---|
methodrequiredstring | crypto, binance_pay, card, mobile_money (with code) or a mobile money method code. |
assetstring | For crypto: the asset to receive, for example USDT. |
networkstring | For crypto: TRON, BSC, ETH, POLYGON, BTC or LTC. |
codestring | With mobile_money: the method code, for example orange_ci or mtn_cm. |
phonestring | For mobile money: the customer number, in international format. |
operatorstring | For mobile money: the operator, when the method needs one. |
payerobject | Payer information collected on your page, merged with what the payment already has. |
return_urlstring | After a secure page (bank card, operator page), the payer comes straight back to this address (https; http in test mode) instead of the payment page. It also becomes the return_url of the payment. |
The bank card is offered where it is available: GET /v1/methods then lists it with kind set to card.
The QR code of any payment is available at /pay/{id}/qr.svg.
curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/method \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"method":"crypto","asset":"USDT","network":"TRON"}'
const p = await sp.payments.chooseMethod('pay_3f9a5c0d21e4b7a6c8d1', { method: 'crypto', asset: 'USDT', network: 'TRON', }); p.pay_address; p.pay_amount;
$p = $sp->payments->chooseMethod('pay_3f9a5c0d21e4b7a6c8d1', [ 'method' => 'crypto', 'asset' => 'USDT', 'network' => 'TRON', ]);
p = sp.payments.choose_method("pay_3f9a5c0d21e4b7a6c8d1", "crypto", asset="USDT", network="TRON") p["pay_address"], p["pay_amount"]
{ "method": "crypto", "asset": "USDT", "network": "TRON" }
# the payment now carries:
# pay_address, pay_amount (send exactly this amount), network, expires_at
{ "method": "binance_pay" }
# the payment now carries:
# pay_url (open it or show it as a QR code), pay_amount in USDT
{ "method": "card" }
# the payment now carries:
# pay_url = https://…/pay/{id}/redirect : send the customer there,
# they pay on the secure card page and come back to the payment page
الأموال عبر الهاتف المحمول
Mobile money works in several countries through local operators (Wave, Orange Money, MTN MoMo, Moov Money, Free Money and others). Each method has a code made of the operator and the country (for example orange_ci or mtn_cm), the countries where it works and the currency it collects: XOF or XAF.
الدول والمشغّلون والعملات
| Country | المشغّلون (رموز الوسائل) | Currency |
|---|---|---|
Côte d'Ivoire CI | Wave wave_ci, Orange Money orange_ci, MTN Mobile Money mtn_ci, Moov Money moov_ci | XOF |
Senegal SN | Wave wave_sn, Orange Money orange_sn, Free Money free_sn | XOF |
Benin BJ | MTN Mobile Money mtn_bj, Moov Money moov_bj | XOF |
Burkina Faso BF | Orange Money orange_bf, Moov Money moov_bf | XOF |
Cameroon CM | MTN Mobile Money mtn_cm, Orange Money orange_cm | XAF |
GET /v1/methods returns the methods open to your account right now, with kind set to mobile_money, code, operator, countries and currency.
- Choose the customer's country with
country(ISO alpha-2, for exampleCIorCM) and the operator withmethod(its code), plusphonein international format. You can also choose the method later withPOST /v1/payments/{id}/method. - The customer approves the request on their phone. Show them
instructions. When the method works in redirect mode,pay_urlis filled in: send the customer there. - When the operator confirms, the payment becomes
paidand you receive thepayment.paidwebhook. Your balance is credited in the collected currency:XOForXAF.
حقول الدفعة
| Field | Description |
|---|---|
method_code | The chosen method: crypto, binance_pay, card or a mobile money code. |
provider | Family of the chosen method: crypto, binance_pay, mobile_money or card, and null before the choice. It never names an internal processor. Base your logic on method, method_code and status. |
pay_url | Binance Pay: the Binance Pay link. Mobile money in redirect mode and bank card: a link to /pay/{id}/redirect on our domain, which sends the customer to the secure payment page while the payment waits for it, then back to the payment page. |
customer_phone | The number the request was sent to. |
operator | The mobile money operator, when known. |
country | The customer country (ISO alpha-2). |
instructions | Text to show the customer while they approve the request. |
last_error | Why the last request failed, for example a request declined by the customer. |
409. A declined request puts the payment back to new with last_error: the customer can try again, up to 5 attempts, then 429.99, the request is declined; ending in 98, it stays pending; any other number is paid after a few seconds, or at once with POST /v1/payments/{id}/simulate.
# Côte d'Ivoire: Orange Money, amount in XOF (no decimals) curl -X POST https://soncopay.example/v1/payments \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"amount":"5000","currency":"XOF","country":"CI","order_id":"demo-1043","method":"orange_ci","phone":"+2250700000000"}' # Cameroon: MTN Mobile Money, amount in XAF (no decimals) curl -X POST https://soncopay.example/v1/payments \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"amount":"5000","currency":"XAF","country":"CM","order_id":"demo-1044","method":"mtn_cm","phone":"+237670000000"}'
// Côte d'Ivoire: Orange Money, amount in XOF (no decimals) const p = await sp.payments.create({ amount: '5000', currency: 'XOF', country: 'CI', order_id: 'demo-1043', method: 'orange_ci', phone: '+2250700000000', }); p.method_code; // 'orange_ci' p.instructions; // text to show the customer if (p.pay_url) res.redirect(303, p.pay_url); // redirect mode // Cameroon: MTN Mobile Money, amount in XAF (no decimals) const q = await sp.payments.create({ amount: '5000', currency: 'XAF', country: 'CM', order_id: 'demo-1044', method: 'mtn_cm', phone: '+237670000000', }); // the operators of one country, from GET /v1/methods const { methods } = await sp.methods(); methods.filter((m) => m.kind === 'mobile_money' && m.countries.includes('SN')); // or later, on an existing payment (another operator of the same country) await sp.payments.chooseMethod(p.id, { method: 'mobile_money', code: 'wave_ci', phone: '+2250700000000' });
// Côte d'Ivoire: Orange Money, amount in XOF (no decimals) $p = $sp->payments->create([ 'amount' => '5000', 'currency' => 'XOF', 'country' => 'CI', 'order_id' => 'demo-1043', 'method' => 'orange_ci', 'phone' => '+2250700000000', ]); $p['method_code']; // 'orange_ci' $p['instructions']; // text to show the customer if ($p['pay_url'] !== null) { header('Location: ' . $p['pay_url'], true, 303); // redirect mode } // Cameroon: MTN Mobile Money, amount in XAF (no decimals) $q = $sp->payments->create([ 'amount' => '5000', 'currency' => 'XAF', 'country' => 'CM', 'order_id' => 'demo-1044', 'method' => 'mtn_cm', 'phone' => '+237670000000', ]); // or later, on an existing payment (another operator of the same country) $sp->payments->chooseMethod($p['id'], ['method' => 'mobile_money', 'code' => 'wave_ci', 'phone' => '+2250700000000']);
# Côte d'Ivoire: Orange Money, amount in XOF (no decimals) p = sp.payments.create(amount="5000", currency="XOF", country="CI", order_id="demo-1043", method="orange_ci", phone="+2250700000000") p["method_code"], p["instructions"] # "orange_ci", text to show the customer if p["pay_url"]: return redirect(p["pay_url"], code=303) # redirect mode # Cameroon: MTN Mobile Money, amount in XAF (no decimals) q = sp.payments.create(amount="5000", currency="XAF", country="CM", order_id="demo-1044", method="mtn_cm", phone="+237670000000") # or later, on an existing payment (another operator of the same country) sp.payments.choose_method(p["id"], "mobile_money", code="wave_ci", phone="+2250700000000")
السحب إلى الأموال عبر الهاتف المحمول
Send method (the method code of the country, for example wave_sn or orange_cm), phone and amount to POST /v1/payouts, plus operator when the method needs one. The currency is the one of the method: XOF or XAF, in whole amounts.
# Senegal: Wave, XOF curl -X POST https://soncopay.example/v1/payouts \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"method":"wave_sn","phone":"+221770000000","amount":"10000","reference":"demo-payout-8"}' # Cameroon: Orange Money, XAF curl -X POST https://soncopay.example/v1/payouts \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"method":"orange_cm","phone":"+237690000000","amount":"15000","reference":"demo-payout-9"}'
await sp.payouts.create({ method: 'wave_sn', phone: '+221770000000', amount: '10000', reference: 'demo-payout-8' }); // XOF await sp.payouts.create({ method: 'orange_cm', phone: '+237690000000', amount: '15000', reference: 'demo-payout-9' }); // XAF
$sp->payouts->create(['method' => 'wave_sn', 'phone' => '+221770000000', 'amount' => '10000', 'reference' => 'demo-payout-8']); // XOF $sp->payouts->create(['method' => 'orange_cm', 'phone' => '+237690000000', 'amount' => '15000', 'reference' => 'demo-payout-9']); // XAF
sp.payouts.create(method="wave_sn", phone="+221770000000", amount="10000", reference="demo-payout-8") # XOF sp.payouts.create(method="orange_cm", phone="+237690000000", amount="15000", reference="demo-payout-9") # XAF
الاسترجاع والسرد
GET/v1/payments/{id}
GET/v1/payments
| Parameter | Description |
|---|---|
status | Only payments with this status, for example paid. |
q | Search by payment ID, order ID or customer email. |
limit | From 1 to 200. Default: 50. |
offset | Number of payments to skip. The response says has_more when there are more. |
POST /v1/payments/{id}/simulate marks a payment as paid with its exact amount, once a method is chosen, so you can test your webhook handler.
curl https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1 -H "X-Api-Key: sp_test_…" curl "https://soncopay.example/v1/payments?status=paid&limit=50" -H "X-Api-Key: sp_test_…" # test mode curl -X POST https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/simulate -H "X-Api-Key: sp_test_…"
const p = await sp.payments.retrieve('pay_3f9a5c0d21e4b7a6c8d1'); const { items, has_more } = await sp.payments.list({ status: 'paid', limit: 50 }); await sp.payments.simulate(p.id); // test mode
$p = $sp->payments->retrieve('pay_3f9a5c0d21e4b7a6c8d1'); $page = $sp->payments->list(['status' => 'paid', 'limit' => 50]); $page['has_more']; $sp->payments->simulate($p['id']); // test mode
p = sp.payments.retrieve("pay_3f9a5c0d21e4b7a6c8d1") page = sp.payments.list(status="paid", limit=50) page["has_more"] sp.payments.simulate(p["id"]) # test mode
حالات الدفع
| Status | Meaning |
|---|---|
| new | Created; the customer has not chosen a method yet. |
| waiting | Method chosen; waiting for the funds. |
| confirming | Deposit detected; waiting for confirmations. |
| paid | Confirmed and credited to your balance. Deliver the order. |
| expired | Not paid in time. A deposit that arrives within 24 hours of expiry still marks it paid, with late: true in the webhook. |
| underpaid | Crypto on an address reserved for the payment: part of the amount arrived, the rest (amount_remaining) is expected at the same address before expires_at. |
| partially_paid | The rest did not arrive in time: the amount received is kept and our team can validate the payment or return the funds. |
| failed | Paid with a wrong amount through Binance Pay. |
| partially_refunded | Part of the payment was refunded (refunded_amount). See Refunds. |
| refunded | Everything that could be refunded was refunded, after a full refund or a cancellation. |
تم استلام أصل خاطئ
Wrong asset received: when the customer sends another asset, or the same asset on another network, to the address reserved for a crypto payment, the payment keeps its status and gets a wrong_asset object, and you receive the payment.wrong_asset webhook. Our team then decides: switch the payment to the asset received, wait for the rest, or close the case. Do not fulfil the order before payment.paid.
| Field | Description |
|---|---|
wrong_asset.state | in_review (our team is handling it) or resolved. |
wrong_asset.reason | wrong_asset (another asset) or wrong_network (the same asset on another network). |
wrong_asset.expected, wrong_asset.received | What the payment expected and what arrived: asset, network, amount, and tx_hash for the transfer received. |
wrong_asset.resolution | switched (the payment was accepted in the asset received), ignored or closed (nothing was credited to this payment), null while in review. |
wrong_asset.handling_fee, wrong_asset.fee_percent | Wrong asset handling fee taken when the payment was switched, and its rate; null otherwise. |
When our team switches the payment to the asset received, you receive the usual payment.paid, sent like any other (the callback_url of the payment, then the webhook of the key, then the webhook of your account): your existing code validates the order with no change. It also carries resolution (wrong_asset), received_asset, received_network and fee_details (commission, wrong_asset_fee, overpayment). asset, network and amount_due of the payment become those of the asset received.
A wrong asset handling fee (2 % of the amount credited by default) is taken on top of the commission when the payment is switched. It is included in fee, given in wrong_asset.handling_fee, and shown as its own line in your statement.
Balances
GET/v1/balances
Returns your available balance per asset, in the mode of the key you use.
reserved gives, per asset, the amount and the fee of your payouts that are still open. They are already deducted from balances.
available gives, per asset, what you can withdraw now; on_hold gives what is still in its waiting period before payout (amount and next_available_at). Each payout is taken from your payments, the oldest first, and GET /v1/payouts/{id} lists them in funded_by. A payout above available is refused with 422 payout_funds_on_hold.
GET /v1/payments/{id} carries payout_hold when the payment has a waiting period before payout: days, available_at (end of the waiting period, once the payment is paid) and card_rule. Card payments can always be withdrawn only 14 days after they are paid, as set by the card network rules (chargeback period): card_rule is then true. Otherwise payout_hold is null.
curl https://soncopay.example/v1/balances -H "X-Api-Key: sp_test_…"
const { balances, reserved } = await sp.balances();
$b = $sp->balances(); $b['balances']; $b['reserved'];
b = sp.balances() b["balances"], b["reserved"]
{
"livemode": false,
"balances": { "USDT": "124.5", "XOF": "35000" },
"reserved": { "USDT": "51" }
}
GET/v1/ledger
Lists every movement of your balance: payments, fees and payouts. Filter with asset, page with limit (up to 500) and offset.
/v1/ledger keeps its format but each id becomes the ID of the accounting line: IDs from before and after the switch cannot be compared. Use statements to reconcile.curl "https://soncopay.example/v1/ledger?asset=USDT&limit=100" -H "X-Api-Key: sp_test_…"
const { items } = await sp.ledger.list({ asset: 'USDT', limit: 100 }); for await (const entry of sp.ledger.listAll({ asset: 'USDT' })) { … }
$page = $sp->ledger->list(['asset' => 'USDT', 'limit' => 100]); foreach ($sp->ledger->listAll(['asset' => 'USDT']) as $entry) { … }
page = sp.ledger.list(asset="USDT", limit=100) for entry in sp.ledger.list_all(asset="USDT"): …
Fees
GET/v1/fees
Returns the fee applied to your payments, as a percentage plus a fixed amount in USD, for each method you can use in this mode, with the payout fees and the limits. Each part comes from your own rate first, then from the method, then from the platform default: percent_source and fixed_source say which one applies.
The values above are examples: your dashboard and this endpoint show the fees that apply to you.
Each network (mobile money operator, card network, blockchain) charges its own payment fees, which vary from one network to another and over time. Sonco Pay always applies the rate declared in Sonco Pay itself: the one shown on the payment page and returned by the API (operator_fee, payer_total), even if the network changes its own. On the payment page, the exact amount to pay is only shown once the customer has chosen a payment method, without the detail of the fees; before that, each network shows its own total, all fees included.
من يدفع رسوم الخدمة
By default the customer pays the service fee: the payment page shows the amount, the service fee and the total, and the customer pays the total. Your balance receives the full amount. You can instead take the fee from what you receive, in the dashboard (Settings, Service fee) or for one payment with fee_paid_by. The choice is fixed on each payment when it is created.
Every payment and webhook carries fee_paid_by, amount_due (the amount to pay in asset, service fee included; for mobile money the phone asks payer_total, operator fee included), fee_quote (the service fee added to that total, or null), and after payment fee and net_amount. GET /v1/fees returns your setting in fee_bearer; when Sonco Pay has locked this setting, another value is ignored: the payment is accepted with the locked setting and fee_paid_by shows who pays.
curl https://soncopay.example/v1/fees -H "X-Api-Key: sp_test_…"
const fees = await sp.fees();
$fees = $sp->fees();
fees = sp.fees()
{
"livemode": false,
"payment": { "percent": "0.5", "fixed_usd": "0", "percent_source": "global", "fixed_source": "global" },
"per_method": [ { "code": "orange_ci", "name": "Orange Money", "kind": "mobile_money", "percent": "1.5", … } ],
"payout_fees": { "USDT:TRON": "1", … },
"limits": { "min_payment_usd": 1, "min_payout_usd": 5 }
}
الحدود الدنيا للسحب ورسومه حسب الشبكة
يجب أن يبلغ كل سحب، بما في ذلك التسوية التلقائية، الحد الأدنى لشبكته؛ وتُضاف رسوم الشبكة إلى المبلغ وتُخصم من رصيدك.
تُرسل التسوية التلقائية عندما يبلغ المجموع المستحق على شبكة حدها الأدنى. وما دون ذلك تتراكم المبالغ في رصيدك وتُرسل معًا في سحب واحد.
| العملة والشبكة | الحد الأدنى لكل سحب | Fee | الحد الأدنى المخصوم من الرصيد |
|---|---|---|---|
| جارٍ التحميل… | |||
تأتي هذه القيم من الإعدادات الحية وقد تتغير مع الشبكات. يعيدها GET /v1/fees لحسابك (payout_limits).
Payouts
POST/v1/payouts
Withdraws from your balance to a crypto address, a mobile money number or a saved payout destination, bank account included. For crypto, the network fee from /v1/payout-fees is added to the amount; the same call returns the minimum payout.
In live mode, a payout created with an API key goes to a saved and confirmed payout destination (destination_id): an address typed in the request is refused with 422 and the code destination_required (during the transition period it is still accepted and the response carries a Sonco-Deprecation header). Payouts are also limited per 24 hours, in number and in USD: above the limit of your account, 429 and the code payout_velocity_exceeded.
| Field | Description |
|---|---|
assetstring | Crypto: the asset to withdraw, for example USDT (required). Mobile money: the currency, by default the one of the method. |
networkstring | Crypto (required): the network to send on, for example TRON. |
amountrequiredنص أو رقم | Amount the address receives. |
addressstring | Crypto (required): the destination address, checked against the network format. |
methodstring | Mobile money: the method code, for example wave_sn or orange_cm. |
phonestring | Mobile money: the number to pay, in international format. |
operatorstring | Mobile money: the operator, when the method needs one. |
memostring | Memo or tag, when the destination needs one. |
referencestring | Your reference. Sending the same reference again returns the same payout. |
destination_idstring | A saved and confirmed payout destination. Its details replace asset, network, address, method and phone; asset, when sent, must equal its currency. It is the only way to pay out to a bank account. |
curl -X POST https://soncopay.example/v1/payouts \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{ "asset": "USDT", "network": "TRON", "amount": "150", "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", "reference": "withdraw-77" }'
const payout = await sp.payouts.create({ asset: 'USDT', network: 'TRON', amount: '150', address: 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE', reference: 'withdraw-77', });
$payout = $sp->payouts->create([
'asset' => 'USDT', 'network' => 'TRON', 'amount' => '150',
'address' => 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE', 'reference' => 'withdraw-77',
]);
payout = sp.payouts.create(
asset="USDT", network="TRON", amount="150",
address="TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", reference="withdraw-77",
)
| Status | Meaning |
|---|---|
| pending_review | A large payout waits for our team's review before it is sent. |
| queued | Accepted and waiting to be sent. |
| submitting | Being handed over for sending. If the answer is lost, the same request is retried safely: a payout is never sent twice. |
| sent | Sent; waiting for confirmation on the network. |
| unknown | No clear answer after sending: our team checks before anything else happens. The payout is never sent again automatically. |
| awaiting_manual | Bank transfer: waiting for our team to execute it. It then becomes completed with bank_reference. |
| completed | Done: tx_hash (crypto) or bank_reference (bank transfer) is filled in. |
| failed | The payout failed; the amount and the fee are back in your balance. |
| rejected | Refused after review; the amount and the fee are back in your balance. |
| awaiting_approval | Waits for the signatures of your team (multi-approval). The amount and the fee are set aside meanwhile. |
| expired | Not signed in time (multi-approval); the amount and the fee are back in your balance. |
حقول السحب
| Field | Description |
|---|---|
rail | crypto, momo (mobile money) or bank. |
destination_id | The saved destination used, or null. |
destination | Copy of the destination at the time of the request (kind, label, currency, masked details), or null. |
bank_reference | Reference of the bank transfer, once it is executed. |
tx_hash | Transaction hash of a crypto payout. |
from_address | The address the money left from on the network, when Sonco Pay knows it (payouts sent from our own wallet), otherwise null. Optional: use it only to look the transfer up when the blockchain explorer is slow to show it. It is not a proof of payment: the proof stays tx_hash and its confirmation (payout.completed). |
error | Why the payout failed, when it did. |
approval_id | Multi-approval: the request to sign (GET /v1/payouts/{id} gives approval: status, required, approvals, expires_at, signatures, missing), or null. |
curl https://soncopay.example/v1/payouts/po_8b2d… -H "X-Api-Key: sp_test_…" curl https://soncopay.example/v1/payout-fees -H "X-Api-Key: sp_test_…"
const po = await sp.payouts.retrieve('po_8b2d…'); po.status; po.rail; po.tx_hash; const { fees, min_payout_usd } = await sp.payouts.fees();
$po = $sp->payouts->retrieve('po_8b2d…'); $po['status']; $fees = $sp->payouts->fees();
po = sp.payouts.retrieve("po_8b2d…") po["status"] fees = sp.payouts.fees()
وجهات السحب
Save where your money goes once, confirm it in your dashboard, then pay out with destination_id only. A stolen API key cannot add an address and empty your balance to it.
In the dashboard, these saved destinations are listed under Withdrawal methods: the Withdraw form of the dashboard only offers them, there is no field to type an address there.
| Endpoint | Description |
|---|---|
GET/v1/payout-destinations | Your destinations (filters kind and status) and the settings that apply to them. |
POST/v1/payout-destinations | Saves a destination. It starts as pending_confirmation. |
GET/v1/payout-destinations/{id} | عرض وجهة سحب |
PATCH/v1/payout-destinations/{id} | Changes the label only. New details make a new destination, to confirm again. |
DELETE/v1/payout-destinations/{id} | Disables a destination. It is kept for your history, never erased. |
الحقول حسب النوع
| Field | Description |
|---|---|
kindrequiredstring | crypto, mobile_money or bank. |
labelstring | Your own name for this destination, up to 80 characters. |
assetnetworkaddress | Crypto (required): the asset, the network and the address, checked against the network format. |
memo | Crypto: memo or tag, when the network needs one. |
methodphone | Mobile money (required): the method code, for example wave_sn or orange_cm, and the number in international format. |
operator | Mobile money: the operator, when the method needs one. |
countryholder | Mobile money, optional: the country of the number, one of the countries of the method (the number must start with its country code), and holder, the name of the account holder. |
holderbank_name | Bank (required): the account holder and the name of the bank. |
ibanaccount_number | Bank: either an IBAN, which is checked, or a local account number (8 to 34 letters and digits). |
swift_bic | Bank, optional: the SWIFT/BIC code. |
country | Bank: two-letter country code. With an IBAN, it is taken from the IBAN. |
currency | Bank (required): one of settings.bank_currencies. Mobile money: by default the currency of the method. Payouts are never converted. |
pending_confirmation. A team member confirms it in the dashboard, under Withdrawal methods, by typing their password again. An API key can never confirm a destination. Depending on the platform settings, the confirmation must come from another team member than the one who added it.Automatic confirmation: when Sonco Pay turns it on for your account, a destination added with an API key comes back active at once, with confirmed_by set to api_key:<prefix> and usable_from. It can be used for payouts only after the waiting period (the one of the platform in live mode, none in test mode), like a manual confirmation. settings.api_auto_confirm in GET /v1/payout-destinations tells whether it is on. You still receive payout_destination.created then payout_destination.confirmed, and your team is told of every address added.
Webhooks: payout_destination.confirmed when a destination is confirmed, then payout_destination.usable once it can be used for payouts. See Webhooks.
Webhooks: payout_destination.created when a destination is added (dashboard, API or app) and payout_destination.removed when it is removed or disabled, with removed_by: partner or sonco_pay.
Sonco Pay can enable or disable payout networks and methods for each account. A disabled one is not listed for your account: GET /v1/payout-fees, settings.payout_methods and settings.mobile_money_methods only list what is open to your account. Adding or confirming a destination, or a payout, on a disabled one is refused with 422 and the code payout_method_not_allowed. A destination saved before stays listed with payout_allowed: false and usable: false; automatic settlement to it waits with the reason payout_method_disabled.
Mobile money destinations: settings.mobile_money_methods lists the methods open to your account, with code, name, operator, countries, dial_codes, currencies, limits, notice and payouts. You can save a number on any listed method. When payouts is false, no payout can be sent to this method in this mode yet: a payout request to it is refused with 422 and the code payout_method_unavailable before any amount is reserved, and automatic settlement to it waits with the reason destination_not_ready (hold.state: method_unavailable). In test mode, payouts to mobile money are simulated. The phone number is encrypted at rest and only shown masked, in details.phone_masked.
Messages from Sonco Pay: settings.payout_method_notices maps a payout method (USDT:TRON, mtn_bj, bank) to a short message from our team about it, and each mobile money method has its notice (or null). Show it next to the method. A refused payout (payout_method_unavailable or payout_method_not_allowed) gives the message in detail and notice when there is one.
# 1. save it: status 'pending_confirmation' curl -X POST https://soncopay.example/v1/payout-destinations \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"kind":"crypto","asset":"USDT","network":"TRON","address":"TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE","label":"Treasury"}' # 2. a team member confirms it in the dashboard (the password is asked again) # 3. pay out to it once usable is true curl -X POST https://soncopay.example/v1/payouts \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"destination_id":"pd_5c1e…","amount":"50","reference":"demo-payout-9"}'
// 1. save it: status 'pending_confirmation' const dest = await sp.payoutDestinations.create({ kind: 'crypto', asset: 'USDT', network: 'TRON', address: 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE', label: 'Treasury', }); // 2. a team member confirms it in the dashboard (the password is asked again) // 3. pay out to it once dest.usable is true try { await sp.payouts.create({ destination_id: dest.id, amount: '50', reference: 'demo-payout-9' }); } catch (err) { if (err.code === 'destination_cooling_down') console.log(err.usableFrom); else throw err; } const { items, settings } = await sp.payoutDestinations.list({ status: 'active' }); await sp.payoutDestinations.update(dest.id, { label: 'Main wallet' }); await sp.payoutDestinations.disable(dest.id);
// mobile money destination: status 'pending_confirmation' $dest = $sp->payoutDestinations->create([ 'kind' => 'mobile_money', 'method' => 'wave_sn', 'phone' => '+221770000000', 'label' => 'Demo payouts', ]); // confirmed in the dashboard, then: try { $sp->payouts->create(['destination_id' => $dest['id'], 'amount' => '10000']); } catch (ApiException $e) { if ($e->getErrorCode() === 'destination_cooling_down') { echo $e->getUsableFrom(); } } $page = $sp->payoutDestinations->list(['kind' => 'mobile_money']); $page['settings']['cooldown_hours']; $sp->payoutDestinations->retrieve($dest['id']);
# bank account: status "pending_confirmation" dest = sp.payout_destinations.create( kind="bank", holder="Demo Store", bank_name="Demo Bank", account_number="BJ0610100100144390000769", country="BJ", currency="XOF", ) # confirmed in the dashboard, then: try: payout = sp.payouts.create(destination_id=dest["id"], amount="50000") payout["status"] # "awaiting_manual", then "completed" with bank_reference except ApiError as e: if e.code == "destination_cooling_down": print(e.usable_from) page = sp.payout_destinations.list(kind="bank") sp.payout_destinations.disable(dest["id"])
فترة الانتظار الأمنية
In live mode, a confirmed destination can be used from usable_from, at the end of a security waiting period that starts at confirmation. usable tells you whether a payout can use it now. There is no waiting period in test mode.
In a hurry? For a destination in its waiting period, the dashboard offers Ask to lift the waiting period: our team decides. The last request is in cooldown_waiver (status open, granted, refused, lapsed or cancelled, decision_reason), or null. When the waiting period is lifted, the payout_destination.usable webhook is sent.
| Status | Meaning |
|---|---|
| pending_confirmation | Saved, waiting for confirmation in the dashboard. |
| active | Confirmed. Usable from usable_from. |
| disabled | Disabled by you or by our team, kept for your history. |
| rejected | Refused by our team. |
الإعدادات التي تُعيدها القائمة
GET /v1/payout-destinations returns items and settings. These settings are set by the platform and can change: read them rather than writing them in your code.
| Setting | Meaning |
|---|---|
cooldown_hours | Waiting period after confirmation, in hours (0 in test mode). |
require_saved_destination | When true, every payout must use destination_id. |
waiver_requests | When true, a destination in its waiting period can be sent to our team with a request to lift the waiting period. |
second_confirmer | When true, another team member must confirm a destination you added. |
api_keys_can_create | When false, destinations can only be added from the dashboard. |
bank_currencies | Currencies accepted for bank transfers. |
bank_payout_feesbank_payout_min | Fee and minimum amount of a bank transfer, per currency. |
encryption_ready | When false, mobile money and bank destinations cannot be saved right now. |
البيانات المُخفاة
Full phone numbers, IBANs and account numbers are stored encrypted and never returned. details shows what you need to recognise a destination: address for crypto, phone_masked for mobile money, iban_masked or account_masked for a bank account.
{
"id": "pd_5c1e…", "object": "payout_destination", "livemode": true,
"kind": "mobile_money", "label": "Demo payouts", "currency": "XOF",
"status": "active", "usable": false, "usable_from": "2026-10-03T09:00:00+00:00",
"details": { "method_code": "wave_sn", "country": "SN", "phone_masked": "+221•••••000" },
"created_via": "api", "confirmed_at": "2026-10-02T09:00:00+00:00", …
}
رموز الأخطاء
These errors carry a stable code in the body, next to detail.
| Code | HTTP | Meaning |
|---|---|---|
destination_not_confirmed | 409 | The destination was not confirmed in the dashboard yet. |
destination_cooling_down | 409 | Confirmed, but the waiting period is not over: the body carries usable_from. |
destination_disabled | 409 | The destination is disabled. |
destination_mode_mismatch | 409 | A test destination with a live key, or the reverse. |
destination_duplicate | 409 | The same details are already saved: the body carries destination_id. |
destination_limit | 409 | 50 open destinations at most per mode. |
destination_currency_mismatch | 422 | asset differs from the currency of the destination: payouts are not converted. |
destination_required | 422 | Your account only pays out to saved destinations: send destination_id. |
destination_invalid | 422 | Invalid details: the body carries field, the field to fix. |
destination_not_found | 404 | Unknown destination. |
api_key_not_allowed | 403 | Destinations can only be added from the dashboard. |
data_key_missing | 503 | Mobile money and bank destinations cannot be saved right now. |
{
"detail": "…",
"code": "destination_cooling_down",
"usable_from": "2026-10-03T09:00:00+00:00"
}
الموافقة المتعددة
You can ask that several people of your team approve each payout before it leaves. It is not a blockchain multisig: approvals happen in Sonco Pay and apply to every payout method. It is off by default and is turned on per business in the dashboard (Settings, Signatures).
When it is on, POST /v1/payouts (API key or dashboard) answers 201 with status awaiting_approval and an approval_id. The amount and the fee are set aside at once. The payout leaves only once the quorum has signed (M out of N signers, or all of them); a signer can refuse with a reason, which blocks it. A request not signed in time becomes expired and the amount comes back to your balance.
Signers sign in the dashboard only, with a recent two-factor code: an API key can never sign, and Sonco Pay staff never sign for you. New payout destinations, the settlement mode and the signers also need the signatures. Automatic settlement keeps running without signatures only to destinations approved by the signers and within the limits they set; above, the automatic payout waits for signatures too.
Policies, as at BitGo, each with its action, ask for approval or refuse: a whitelist of destinations (a destination joins it only once approved) and velocity limits (maximum amount per payout, hour, day or week, in USD or in one asset). A payout refused by a policy answers 403 policy_denied with policies. The person who asks for a payout never counts as an approval. Once the policies are locked, changing them answers 403 policies_locked.
{
"id": "po_9ff64299628ce397f64b",
"status": "awaiting_approval",
"amount": "50", "asset": "USDT",
"approval_id": "apr_0c4428b95a8d644a20f5",
"approval": {
"status": "pending", "required": 2, "approvals": 1,
"expires_at": "2026-10-07T17:44:18Z",
"signatures": [{ "email": "[email protected]", "decision": "approve" }],
"missing": [{ "email": "[email protected]" }]
}
}
المبالغ المستردة والإلغاءات
Refund all or part of a paid payment, or cancel it and refund everything that is left. The money leaves your balance and goes back to the payer, on the method you give or on the one the payer chooses.
Refunds are off by default: Sonco Pay turns them on for your account. Until then, every refund route answers 403 with the code refunds_disabled.
The API key needs the payouts scope, like payouts (a live key with this scope needs a list of allowed IP addresses). In the dashboard, the permission refunds.create creates, cancels and previews refunds, payments.view reads them, and creating a refund asks for a recent two-factor code, like a payout.
A payment can be refunded for 30 days after it was paid (period set by Sonco Pay, window_ends_at in the refund options). Several partial refunds are allowed, up to the refundable amount.
المبلغ الذي يمكنك ردّه
At most the net_amount of the payment (what you received, the Sonco Pay fee already deducted), minus what is already refunded or in progress. The fee of the original payment is never refunded, nor an overpayment or top-up fees kept by Sonco Pay.
- The payer paid the fee (
fee_paid_bypayer): 100 USDT requested, the payer paid 100.5, you received 100. You can refund 100. - You paid the fee (
fee_paid_bymerchant): 100 USDT paid, fee 0.5, you received 99.5. You can refund 99.5.
Your balance is debited by the gross amount, in the asset of the payment (currency).
رسوم تغيير طريقة الدفع
When the payer is refunded on another method than the one used to pay, a fee is deducted from the refund. Sonco Pay sets the grid; the current values are in fee_grid of the refund options.
| Conversion | الرسوم (%) | Meaning |
|---|---|---|
same | 0 | Same asset on the same network, or the same mobile money method. |
network | 10 | Same crypto asset on another network (for example USDT BSC to USDT TRON), or a payment from an exchange account refunded on a network. |
asset | 10 | Another crypto asset. |
crypto_to_momo | 15 | Paid in crypto, refunded by mobile money. |
momo_to_crypto | 15 | Paid by mobile money, refunded in crypto. |
momo_other | 10 | Another mobile money method. |
other | 15 | Any other case, for example a bank card. |
You receive 2 points of this fee (set by Sonco Pay, partner_share), credited to your balance. 100 refunded at 10%: fee 10, 2 for you, 8 for Sonco Pay. At 15%: fee 15, 2 for you, 13 for Sonco Pay. At 0%: nothing.
net_amount is amount minus fee, converted to the asset of the payer at the rate of the moment (rate, null for the same asset). The usual network fee of a payout (network_fee) is then deducted: payer_amount is what the payer receives. Example: 100 USDT, from USDT TRON to USDT BSC (network fee 0.3): fee 10, partner_share 2, net_amount 90, payer_amount 89.7.
curl https://soncopay.example/v1/payments/pay_3f9a5c0d21e4b7a6c8d1/refund-options \
-H "X-Api-Key: sp_test_…"
const opts = await sp.payments.refundOptions('pay_3f9a5c0d21e4b7a6c8d1');
if (!opts.enabled) console.log(opts.disabled_reason); // e.g. refund_window_closed
$opts = $sp->payments->refundOptions('pay_3f9a5c0d21e4b7a6c8d1');
// $opts['refundable_amount'], $opts['fee_grid'], $opts['options']
opts = sp.payments.refund_options("pay_3f9a5c0d21e4b7a6c8d1")
# opts["refundable_amount"], opts["fee_grid"], opts["options"]
{
"object": "refund_options", "payment_id": "pay_3f9a5c0d21e4b7a6c8d1",
"enabled": true, "disabled_reason": null, "currency": "USDT",
"refundable_amount": "60", "refunded_amount": "40", "pending_amount": "0",
"window_ends_at": "2026-11-06T14:31:07+00:00", "link_expiry_hours": 72,
"delay_minutes": 30, "partner_share_points": "2",
"fee_grid": { "same": "0", "network": "10", "asset": "10", "crypto_to_momo": "15",
"momo_to_crypto": "15", "momo_other": "10", "other": "15" },
"options": [
{ "kind": "crypto", "asset": "USDT", "network": "TRON", "label": "USDT · Tron (TRC20)",
"conversion": "same", "fee_percent": "0", "payer_currency": "USDT", "network_fee": "1" },
{ "kind": "mobile_money", "method": "mtn_bj", "label": "MTN Mobile Money",
"payer_currency": "XOF", "conversion": "crypto_to_momo", "fee_percent": "15", "network_fee": "0" }
]
}
طريقتان للاسترداد
Direct (mode direct, by default): you give the destination, a crypto address (kind crypto, asset, network, address, memo) or a mobile money number (kind mobile_money, method, phone). The methods offered are in options of the refund options; mobile money appears only when mobile money payouts are available.
Back to the number that paid (kind original, nothing else to give): for a payment paid by mobile money, the refund goes back to the number that paid, through the operator, with no fee for changing method and without asking anything to the payer. When it is possible, it comes first in options. One refund of this kind is sent at a time for a payment; the next one waits for it.
Link (mode link): the payer receives a link (link_url, status awaiting_payer), chooses a method, types an address or a number and sees the fees before confirming. You send the link to the payer. It expires (link_expires_at, after link_expiry_hours): an unused link becomes expired and the amount comes back to your balance.
Cancel and refund: with cancel true, the refund covers everything that is left (amount is ignored) and kind is cancel.
Before it leaves, a refund is scheduled for a delay set by Sonco Pay (delay_minutes, send_after): you can cancel it until then. Above a threshold, the Sonco Pay team reviews it first (pending_review). If your business turned on multi-approval, it also waits for the signatures of your team (awaiting_approval). It is then sent as a payout (payout_id).
إنشاء عملية استرداد
POST/v1/refunds
| Field | Description |
|---|---|
payment_idrequiredstring | The paid payment to refund. |
amountنص أو رقم | Amount to refund, in the currency of the payment. By default, everything that is left to refund. |
cancelboolean | true cancels the payment and refunds everything that is left; amount is then ignored. |
modestring | direct (by default) or link. |
destinationobject | Required in direct mode: {"kind": "original"} (number that paid, mobile money payments), {"kind": "crypto", "asset", "network", "address", "memo"} or {"kind": "mobile_money", "method", "phone"}. |
reasonstring | The reason, kept with the refund. |
referencestring | Your reference. Sending the same reference again returns the same refund. |
metadataobject | Your own data, returned as it is. |
curl -X POST https://soncopay.example/v1/refunds \
-H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \
-d '{"payment_id":"pay_3f9a5c0d21e4b7a6c8d1","amount":"40","reference":"refund-1042",
"destination":{"kind":"crypto","asset":"USDT","network":"BSC",
"address":"0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE"}}'
const refund = await sp.refunds.create({
payment_id: 'pay_3f9a5c0d21e4b7a6c8d1', amount: '40', reference: 'refund-1042',
destination: { kind: 'crypto', asset: 'USDT', network: 'BSC',
address: '0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE' },
});
// or a mobile money number
await sp.refunds.create({ payment_id: 'pay_3f9a5c0d21e4b7a6c8d1', cancel: true,
destination: { kind: 'mobile_money', method: 'mtn_bj', phone: '+22997000001' } });
$refund = $sp->refunds->create([
'payment_id' => 'pay_3f9a5c0d21e4b7a6c8d1', 'amount' => '40', 'reference' => 'refund-1042',
'destination' => ['kind' => 'crypto', 'asset' => 'USDT', 'network' => 'BSC',
'address' => '0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE'],
]);
refund = sp.refunds.create(
payment_id="pay_3f9a5c0d21e4b7a6c8d1", amount="40", reference="refund-1042",
destination={"kind": "crypto", "asset": "USDT", "network": "BSC",
"address": "0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE"},
)
curl -X POST https://soncopay.example/v1/refunds \ -H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \ -d '{"payment_id":"pay_3f9a5c0d21e4b7a6c8d1","cancel":true,"mode":"link","reason":"Order cancelled"}' # send link_url to the payer (status awaiting_payer)
const refund = await sp.refunds.create({
payment_id: 'pay_3f9a5c0d21e4b7a6c8d1', cancel: true, mode: 'link', reason: 'Order cancelled',
});
sendToPayer(refund.link_url, refund.link_expires_at);
$refund = $sp->refunds->create([
'payment_id' => 'pay_3f9a5c0d21e4b7a6c8d1', 'cancel' => true, 'mode' => 'link', 'reason' => 'Order cancelled',
]);
// send $refund['link_url'] to the payer, valid until $refund['link_expires_at']
refund = sp.refunds.create(
payment_id="pay_3f9a5c0d21e4b7a6c8d1", cancel=True, mode="link", reason="Order cancelled",
)
# send refund["link_url"] to the payer, valid until refund["link_expires_at"]
{
"id": "rf_7c21d4a9e0b35f86a1c2", "object": "refund", "livemode": false,
"payment_id": "pay_3f9a5c0d21e4b7a6c8d1", "kind": "refund", "mode": "direct",
"status": "scheduled", "currency": "USDT", "amount": "40",
"conversion": "network", "fee_percent": "10", "fee": "4", "partner_share": "0.8",
"net_amount": "36",
"destination": { "kind": "crypto", "asset": "USDT", "network": "BSC",
"address": "0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE", "memo": null,
"method": null, "label": "USDT · BNB Smart Chain (BEP20)" },
"payer_currency": "USDT", "rate": null, "network_fee": "0.3", "payer_amount": "35.7",
"link_url": null, "link_expires_at": null,
"send_after": "2026-10-07T15:00:00+00:00", "payout_id": null,
"reason": null, "reference": "refund-1042", "metadata": {}, "error": null,
"history": [{ "status": "scheduled", "at": "2026-10-07T14:30:00+00:00" }],
"created_at": "2026-10-07T14:30:00+00:00", "updated_at": "2026-10-07T14:30:00+00:00",
"completed_at": null
}
نقاط نهاية الاسترداد
| Endpoint | Description |
|---|---|
POST/v1/refunds | إنشاء عملية استرداد |
GET/v1/refunds | عرض قائمة عمليات الاسترداد |
GET/v1/refunds/{id} | قراءة عملية استرداد |
POST/v1/refunds/{id}/cancel | إلغاء عملية استرداد |
POST/v1/refunds/preview | معاينة عملية استرداد |
GET/v1/payments/{id}/refund-options | خيارات الاسترداد لدفعة ما |
GET /v1/refunds accepts payment_id, status, limit (50 by default) and offset, and answers items and has_more.
POST /v1/refunds/preview takes payment_id, amount, cancel and a destination without address (kind, asset and network, or kind mobile_money and method). It creates nothing and answers the amounts: refundable_amount, conversion, fee_percent, fee, partner_share, net_amount, payer_currency, rate, network_fee, payer_amount, minimum and estimated.
GET /v1/payments/{id}/refund-options says whether the payment can be refunded (enabled, otherwise disabled_reason: refunds_disabled, payment_not_refundable, refund_window_closed or nothing_left), with refundable_amount, refunded_amount, pending_amount, window_ends_at, link_expiry_hours, delay_minutes, partner_share_points, fee_grid and the options offered.
POST /v1/refunds/{id}/cancel (with an optional reason) works only before the refund leaves (awaiting_payer, scheduled, pending_review, awaiting_approval); otherwise 409 refund_not_cancellable. The amount comes back to your balance.
curl -X POST https://soncopay.example/v1/refunds/preview \
-H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \
-d '{"payment_id":"pay_3f9a5c0d21e4b7a6c8d1","amount":"100",
"destination":{"kind":"crypto","asset":"USDT","network":"BSC"}}'
const quote = await sp.refunds.preview({
payment_id: 'pay_3f9a5c0d21e4b7a6c8d1', amount: '100',
destination: { kind: 'crypto', asset: 'USDT', network: 'BSC' },
});
// quote.fee, quote.partner_share, quote.payer_amount
$quote = $sp->refunds->preview([
'payment_id' => 'pay_3f9a5c0d21e4b7a6c8d1', 'amount' => '100',
'destination' => ['kind' => 'mobile_money', 'method' => 'mtn_bj'],
]);
quote = sp.refunds.preview(
payment_id="pay_3f9a5c0d21e4b7a6c8d1", amount="100",
destination={"kind": "crypto", "asset": "USDT", "network": "BSC"},
)
{
"object": "refund_preview", "payment_id": "pay_3f9a5c0d21e4b7a6c8d1",
"currency": "USDT", "amount": "100", "refundable_amount": "100",
"conversion": "network", "fee_percent": "10", "fee": "10", "partner_share": "2",
"net_amount": "90", "payer_currency": "USDT", "rate": null,
"network_fee": "0.3", "payer_amount": "89.7", "minimum": "1", "estimated": false
}
curl -X POST https://soncopay.example/v1/refunds/rf_7c21d4a9e0b35f86a1c2/cancel \
-H "X-Api-Key: sp_test_…" -H "Content-Type: application/json" \
-d '{"reason":"Customer kept the order"}'
const r = await sp.refunds.cancel('rf_7c21d4a9e0b35f86a1c2', { reason: 'Customer kept the order' });
// r.status === 'cancelled'; 409 refund_not_cancellable once it has left
$r = $sp->refunds->cancel('rf_7c21d4a9e0b35f86a1c2', ['reason' => 'Customer kept the order']);
r = sp.refunds.cancel("rf_7c21d4a9e0b35f86a1c2", reason="Customer kept the order")
كائن الاسترداد
| Field | Description |
|---|---|
id | Identifier of the refund, starting with rf_. |
payment_id | The refunded payment. |
kind | refund, or cancel for a cancellation. |
mode | direct or link. |
status | See the refund statuses below. |
currency, amount | Amount debited from your balance, in the asset of the payment. |
conversion, fee_percent, fee | The change of method and the fee deducted from the refund. |
partner_share | Your share of the fee, credited to your balance. |
net_amount | amount minus fee. |
destination | Where the refund goes, with a label; null while the link has not been used. |
payer_currency, rate, network_fee, payer_amount | What the payer receives, in payer_currency, after conversion and network fee. |
link_url, link_expires_at | Link mode: the link for the payer, while the status is awaiting_payer. |
send_after | When the refund leaves, at the earliest. |
payout_id | The payout that carries the refund, once it is sent. |
reason, reference, metadata | Your data, as you sent it. |
error | Why the refund failed, otherwise null. |
history | Each change of status, with its date. |
created_at, updated_at, completed_at | Dates of creation, of the last change and of completion. |
حالات الاسترداد
| Status | Meaning |
|---|---|
| awaiting_payer | The link was sent; the payer chooses a method. |
| scheduled | Leaves after the delay set by Sonco Pay. You can still cancel it. |
| pending_review | Above a threshold, the Sonco Pay team reviews the refund before it is sent. |
| awaiting_approval | Waits for the signatures of your team (multi-approval). |
| sent | Sent to the payer. |
| completed | Received by the payer. |
| failed | The refund failed; the amount is back in your balance. |
| cancelled | Cancelled before it left; the amount is back in your balance. |
| expired | The link was not used in time; the amount is back in your balance. |
The payment: after a completed refund, its status becomes partially_refunded or refunded, and refunded_amount gives the total refunded.
أحداث الاسترداد
Signed like every other event, with the same headers. The data of the refund.* events is the refund object.
| Event | When |
|---|---|
refund.created | A refund was created. |
refund.scheduled, refund.pending_review, refund.awaiting_approval | The refund waits before it leaves: delay, review by our team or signatures of your team. |
refund.sent | The refund was sent to the payer. |
refund.completed | The payer received the refund. |
refund.failed, refund.cancelled, refund.expired | The refund failed, was cancelled, or its link expired; the amount is back in your balance. |
payment.refunded | A refund of the payment is completed: data is the payment, with refunded_amount and refund (the completed refund). |
أخطاء الاسترداد
| Code | Meaning |
|---|---|
403 refunds_disabled | Refunds are not turned on for your account. |
409 payment_not_refundable | The payment is not paid, or it cannot be refunded. |
409 refund_window_closed | The refund period of this payment is over. |
422 refund_amount_too_high | More than what is left to refund (the response gives refundable_amount). |
422 refund_amount_invalid | The amount is not valid. |
422 refund_insufficient_balance | Your balance does not cover the refund. |
409 payment_already_withdrawn | The money of this payment was already withdrawn, in whole or in part: it can no longer be refunded. |
429 refund_velocity_exceeded | Too many refunds in a short time. |
422 destination_required | Direct mode without a destination. |
422 destination_invalid | The address or the number is not valid. |
422 refund_method_unavailable | This method cannot be used for a refund at the moment. |
422 refund_below_minimum | What the payer would receive is below the minimum. |
422 refund_above_maximum | Above the maximum of the operator for a refund to the original number (the response gives maximum): refund in several parts. |
503 / 403 refunds_paused | Refunds are paused for the moment, for every account (503) or for yours (403). Refunds already created wait and leave when they open again. |
409 refund_not_cancellable | The refund has already left, or it is over. |
404 refund_not_found | No refund with this identifier in this mode. |
{
"event": "payment.refunded",
"created_at": "2026-10-07T15:12:40+00:00",
"data": {
"id": "pay_3f9a5c0d21e4b7a6c8d1", "status": "partially_refunded",
"currency": "USDT", "net_amount": "100", "refunded_amount": "40",
"refund": { "id": "rf_7c21d4a9e0b35f86a1c2", "object": "refund", "status": "completed",
"amount": "40", "payer_amount": "35.7", … },
…
}
}
{
"detail": "…",
"code": "refunds_disabled"
}
أوضاع التسوية
Your account is in one of two settlement modes. You choose it in the dashboard (Settings, password required), unless Sonco Pay has locked the mode of your account:
- Custody (default): each paid payment is credited to your balance, minus the fee. You withdraw when you want.
- Automatic: each paid payment is credited, then its net amount is sent automatically to your settlement destination for that currency, as a normal payout (payout fee, review above a threshold, same statuses and webhooks). One payment gives at most one automatic payout; small amounts add up until they reach the minimum payout.
Choose a settlement destination for each currency (USDT, XOF…) or for a currency on one network (USDT:TRON, which wins over USDT) among your confirmed payout destinations, in the dashboard or with PUT /v1/settlement/routes. Without a usable destination, or when a limit or a block applies, the amount stays in your balance and the settlement waits; the reason is given in GET /v1/settlement and in the payment timeline.
GET /v1/payments/{id} carries settlement: mode, status (pending, held, settled, failed, cancelled), reason and payout_id. The payment.paid webhook carries settlement.mode; when the payout is created you receive payment.settled, then the usual payout.* webhooks. Payouts carry origin: request or settlement.
When settlement goes on hold, the payment.settlement_held webhook gives the reason and what to do, once per hold. See Webhooks.
GET /v1/settlement also tells whether you can change the mode yourself: locked, can_change and blocked_by (locked or platform). Turning on automatic settlement needs a usable settlement destination; the change applies to payments paid after it, and the account owners receive a security email.
curl -X PUT https://soncopay.example/v1/settlement/routes \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"scope":"USDT","destination_id":"pd_3c1e…"}'
{
"event": "payment.settled",
"data": {
"id": "pay_3f9a…", "status": "paid", "net_amount": "24.8886",
"settlement": {
"mode": "auto", "status": "settled",
"payout_id": "po_7b2d…", "payout_amount": "23.8886",
"payout_fee": "1", "asset": "USDT"
}, …
}
}
Timelines
GET/v1/payments/{id}/timeline
GET/v1/payouts/{id}/timeline
The steps of a payment or a payout, in order, with their time and the status after each step. A timeline shows no internal detail: give its trace_id to our support when you ask about an operation.
step is a stable code: translate it in your interface. label is an English text, status the status after the step and data the useful public references (amounts, method, transaction hash).
مراحل الدفعة
| Step | Meaning |
|---|---|
created | Created |
method_selected | تم اختيار وسيلة الدفع |
awaiting_customer | في انتظار العميل |
attempt_failed | تم رفض المحاولة |
confirming | تم رصد التحويل، جارٍ التأكيد |
deposit_attributed | طابق فريقنا التحويل |
paid | تم الدفع والإضافة إلى الرصيد |
expired | Expired |
failed | Failed |
webhook_sent | تم تسليم الإشعار |
webhook_failed | لم يتم تسليم الإشعار |
مراحل السحب
| Step | Meaning |
|---|---|
requested | تم طلب السحب |
under_review | قيد المراجعة |
approved | Approved |
rejected | Rejected |
submitted | أُرسل للمعالجة |
sent | تم القبول للإرسال |
unknown | قيد التحقق من فريقنا |
completed | Completed |
failed | Failed |
webhook_sent | تم تسليم الإشعار |
webhook_failed | لم يتم تسليم الإشعار |
curl https://soncopay.example/v1/payouts/po_8b2d…/timeline -H "X-Api-Key: sp_test_…" # or /v1/payments/{id}/timeline
const tl = await sp.payouts.timeline(payout.id); // or sp.payments.timeline(payment.id) for (const e of tl.events) console.log(e.occurred_at, e.step, e.status);
$tl = $sp->payouts->timeline($payout['id']); // or $sp->payments->timeline($id) foreach ($tl['events'] as $e) { echo $e['occurred_at'], ' ', $e['step'], PHP_EOL; }
tl = sp.payouts.timeline(payout["id"]) # or sp.payments.timeline(payment_id) for e in tl["events"]: print(e["occurred_at"], e["step"], e["status"])
{
"object": "timeline",
"subject": { "type": "payout", "id": "po_8b2d…", "status": "completed" },
"livemode": true, "trace_id": "4f0c…",
"events": [
{ "step": "requested", "label": "Payout requested", "status": "queued",
"occurred_at": "2026-10-02T09:00:00+00:00", "data": { "amount": "50", "fee": "1", "asset": "USDT" } },
{ "step": "submitted", "label": "Sent for processing", "status": "submitting", … },
{ "step": "completed", "label": "Completed", "status": "completed", "data": { "tx_hash": "…" } }
]
}
Statements
GET/v1/statements
GET/v1/statements.csv
Your account statement per currency, read from our double entry books: the opening balance, every line with the balance after it, and the closing balance. The opening balance plus the lines always equals the closing balance.
| Parameter | Description |
|---|---|
currency | One currency, for example USDT. By default, every currency of your account. |
from | Start of the period: YYYY-MM-DD or ISO 8601. |
to | End of the period, included: YYYY-MM-DD or ISO 8601. |
limit | From 1 to 1000. Default: 200. |
cursor | The next_cursor of the previous page, while it is not null. |
بنود الكشف
| Field | Description |
|---|---|
id | ID of the accounting line. |
date | Posting time, ISO 8601. |
type | payment, fee, payout, payout_fee, payout_release or adjustment. |
label | Stable English label, for example Payment received: translate it in your interface. |
description | Reason of an adjustment, when there is one. |
amount | Signed amount: positive when it credits your balance, negative when it debits it. |
balance_after | Balance of the currency after this line. |
operation | The related payment or payout (type and id), or null. |
GET /v1/statements.csv takes the same currency, from and to and returns the whole period as CSV, with the columns date, currency, type, label, description, amount, balance_after, operation_type, operation_id and line_id.
curl "https://soncopay.example/v1/statements?currency=USDT&from=2026-10-01&to=2026-10-31" \ -H "X-Api-Key: sp_test_…" curl "https://soncopay.example/v1/statements.csv?currency=USDT&from=2026-10-01" \ -H "X-Api-Key: sp_test_…" -o statement.csv
const st = await sp.statements.list({ currency: 'USDT', from: '2026-10-01', to: '2026-10-31' }); st.opening; st.closing; for await (const line of sp.statements.listAll({ currency: 'USDT', from: '2026-10-01' })) { // follows next_cursor for you } const csv = await sp.statements.csv({ currency: 'USDT', from: '2026-10-01', to: '2026-10-31' });
$st = $sp->statements->list(['currency' => 'USDT', 'from' => '2026-10-01', 'to' => '2026-10-31']); foreach ($sp->statements->listAll(['currency' => 'USDT']) as $line) { // follows next_cursor for you } $csv = $sp->statements->csv(['currency' => 'USDT', 'from' => '2026-10-01']);
st = sp.statements.list(currency="USDT", from_="2026-10-01", to="2026-10-31") for line in sp.statements.list_all(currency="USDT", from_="2026-10-01"): pass # follows next_cursor for you csv = sp.statements.csv(currency="USDT", from_="2026-10-01", to="2026-10-31")
{
"livemode": true, "currency": "USDT",
"from": "2026-10-01T00:00:00+00:00", "to": "2026-11-01T00:00:00+00:00",
"currencies": ["USDT"],
"opening": { "USDT": "100" },
"lines": [
{ "id": 5120, "date": "2026-10-02T09:12:40+00:00", "currency": "USDT",
"type": "payment", "label": "Payment received", "description": null,
"amount": "25.0137", "balance_after": "125.0137",
"operation": { "type": "payment", "id": "pay_3f9a…" } },
…
],
"closing": { "USDT": "124.8886" },
"next_cursor": null
}
الفواتير والاشتراكات
POST/v1/invoices
POST /v1/invoices creates a draft (issue: true gives it a number, send: true also sends it). Lines carry description, quantity, unit_amount and an optional tax_rate (percent). The customer pays on hosted_url (/i/… short link in SMS) with every active method; each payment follows the usual flow (credit, commission, settlement).
Statuses: draft, open, partially_paid (with allow_partial), overdue, paid, void. Actions: /issue, /send, /remind (429 reminder_too_soon), /void, /mark-paid (paid outside Sonco Pay), /timeline and /pdf.
إنشاء اشتراك
POST/v1/subscriptions
A subscription creates one invoice per due date (interval: week, month, quarter, year or custom with interval_days), a few days in advance, then reminds the customer before the due date (reminders.days_before, for example 7, 3 and 1), on the day and after it (after_due). An unpaid invoice makes the subscription unpaid; after dunning.grace_days it is canceled, paused or kept, as you choose.
Automatic card debit is not available yet: auto_debit: true fails with auto_debit_unavailable. Card, crypto, mobile money and Binance Pay are paid from the invoice link. Reminders go by email, and by SMS or WhatsApp only to customers who agreed (consent); a STOP reply opts them out.
Creations accept the Idempotency-Key header (24 hours; the same key with another body returns 409 idempotency_key_reused) or an external_ref. Lists return items, has_more and next_offset. In test mode, POST /v1/billing/test-clock moves time forward to try due dates and reminders.
curl -X POST https://soncopay.example/v1/invoices \ -H "X-Api-Key: sp_test_…" \ -H "Idempotency-Key: demo-invoice-1042" \ -H "Content-Type: application/json" \ -d '{"customer":{"name":"Demo Customer","email":"[email protected]","phone":"+2250700000000", "consent":{"email":true,"sms":true}},"currency":"XOF","due_days":7, "lines":[{"description":"Demo service","quantity":1,"unit_amount":"15000"}],"send":true}'
const invoice = await sp.invoices.create({ customer: { name: 'Demo Customer', email: '[email protected]', phone: '+2250700000000' }, currency: 'XOF', due_days: 7, send: true, lines: [{ description: 'Demo service', quantity: 1, unit_amount: '15000' }], }, { idempotencyKey: 'demo-invoice-1042' }); invoice.hosted_url;
$invoice = $sp->invoices->create([
'customer' => ['name' => 'Demo Customer', 'email' => '[email protected]'],
'currency' => 'XOF', 'due_days' => 7, 'send' => true,
'lines' => [['description' => 'Demo service', 'quantity' => 1, 'unit_amount' => '15000']],
], ['idempotency_key' => 'demo-invoice-1042']);
$invoice['hosted_url'];
invoice = sp.invoices.create(
customer={"name": "Demo Customer", "email": "[email protected]"},
currency="XOF", due_days=7, send=True,
lines=[{"description": "Demo service", "quantity": 1, "unit_amount": "15000"}],
idempotency_key="demo-invoice-1042",
)
invoice["hosted_url"]
curl -X POST https://soncopay.example/v1/subscriptions \ -H "X-Api-Key: sp_test_…" \ -H "Content-Type: application/json" \ -d '{"customer_id":"cus_…","description":"Demo monthly plan","amount":"10000","currency":"XOF", "interval":"month","preferred_method":"mobile_money","reminders":{"days_before":[7,3,1]}, "dunning":{"grace_days":7,"action":"pause"}}'
const sub = await sp.subscriptions.create({ customer_id: customer.id, description: 'Demo monthly plan', amount: '10000', currency: 'XOF', interval: 'month', preferred_method: 'mobile_money', reminders: { days_before: [7, 3, 1] }, dunning: { grace_days: 7, action: 'pause' }, }); await sp.billing.advanceTestClock({ advance_days: 30 }); // test mode
$sub = $sp->subscriptions->create([
'customer_id' => $customer['id'], 'description' => 'Demo monthly plan',
'amount' => '10000', 'currency' => 'XOF', 'interval' => 'month',
'reminders' => ['days_before' => [7, 3, 1]], 'dunning' => ['grace_days' => 7, 'action' => 'pause'],
]);
sub = sp.subscriptions.create(
customer_id=customer["id"], description="Demo monthly plan", amount=10000, currency="XOF",
interval="month", reminders={"days_before": [7, 3, 1]}, dunning={"grace_days": 7, "action": "pause"},
)
sp.billing.advance_test_clock(days=30) # test mode
Webhooks
Set your webhook URL in the dashboard. We send a POST with a JSON body for each event, and retry for about three days until your server answers with a 2xx status.
One webhook per API key: each API key can have its own webhook URL and its own signing secret (dashboard, API keys, open the key). Events of an object created with a key (payment, invoice, subscription, payout, refund, payout destination) go to the URL of that key; without a URL on the key, they go to the URL of your account.
Order used for each event: the callback_url of the payment, then the webhook of the key that created the object, then the webhook of your account. Account events (verification, settlement, destinations added in the dashboard…) go to the webhook of your account. A test key only receives test events. The option Also receive every other event of the business sends a key a copy of the other events of its mode; an address never receives the same event twice. When a key is revoked, its next events go to the webhook of your account.
| Event | When |
|---|---|
payment.confirming | A deposit was detected and is being confirmed. |
payment.paid | The payment is confirmed. Fulfil the order. |
payment.settled | Automatic settlement: the payout of this payment was created (settlement.payout_id). |
payment.settlement_held | Automatic settlement of this payment is on hold: settlement.reason, settlement.detail, settlement.action (what to do) and settlement.destination when an address is concerned. |
payment.underpaid | Crypto on an address reserved for the payment: less than the amount due arrived. status is underpaid; the customer is asked to send amount_remaining (also in next_action.amount) to the same address before expires_at. Do not fulfil the order yet. |
payment.wrong_asset | Crypto on an address reserved for the payment: another asset, or the same asset on another network, arrived. The payment carries wrong_asset; expected and received (asset, network, amount, tx_hash) are added. Our team handles it: do not fulfil the order yet. If the payment is accepted, payment.paid follows as usual. |
payment.attempt_failed | A mobile money request or a card payment was declined: the payment is back to new with last_error; the customer can try again or choose another method. |
payment.failed | Binance Pay paid with a wrong amount: the payment is failed. |
payment.expired | The payment was not made in time. After a partial crypto payment, status is partially_paid: the amount received is kept and our team can validate the payment or return the funds. |
payout.sent | The money has left our wallet (automatic settlement included): the transaction is broadcast and tx_hash is filled in for crypto. payout.completed follows once it is confirmed. |
payout.completed | The payout is done: tx_hash (crypto) or bank_reference (bank transfer) is filled in. |
payout.failed | The payout failed or was rejected; the amount is back in your balance. |
payout.awaiting_approval | A payout is waiting for the signatures of your team (approval gives the request). |
payout.approved | The signers approved the payout: it is now sent as usual. |
payout.rejected | A signer refused the payout, or it was cancelled; the amount is back in your balance (approval.reason). |
pendingapproval | A single event for every request to approve (payouts, destinations, policies) at each change of state: type, state (pending, approved, rejected, expired, cancelled), triggered (policies), required, approvals. |
payout.expired | The payout was not signed in time; the amount is back in your balance. |
refund.* | A refund changed status: created, scheduled, pending_review, awaiting_approval, sent, completed, failed, cancelled or expired (data is the refund). See Refund events. |
payment.refunded | A refund of the payment is completed: data is the payment, with refunded_amount and refund (the completed refund). |
invoice.created, invoice.sent, invoice.reminder_sent, invoice.partially_paid, invoice.paid, invoice.overdue, invoice.voided | An invoice was created, sent, reminded, partly paid, paid, became overdue or was voided. |
subscription.created, subscription.updated, subscription.paused, subscription.resumed, subscription.unpaid, subscription.canceled, subscription.ended | A subscription was created, updated, paused, resumed, became unpaid, was canceled or ended. |
payout_destination.created | A payout destination was added (dashboard, API key or app). data is the destination, details masked, with the status pending_confirmation. |
payout_destination.confirmed | A payout destination was confirmed in the dashboard. data is the destination, details masked; usable_at is the end of its waiting period. |
payout_destination.usable | A confirmed payout destination can now be used: right after the confirmation when there is no waiting period, otherwise when the waiting period ends. |
payout_destination.removed | A payout destination was removed or disabled. removed_by is partner (your team or an API key) or sonco_pay (our team), with removed_at and reason. |
ping | Sent when you test your webhook from the dashboard. |
Payout events (payout.sent, payout.completed, payout.failed) carry the payout, with from_address when it is known. In payment.settled, settlement.payout_from_address is usually null because the payout has just been created: payout.sent brings the address. Each payout_destination.* event is sent once per destination; a retry keeps the same X-SoncoPay-Delivery-Id.
payment.settlement_held is sent once each time a payment goes on hold: the same hold checked again sends nothing, a new reason sends a new event. Reasons: no_destination, destination_not_ready, below_minimum, daily_cap, network_blocked, payouts_blocked, kyb_required, merchant_suspended, payout_refused, multisig_unreachable, payout_method_disabled, disabled. When the payout is finally created you receive payment.settled.
Headers
| Header | Description |
|---|---|
X-SoncoPay-Signature | The signature. Timestamped format t=…,v1=… for new accounts and for accounts that switched in the dashboard; otherwise the legacy format, HMAC SHA512 of the raw body in hexadecimal. See Verify a signature. |
X-SoncoPay-Signature-V2 | Timestamped signature, sent while your account uses the legacy format. |
X-SoncoPay-Timestamp | Unix time of this attempt, in seconds. |
X-SoncoPay-Delivery-Id | Identifier of the delivery, the same on every retry: ignore a delivery you already processed. |
X-SoncoPay-Event | The event name, also present in the body. |
Content-Type | application/json |
{
"event": "payment.paid",
"created_at": "2026-10-01T14:31:07+00:00",
"data": {
"id": "pay_3f9a…", "order_id": "1042", "status": "paid",
"received_amount": "25.0137", "asset": "USDT",
"fee": "0.1251", "net_amount": "24.8886",
"fee_paid_by": "merchant", "amount_due": "25.0137",
"payer": { "email": "[email protected]" },
"settlement": { "mode": "custody", "status": null, "payout_id": null },
"late": false, …
}
}
{
"event": "payout.sent",
"created_at": "2026-10-11T09:12:44+00:00",
"data": {
"id": "po_8b2d…", "object": "payout", "status": "sent",
"asset": "USDT", "network": "TRON", "amount": "250", "fee": "1",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"tx_hash": "4f1c…", "from_address": "TXa1…", …
}
}
{
"event": "payout_destination.usable",
"created_at": "2026-10-12T09:00:31+00:00",
"data": {
"id": "pd_5c1e…", "object": "payout_destination", "livemode": true,
"kind": "crypto", "label": "Main wallet", "currency": "USDT",
"status": "active", "usable": true,
"details": { "asset": "USDT", "network": "TRON", "network_name": "Tron (TRC20)",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", "memo": null },
"confirmed_at": "2026-10-11T09:00:31+00:00",
"usable_at": "2026-10-12T09:00:31+00:00", "created_at": "2026-10-11T08:58:02+00:00"
}
}
{
"event": "payout_destination.created",
"created_at": "2026-10-11T08:58:02+00:00",
"data": {
"id": "pd_5c1e…", "object": "payout_destination", "livemode": true,
"kind": "mobile_money", "label": "Shop phone", "currency": "XOF",
"status": "pending_confirmation", "usable": false,
"details": { "method_code": "mtn_bj", "method_name": "MTN MoMo Benin",
"operator": "MTN", "country": "BJ", "phone_masked": "+229 •••• 0002" },
"confirmed_at": null, "usable_at": null,
"created_at": "2026-10-11T08:58:02+00:00"
}
}
{
"event": "payout_destination.removed",
"created_at": "2026-10-14T16:20:09+00:00",
"data": {
"id": "pd_5c1e…", "object": "payout_destination", "livemode": true,
"kind": "crypto", "label": "Main wallet", "currency": "USDT",
"status": "disabled", "usable": false,
"details": { "asset": "USDT", "network": "TRON", "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", … },
"removed_by": "partner", "removed_at": "2026-10-14T16:20:09+00:00",
"reason": null, …
}
}
{
"event": "payment.settlement_held",
"created_at": "2026-10-12T10:04:51+00:00",
"data": {
"id": "pay_3f9a…", "object": "payment", "status": "paid",
"net_amount": "24.8886", "asset": "USDT", …,
"settlement": {
"mode": "auto", "status": "held",
"reason": "destination_not_ready",
"detail": "Your settlement address can be used from 2026-10-13 09:00 UTC (security waiting period).",
"action": { "code": "confirm_destination",
"message": "Confirm the settlement address, or wait for the end of its security waiting period: settlement then resumes on its own." },
"item_id": "st_91aa…", "amount": "24.8886", "asset": "USDT", "network": "TRON",
"hold": { "state": "waiting_period", "usable_from": "2026-10-13T09:00:00+00:00", "accumulated": "24.8886" },
"next_attempt_at": "2026-10-13T09:00:05+00:00",
"destination": { "id": "pd_5c1e…", "object": "payout_destination", "status": "active", … }
}
}
}
التحقق من التوقيع
Each webhook carries a timestamped signature t=<timestamp>,v1=<signature>: v1 is the HMAC SHA256, in hexadecimal, of the timestamp, a dot and the raw request body, keyed with your webhook signing secret. Compute it on the raw body, before parsing the JSON, compare in constant time, and refuse a timestamp more than 5 minutes away from your clock.
A webhook sent to the URL of an API key is signed with the signing secret of that key, not the secret of your account, and carries X-SoncoPay-Key: the public prefix of the key. A callback_url is signed with the secret of the key that created the payment when that key has its own webhook. With the SDKs, pass the matching secret to constructEvent (construct_event in Python).
Migration: accounts created before October 6, 2026 keep the legacy format in X-SoncoPay-Signature (HMAC SHA512 of the raw body) and receive the timestamped signature in X-SoncoPay-Signature-V2. Install SDK 2.5.0, which checks both, then choose Timestamped in the dashboard under Developers, Webhooks. After the switch, only the timestamped signature is sent: the legacy one has no timestamp and would let a captured webhook be replayed.
GET /v1/payments/{id} before shipping goods of high value.const crypto = require("crypto"); // X-SoncoPay-Signature: t=1700000000,v1=… (accounts on the legacy format: X-SoncoPay-Signature-V2) const header = req.headers["x-soncopay-signature-v2"] || req.headers["x-soncopay-signature"] || ""; const sig = Object.fromEntries(header.split(",").map((p) => p.split("="))); const expected = crypto.createHmac("sha256", process.env.SP_WEBHOOK_SECRET).update(sig.t + ".").update(rawBody).digest("hex"); const ok = Math.abs(Date.now() / 1000 - Number(sig.t)) <= 300 && String(sig.v1).length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(String(sig.v1)));
// X-SoncoPay-Signature: t=1700000000,v1=… (accounts on the legacy format: X-SoncoPay-Signature-V2) $header = $_SERVER['HTTP_X_SONCOPAY_SIGNATURE_V2'] ?? $_SERVER['HTTP_X_SONCOPAY_SIGNATURE'] ?? ''; parse_str(str_replace(',', '&', $header), $sig); $expected = hash_hmac('sha256', ($sig['t'] ?? '') . '.' . file_get_contents('php://input'), getenv('SP_WEBHOOK_SECRET')); $ok = abs(time() - (int) ($sig['t'] ?? 0)) <= 300 && hash_equals($expected, (string) ($sig['v1'] ?? ''));
import hmac, hashlib, time # X-SoncoPay-Signature: t=1700000000,v1=… (accounts on the legacy format: X-SoncoPay-Signature-V2) header = request.headers.get("X-SoncoPay-Signature-V2") or request.headers.get("X-SoncoPay-Signature", "") sig = dict(p.split("=", 1) for p in header.split(",") if "=" in p) expected = hmac.new(secret.encode(), f"{sig.get('t')}.".encode() + raw_body, hashlib.sha256).hexdigest() ok = abs(time.time() - int(sig.get("t", 0))) <= 300 and hmac.compare_digest(expected, sig.get("v1", ""))
Errors
Errors use standard HTTP codes and a JSON body {"detail": "…"}. Some errors also carry a stable code that you can test in your code: {"detail": "…", "code": "kyb_required"}.
| Code | Meaning |
|---|---|
401 | Missing or invalid API key. |
403 | Account suspended, payments or payouts blocked for your account, missing permission (permission_denied), or live mode before your business verification is approved (kyb_required). |
404 | Payment or payout not found in this mode. |
409 | Conflict: payment expired, already paid, or order_id reused with another amount. |
429 | Too many mobile money attempts for this payment. |
422 | Invalid input, unsupported currency, amount below the minimum, insufficient balance. |
422 provider_refused | The provider refused to start the payment (card, mobile money or Binance Pay). The detail gives its reason. Nothing was charged: choose another method or retry later. |
502 | A payment provider or the exchange rate is temporarily unavailable. Retry later. |
503 | Payments or payouts are temporarily closed, or the service is under maintenance: the body then carries "maintenance": true and a Retry-After header. Retry later. |
API keys: api_key_scope (the key does not have the scope of this route) and api_key_ip_not_allowed (address outside the allowlist of the key), both 403. Payouts: destination_required (422) and payout_velocity_exceeded (429). Payments: return_url_invalid (422, https only in live mode).
Payment methods: method_not_allowed (422, the method is not enabled for your account; contact support to enable it) and pair_disabled (422, this asset and network are not offered at the moment).
Payout methods: payout_method_not_allowed (422, payouts to this network or method are not enabled for your account; contact support to enable it) and payout_method_unavailable (422, the method is open to your account but payouts to it are not available yet; nothing is reserved). The body gives the key in method (USDT:TRON, mtn_bj, bank) and, when our team has written one, a message in notice.
Refund errors are listed in Refunds.
Error messages (detail, last_error, the error of a payout) never name our internal processors. Payout destination errors are listed in Payout destinations.
{
"detail": "…",
"code": "kyb_required"
}