Webhook
This is the request we make to the callback URL you have sent on the merchant dashboard
XtraPay sends a webhook to your server the moment a payment or payout reaches a final state, so you can fulfil an order or update your records without polling.
Every webhook is a signed POST request with a JSON body. Always verify the signature before you act on a webhook. Anyone can send a request to your URL, and only the signature proves it came from XtraPay.
Set up
In XtraPay, open Settings → Developers.
Under API Keys & Webhooks, set your Callback URL. You can also add more URLs on the Webhooks tab, each with its own list of events.
Set a Callback Secret and click Save. Use a long random string, such as 32 or more characters from a password generator.

A Callback Secret is required. XtraPay never sends an unsigned webhook. If no secret is set, the delivery is held and shows "Not sent: no Callback Secret is set to sign webhooks". It goes out on the next retry once you save a secret.
Keep the secret on your server only. Never put it in a mobile app, browser code or a public repository. If it leaks, change it in Settings → Developers.
Events
payment.completed
A customer's payment succeeded and the money is in your wallet.
payment.failed
A payment was declined, cancelled or expired.
payout.completed
A payout you made through the API reached the recipient.
payout.failed
A payout could not be completed. The amount is returned to your wallet.
On the Webhooks tab you can limit a URL to certain events: a comma-separated list such as payment.completed, payout.failed, or a group such as payment.*. Leave it empty to receive every event.
The request
Headers
X-XtraPay-Signature
t=<timestamp>,v1=<signature>. See Verify the signature.
X-XtraPay-Timestamp
Unix time (seconds) the request was signed. Same value as t in the signature.
X-XtraPay-Event
The event name, also in the body.
X-XtraPay-Delivery
ID of this delivery to this URL. Useful when you contact support.
Body
id
string
Unique event ID. It stays the same on every retry and resend, so use it to ignore duplicates.
event
string
One of the events above.
created_at
string
When the event was created (ISO 8601).
data.transaction_id
string
XtraPay's reference for the transaction.
data.merchant_transaction_id
string
The transaction_id you sent when starting the payment. Present for API payments.
data.business_code
string
Your business code.
data.type
string
payment or payout.
data.source
string
Where the payment came from: api, payment_link, virtual_terminal (USSD) or checkout.
data.status
string
completed or failed.
data.amount
string
Transaction amount, two decimal places.
data.fee
string
XtraPay's fee.
data.net_amount
string
Payments: what you keep (amount − fee). Payouts: what left your wallet (amount + fee).
data.currency
string
ISO currency code, e.g. GHS.
data.provider
string
The payment network that processed it.
data.provider_reference
string
The network's own reference, when there is one.
data.reason
string
Why it failed. Only present on *.failed events.
data.transaction_date
string
When the transaction started.
data.settled_at
string
When it reached its final state.
Fields with no value are left out, so don't treat a missing field as an error.
Verify the signature
The signature is an HMAC-SHA256 of the timestamp, a full stop and the raw request body, keyed with your Callback Secret:
To verify a webhook:
Read the
X-XtraPay-Signatureheader and split it on commas intot=…andv1=….Reject the request if
tis more than 5 minutes away from your server's current time. This stops an old, captured request being replayed.Compute the HMAC above over the exact bytes you received. Do not parse and re-encode the JSON first, or the signature will not match.
Compare your result with
v1using a constant-time comparison.If anything fails, respond
401and do nothing else.
Node.js (Express)
PHP
In Laravel, use $request->getContent() for the raw body, and exclude the route from CSRF protection.
Python (Flask)
Respond quickly
Return any 2xx status within 10 seconds to confirm receipt. Anything else, a timeout or a failed connection counts as a failed attempt.
Do slow work, such as sending emails or calling other services, after you respond.
Redirects are not followed. Point the URL straight at your handler and use HTTPS.
Retries and duplicates
If an attempt fails, XtraPay tries again after 10 seconds, 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 3 hours and 6 hours. That is 10 attempts over about 11 hours, after which the delivery is marked as failed.
You can also send any webhook again at any time: open the transaction in XtraPay and click Resend Webhook. The Webhook / Metadata panel there shows every attempt and what your server answered.
Because of retries and resends, the same event can reach you more than once, and events may not arrive in order:
Store the
idof each event you process, and ignore one you have already handled.Act on
data.status, not on the order webhooks arrive in. Apayment.completedis final and is never followed by apayment.failedfor the same payment.For extra certainty before you release goods, confirm the transaction with the Query Transaction Status endpoint.
Test your endpoint
Use the Resend Webhook button on any transaction to send a real, signed webhook to your URL. Check the Webhook / Metadata panel for the status code and response your server returned.
Changes from the previous version of this page
The earlier version of this page described a format that is no longer used. If you built against it, update your handler:
signature header with an HMAC of the body only
X-XtraPay-Signature: t=…,v1=…, with an HMAC of t.body, checked against the timestamp
Authorization: Bearer API_KEY header
Removed. Your API key is never sent to your webhook URL; the signature proves the request is genuine.
Signature only when a secret was set
Every webhook is signed. Without a Callback Secret, webhooks are not sent.
Flat body (status, message, amount, transaction_id, currency, business_code)
id, event, created_at and a data object (see Body)
Last updated