Core concepts
Webhooks
Pay Sef sends an HTTPS POST to your endpoint when an order reaches a final status or your wallet is funded, so you do not have to poll.
Set up an endpoint
- Create a public HTTPS endpoint that accepts
POSTrequests with a JSON body. - In Developer settings in the app, enter its URL (confirm with your transaction PIN). Then rotate your webhook signing secret (
whsec_…), also with your PIN, and copy it: the secret is shown in full only in the rotate response, so rotate once to get it the first time. It signs test and live events alike. - Developer settings has a Test / Live mode switch, and each mode has its own webhook URL. Test orders go to the test URL; until you set one, they go to the live URL.
- Use Send test webhook to receive a signed sample event at the URL of the mode you are in (or a URL you type in). It is an
order.successby default; chooseorder.failedto receive a failed sample instead. That sample carriesFAILED_REFUNDED, while a realorder.failedcarriesFAILED_UNRESERVED, so accept both;customer_statusisfailedin either case. No order exists for it, so it always carriesis_test: true.
{
"event": "order.success",
"timestamp": "2026-10-17T12:00:03.512Z",
"is_test": true,
"data": {
"order_id": "0199f2a4-6c1e-7b3a-9d42-5e8f1a2b3c50",
"order_ref": "VTU-TEST-WEBHOOK",
"reference": "test_ref_1760702403512",
"status": "SUCCESS_SETTLED",
"customer_status": "delivered",
"recipient": "+2348030000000",
"face_value_kobo": 10000,
"amount_debited_kobo": 9800,
"provider_reference": "MOCK-PROVIDER-REF",
"is_test": true,
"created_at": "2026-10-17T12:00:03.512Z",
"updated_at": "2026-10-17T12:00:03.512Z"
}
}You can also pass a callback_url on an individual purchase. Events for that order go to that URL instead of your account's webhook URL, signed the same way.
Events
| Event | Sent when |
|---|---|
| order.success | An order reaches SUCCESS_SETTLED. |
| order.failed | An order fails, immediately or after a pending period. data.status is FAILED_UNRESERVED: the reserved amount was released back to your wallet. |
| order.refunded | Pay Sef refunds an order after review, for example one resolved from manual review or one that was reported as not delivered. data.status is FAILED_REFUNDED. |
| wallet.funded | A bank transfer to your account number is credited. Live mode only; sent to the account webhook URL. |
Events are sent for every order on your account that reaches these states, including orders placed in the Pay Sef app. Use is_test and your reference to match them to your records. New event types may be added; answer 200 to events you do not handle so they are not retried.
Headers
| Header | Value |
|---|---|
| X-Paysef-Signature | Hex HMAC-SHA256 signature (see below) |
| X-Paysef-Timestamp | Unix time in seconds when this attempt was signed (new on every attempt) |
| X-Paysef-Event | Event type, e.g. order.success |
| X-Paysef-Delivery-Id | ID of this delivery, the same on every retry; use it to ignore duplicates |
| User-Agent | Paysef-Webhook/1.0 |
Order event payload
{
"event": "order.success",
"timestamp": "2026-10-17T12:00:03.512Z",
"is_test": false,
"data": {
"order_id": "0199f2a4-6c1e-7b3a-9d42-5e8f1a2b3c4e",
"order_ref": "VTU-20261017-5D6E7F8A9B0C",
"reference": "your-order-1045",
"status": "SUCCESS_SETTLED",
"customer_status": "delivered",
"recipient": "45012345670",
"face_value_kobo": 100000,
"amount_debited_kobo": 99000,
"provider_reference": "PRV-77612390",
"token": "12345678901234567890",
"is_test": false,
"created_at": "2026-10-17T12:00:00.000Z",
"updated_at": "2026-10-17T12:00:02.140Z"
}
}customer_status is processing, delivered or failed, the same values as on the order; branch on it. token, units, pins, provider_reference and failure_reason are included when they apply. token is the token itself with no label in front, the same whichever network delivered it; pins lists each {pin, serial_number} of a multi-PIN exam order. failure_reason is the same plain-language text as on the order, safe to show your customer. data.reference is your reference, or null if you did not send one. Timestamps are UTC ISO 8601 ending in Z, and amounts are whole kobo (₦1 = 100 kobo) in fields ending _kobo.
Wallet event payload
{
"event": "wallet.funded",
"timestamp": "2026-10-17T09:12:03.210Z",
"is_test": false,
"data": {
"deposit_reference": "DEP-20261017-7C1A9E3B5D2F",
"gateway_reference": "BST-92011873",
"gross_amount_kobo": 5000000,
"fee_amount_kobo": 5000,
"net_amount_credited_kobo": 4995000,
"new_available_balance_kobo": 16243050,
"currency": "NGN",
"timestamp": "2026-10-17T09:12:03.198Z"
}
}Verify signatures
Every delivery is signed with your webhook secret. Compute an HMAC-SHA256 of the timestamp, a full stop, and the raw request body, hex-encode it, and compare it with X-Paysef-Signature using a constant-time comparison:
signature = hex( HMAC_SHA256( secret, "<X-Paysef-Timestamp>.<raw body>" ) )Reject deliveries whose signature does not match, and ones whose timestamp is more than a few minutes old, which protects you against replayed requests.
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.PAYSEF_WEBHOOK_SECRET; // whsec_...
// Use the raw body: re-serialised JSON will not match the signature.
app.post("/webhooks/paysef", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.get("X-Paysef-Timestamp") ?? "";
const signature = req.get("X-Paysef-Signature") ?? "";
const expected = crypto
.createHmac("sha256", SECRET)
.update(`${timestamp}.${req.body}`)
.digest("hex");
const valid =
signature.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
if (!valid || !fresh) return res.sendStatus(400);
const event = JSON.parse(req.body);
// Record X-Paysef-Delivery-Id and skip it if you have seen it before.
queueForProcessing(req.get("X-Paysef-Delivery-Id"), event);
res.sendStatus(200);
});Responses, retries and replays
- Any
2xxresponse within 10 seconds counts as delivered. - Otherwise Pay Sef tries again up to 4 more times, waiting about 30 seconds, 2 minutes, 10 minutes and 1 hour between attempts (5 attempts in total; each can be up to 30 seconds later than scheduled).
- The first attempt can arrive before or after the API response to the purchase.
- Recent deliveries, their status and response codes are listed in Developer settings (per mode), where you can replay any of them. A replay is a single attempt.
Process each event once
Retries and replays mean you can receive the same event more than once, and events can arrive out of order. Store X-Paysef-Delivery-Id (or the order ID and status) and skip work you have already done. Respond quickly and do slow work in a background job. In rare cases Pay Sef corrects an order after review, so accept a later event for an order you already treated as final.
A webhook tells you something changed. If you ever doubt one, confirm the order with GET /vtu/orders/{id}.