Countries
One page per country and payment channel: channels, limits, KYC rules, quirks and API examples.
Each country page lists its payment channels, its quirks, how to verify a user, and its limits, KYC rules and fees. Each payment channel has its own page that walks through a real order, with the country values filled in.
West Africa
Central Africa
Southern Africa
Latin America
South East Asia
The crypto networks and assets are on Supported countries and cryptocurrencies.
Before you start
Keys. Sandbox and production are separate systems with separate keys. The examples call sandbox,
https://sandbox-api.fonbnk.com. SwitchFONBNK_BASE_URLtohttps://api.fonbnk.comand your production keys to go live. See Servers.The create-users permission. Get user KYC state, Submit user KYC, Create order and Confirm order answer
403without it, even when quotes work. Ask support to switch it on.A webhook URL in the merchant dashboard. The order statuses arrive there. See Webhooks.
A unique
orderParamsfor each order. It is your own reference. You need it to recover from a timeout, see "Retries and errors" below.
Every call is signed as Signing requests explains. The examples on the country pages use these helpers:
export FONBNK_BASE_URL='https://sandbox-api.fonbnk.com' # https://api.fonbnk.com in production
export FONBNK_CLIENT_ID='<your client id>'
export FONBNK_CLIENT_SECRET='<your api secret>'
# Prints the x-signature of one request: HMAC-SHA256 over "timestamp:endpoint", base64.
fonbnk_sign() {
local key_hex
key_hex=$(printf '%s' "$FONBNK_CLIENT_SECRET" | base64 --decode | xxd -p -c 256)
printf '%s' "$1:$2" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$key_hex" -binary | base64
}import crypto from 'node:crypto';
const BASE_URL = process.env.FONBNK_BASE_URL ?? 'https://sandbox-api.fonbnk.com';
const CLIENT_ID = process.env.FONBNK_CLIENT_ID ?? '';
const CLIENT_SECRET = process.env.FONBNK_CLIENT_SECRET ?? '';
/**
* Signs and sends one Merchant API call. `endpoint` is the path and the query string.
* Throws on a non-2xx answer, with the error body, so the caller can read `errorCode`.
* Do not retry Create order blindly on a timeout: see "Retries and errors" below.
*/
export const fonbnkRequest = async (method: 'GET' | 'POST', endpoint: string, body?: unknown) => {
const timestamp = Date.now().toString();
const signature = crypto
.createHmac('sha256', Buffer.from(CLIENT_SECRET, 'base64'))
.update(`${timestamp}:${endpoint}`)
.digest('base64');
const response = await fetch(`${BASE_URL}${endpoint}`, {
method,
headers: {
'Content-Type': 'application/json',
'x-client-id': CLIENT_ID,
'x-timestamp': timestamp,
'x-signature': signature,
},
body: body === undefined ? undefined : JSON.stringify(body),
signal: AbortSignal.timeout(30_000),
});
const responseBody = await response.json();
if (!response.ok) {
throw Object.assign(new Error(responseBody.message), { status: response.status, body: responseBody });
}
return responseBody;
};After the order
Branch on the status you receive, not on the one you expect next: statuses can be skipped. The full list is on Order statuses.
deposit_awaiting
Show transferInstructions to the user.
deposit_validating, deposit_successful, payout_pending
Wait. The payment is being checked or the payout is being sent.
payout_successful
Final. Deliver what the user paid for.
deposit_canceled, deposit_expired, deposit_invalid
Not final. A late payment can still succeed, so do not reverse your records yet.
payout_failed
Not final. We retry the payout, or refund the user.
refund_initiated, refund_pending, refund_failed
Wait for the refund.
refund_successful
Final. The user has the money back.
Your webhook endpoint must:
check
x-signatureagainst the raw body before it acts, see Webhooks;answer
2xxwithin 20 seconds, at the exact URL you registered, with no redirect;ignore a status it already handled, because a retry can deliver a status twice and out of order;
match the order by
_idormerchantOrderParams, and call Get order when it needs more than the webhook carries.
Retries and errors
A refused call answers with message, errorCode and details. Branch on errorCode, not on the text. All codes are on Errors.
Create order is not idempotent. A second call with the same body creates a second order, and a repeated
orderParamsis accepted. After a timeout, call Get order with yourorderParamsfirst:GET /api/v2/order?orderParams=<your reference>. Retry only when it answers404.ROUTE_NOT_AVAILABLEis the only "no offer" code worth retrying. Every other404code fails again unchanged.429carries aRetry-Afterheader in seconds. Wait that long.An expired quote cannot create an order. Get a new quote. Its fields and options can differ from the old one.

