Webhooks
Receive a payment's outcome, with a signature to verify.
FlowPay sends a JSON POST to your application's webhook address at each payment outcome, whether it comes from the API, a direct payment or a payment link.
Set up
In the dashboard, open your application and save your webhook address.
- A live application requires HTTPS; a test application also accepts HTTP.
- Each new address replaces the previous one and generates a new secret, shown only once: keep it. It signs every delivery.
- The secret belongs to the application.
Events
| Event | When |
|---|---|
payment.succeeded | The payment is settled. |
payment.failed | The payment failed for good. |
payment.expired | The deadline passed without payment. |
payment.canceled | You canceled the payment. |
{
"id": "00000000-0000-4000-8000-000000000001",
"type": "payment.succeeded",
"created_at": "2026-09-01T10:00:00Z",
"data": {
"intent_id": "00000000-0000-4000-8000-000000000002",
"merchant_reference": "ref-0001",
"state": "SUCCEEDED",
"mode": "TEST",
"amount": "5000",
"amount_minor": 5000,
"currency": "XOF",
"network": "BF_ORANGE",
"metadata": { "order": "A-1" },
"succeeded_at": "2026-09-01T10:00:00Z",
"failure": null
}
}What data contains
| Field | Description |
|---|---|
intent_id | The payment identifier (the API's id). |
merchant_reference | Your order reference. |
state | SUCCEEDED, FAILED, EXPIRED or CANCELED. |
mode | TEST or LIVE. |
amount, amount_minor | The amount, in major units (string) and minor units (integer). |
currency | For example XOF. |
network | The network of the attempt that decided it. null for an expiry or a cancellation. |
metadata | Your fields, as supplied at creation. |
succeeded_at | Settlement date, null otherwise. |
failure | null, except for payment.failed. |
For a failure, failure gives the reason:
{
"type": "payment.failed",
"data": {
"state": "FAILED",
"succeeded_at": null,
"failure": {
"reason": "failure_not_retryable",
"failure_class": "CUSTOMER_DECLINED",
"failure_code": "sandbox_declined"
}
}
}Shortened example. failure_class takes the values listed in Errors (CUSTOMER_DECLINED, INSUFFICIENT_FUNDS…). Test failure_class: reason and failure_code may change and are not guaranteed. The provider's raw message is never sent.
Adding a field to the body is compatible; removing one or changing its type means a new X-FlowPay-Version. Ignore fields you do not know.
Headers
| Header | Purpose |
|---|---|
X-FlowPay-Event-Id | The event id: deduplicate on it. |
X-FlowPay-Timestamp | Signature timestamp, in seconds. |
X-FlowPay-Signature | sha256= followed by the hex signature. |
X-FlowPay-Version | Body format version (currently 2026-09-01). |
Verify the signature
The signature is the HMAC-SHA256, using your application's webhook secret, of <timestamp>.<raw body>. Compute it over the bytes you received, before any JSON parsing.
import { createHmac, timingSafeEqual } from "node:crypto";
export function isValid(rawBody: string, headers: Headers, secret: string): boolean {
const timestamp = headers.get("x-flowpay-timestamp") ?? "";
const received = headers.get("x-flowpay-signature") ?? "";
const expected =
"sha256=" + createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
const a = Buffer.from(received);
const b = Buffer.from(expected);
return a.length === b.length && timingSafeEqual(a, b);
}Also reject a timestamp that is too old (five minutes, for example) to rule out replays.
Delivery and retries
Delivery is "at least once": the same event can arrive more than once. Answer 2xx quickly and deduplicate on X-FlowPay-Event-Id.
Without a 2xx answer, FlowPay retries after 30 seconds, 2 minutes, 10 minutes, 1 hour, 6 hours, then 24 hours, then gives up. If your server was down for longer, re-read the affected payments with GET /v1/payments rather than waiting for a resend.
Save the event before answering: a 2xx answer means "received, do not send it again".