Webhooks#
Webhooks let you receive real-time HTTP notifications when events happen in your account — like a successful purchase or a failed transaction.
How Webhooks Work#
- You register a webhook URL in the Merchant Portal → Settings → Webhooks tab
- When an event occurs, we send a
POSTrequest to your URL with the event data - Your server processes the event and returns a
200status code - If delivery fails, we retry up to 4 more times with exponential backoff: 30s, 2min, 10min, 1hr
Each endpoint retries independently, so a single failing URL never causes a duplicate delivery to your other endpoints.
Setting Up#
- Go to Merchant Portal → Settings → Webhooks
- Click Add webhook
- Enter your endpoint URL. Use HTTPS: plain
http://URLs are accepted (handy for a local tunnel while developing), but the payload and its signature then travel unencrypted - Choose the environment: Live endpoints receive live purchases only, Test endpoints
receive purchases made with your
sk_test_key only - Select the events you want to receive
- Click Create — the signing secret, beginning
whsec_, is shown
The signing secret is shown once, when the endpoint is created. Store it then. If you lose it, Rotate secret on the endpoint issues a new one — the previous secret stops verifying immediately. Managing endpoints is done in the portal, signed in; your API key cannot create, rotate or replay webhooks.
There is no account-wide webhook secret. Each endpoint has its own signing secret, and only that value verifies deliveries from that endpoint.
Webhook Payload#
Every webhook delivery includes these headers:
| Header | Description |
|---|---|
X-Webhook-Signature | HMAC-SHA256 signature of the raw body, keyed with your signing_secret |
X-Event-Id | Unique delivery ID — use this to deduplicate |
X-Event-Time | Unix timestamp of the event |
Content-Type | application/json |
Example Payload#
Every delivery has the same envelope: id (the event id, also sent as X-Event-Id), time
(Unix seconds, also sent as X-Event-Time), event, and data. For a purchase event,
data.purchase is the purchase exactly as GET /api/v1/purchases/{id} returns it:
{
"id": "01kw46b8t1z6n0q3x2v9c4m7ra",
"time": 1751270405,
"event": "purchase.success",
"data": {
"purchase": {
"id": "01kw463z1czwnst3yknbkzczn2",
"reference": "01kw463z1czwnst3yknbkzczn2",
"status": "success",
"feature": "airtime",
"amount": 50000,
"amount_paid": 50000,
"fee": 0,
"currency_code": "NGN",
"provider_reference": "DIST2349054079391",
"failure_reason": null,
"is_test": false,
"platform_meta": {
"phone_number": "+2348012345678",
"network": "mtn"
},
"created_at": 1751270400,
"updated_at": 1751270403
}
}
}| Field | Description |
|---|---|
id | Event id. A retry or a replay of the same delivery keeps it — deduplicate on it |
time | Unix timestamp (seconds) when the event was raised |
event | One of the event types below |
data.purchase.status | Always matches the event: success for purchase.success, and so on |
data.purchase.failure_reason | A customer-safe reason on purchase.failed; null on every other event |
data.purchase.provider_data | Only on purchase.success for a product that vends a code (a WAEC PIN, an electricity token); absent otherwise |
data.purchase.is_test | true for a purchase made with your test key — delivered to your Test endpoints only |
Amounts are in the smallest currency unit, beside their currency_code.
Verifying Signatures#
Always verify webhook signatures to ensure the request came from us. Compute the HMAC-SHA256 of the raw request body using your webhook secret:
const crypto = require("crypto");
function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac("sha256", secret)
.update(payload)
.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
// In your webhook handler:
app.post("/webhooks", (req, res) => {
const signature = req.headers["x-webhook-signature"];
const isValid = verifyWebhook(req.rawBody, signature, WEBHOOK_SECRET);
if (!isValid) {
return res.status(401).json({ error: "Invalid signature" });
}
const { id, event, data } = req.body;
// Deduplicate on `id`, then act on data.purchase...
res.status(200).json({ received: true });
});import hmac
import hashlib
def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(
secret.encode(),
payload,
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(signature, expected)function verifyWebhook(string $payload, string $signature, string $secret): bool
{
$expected = hash_hmac('sha256', $payload, $secret);
return hash_equals($expected, $signature);
}
// In your controller:
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'];
if (!verifyWebhook($payload, $signature, $webhookSecret)) {
http_response_code(401);
exit;
}
$event = json_decode($payload, true);
// Process the event...Event Types#
These are the events the platform emits. Subscribing to anything not on this list is rejected at write time, so a typo fails immediately instead of silently never firing.
| Event | Description |
|---|---|
purchase.pending | A purchase was created and the buyer debited, not yet sent to the provider |
purchase.processing | The outcome is not yet final: the provider accepted the request, or the purchase is held for manual review |
purchase.success | The purchase was fulfilled |
purchase.failed | The purchase failed and the buyer was refunded |
webhook.test is also delivered, but only on demand from the Test button — you do not
subscribe to it.
The event name is purchase. followed by the purchase status, and the body's status
always matches the event name. One exception: a purchase held for manual review (review
on GET /purchases) is announced as purchase.processing; there is no purchase.review
event. Its purchase.success or purchase.failed follows when it is settled. Only
success and failed are final, so order events by name, not by updated_at.
Retry Policy#
If your endpoint doesn't respond with a 2xx status code, we retry:
| Attempt | Delay |
|---|---|
| 1st retry | 30 seconds |
| 2nd retry | 2 minutes |
| 3rd retry | 10 minutes |
| 4th retry | 1 hour |
After 5 total attempts the delivery is marked failed. Retries are per endpoint: a URL that is down does not cause repeat deliveries to your other endpoints.
A purchase.processing delivery not yet sent when its purchase ends (a first attempt, a
retry or a replay) is dropped rather than sent late: the purchase.success or
purchase.failed event carries the outcome. One already queued is listed in the deliveries
with status superseded.
Deliveries on an endpoint in Settings → Webhooks lists past attempts, with the response code and the attempt count for each, and re-sends a failed one.
Best Practices#
- Respond quickly — return
200immediately, process asynchronously - Handle duplicates — use the
X-Event-Idto deduplicate - Verify signatures — always validate before processing
- Use HTTPS —
http://URLs are accepted, but only HTTPS keeps the payload and its signature private in transit - Log everything — keep records for debugging