Webhooks
FlowPayra Lite sends a signed HTTP POST request to the endpoint configured by the merchant whenever an order, a subscription, a help ticket or the system state changes. Every event is also stored and can be read in commit order through GET /v1/events. Fulfilment and service activation should rely on webhooks or on the status returned by the query endpoints; the flow is described in the integration guide.
Delivery
Section titled “Delivery”| Item | Description |
|---|---|
| Endpoint | Console, “Developers → Webhooks”: one endpoint and one secret each for live and test mode |
| Headers | Content-Type: application/json, User-Agent: FlowPayra-Lite/<version>, FlowPay-Signature: t=<seconds>,v1=<hex> |
| Signature | v1 = hex(HMAC-SHA256(secret, "<t>.<raw body>")), where secret is the whole whsec_… string (UTF-8). Every attempt is signed anew (t is the time of that attempt). Each request carries a single v1; the header format allows several, so a receiver accepts any matching v1. After the signing secret is replaced in the console, the new secret is used at once, and all later deliveries (including retries) are signed with it |
| Acknowledgement | Any 2xx within 10 seconds. Redirects are not followed (a 3xx counts as a failure) |
| Retries | After a failure, retried after 10 seconds, 30 seconds, 1, 5, 15 and 30 minutes, then 1, 2, 4, 8 and 8 hours (12 attempts, about 24 hours); the event is then marked failed and can be resent from the console |
| Ordering | Each mode is delivered strictly in order: while an event is failing, later events of the same mode wait until it is delivered or given up. Live and test do not affect each other |
| No endpoint configured | Events are kept and can be read through GET /v1/events; once an endpoint is configured they are delivered in order |
Requirements for the receiver:
- Verify first, parse second. Compute the signature over the raw request body bytes; re-serialized JSON does not verify.
- Be idempotent by event
id. The same event may arrive more than once (a lost acknowledgement, a manual resend from the console). Record handledidvalues and answer 2xx to repeats. - Answer 2xx within 10 seconds. Queue slow work and process it asynchronously.
- Read the object before acting on an older event. Calling
GET /v1/orders/{id}before fulfilment, for example, rules out both forged requests and out-of-order events. - Acknowledge unknown event types with 2xx. New event types may be added in later versions.
Signature verification
Section titled “Signature verification”FlowPay-Signature: t=1767225600,v1=5b0c…e9v1 = hex(HMAC-SHA256(secret, "<t>.<raw body>")).secretis the wholewhsec_…string shown on the console’s webhook page (used as UTF-8 bytes).- Compute it over the raw request body bytes: verify first, then parse the JSON.
- The header may carry several
v1values, and any one matching is sufficient (each request carries one; after the signing secret is replaced in the console the new secret is used at once, including for later retries, so the receiver must update its secret at the same time). - Reject requests where
|current time − t|exceeds the tolerance (300 seconds is recommended) to prevent replays.
Receiver example (Node.js)
Section titled “Receiver example (Node.js)”import { verifyWebhook } from './flowpay.mjs';// req.rawBody must be the raw bytes (for example express.raw({ type: 'application/json' }))if (!verifyWebhook(process.env.FLOWPAY_WEBHOOK_SECRET, req.get('FlowPay-Signature'), req.rawBody)) { return res.status(400).end();}const event = JSON.parse(req.rawBody);if (await alreadyHandled(event.id)) return res.status(200).end();await queue.push(event); // process asynchronouslyres.status(200).end();Verification functions
Section titled “Verification functions”docs/developers/examples/ in the repository provides two functions in each of five languages: one verifies a webhook (header, raw body, current time, tolerance) and one verifies a return URL (full URL, current time, maximum age). They depend on the standard library only.
| Language | File | Self-check |
|---|---|---|
| Node.js 18+ | examples/node/flowpay.mjs |
node examples/node/check.mjs |
| Python 3.8+ | examples/python/flowpay.py |
python3 examples/python/check.py |
| Go 1.21+ | examples/go/flowpay.go |
cd examples/go && go test |
| PHP 7.4+ | examples/php/FlowPay.php |
php examples/php/check.php |
| Java 11+ | examples/java/FlowPay.java |
See test-examples.sh |
Node.js (from examples/node/flowpay.mjs):
import { createHmac, timingSafeEqual } from 'node:crypto';
const hmac = (secret, data) => createHmac('sha256', Buffer.from(secret, 'utf8')).update(data).digest();
/** `FlowPay-Signature: t=<unix seconds>,v1=<hex>` over `"<t>.<raw body>"`; any v1 may match (secret rotation). */export function verifyWebhook(secret, header, rawBody, now = Math.floor(Date.now() / 1000), toleranceSecs = 300) { if (!secret || typeof header !== 'string') return false; let ts = null; const sigs = []; for (const part of header.split(',')) { const i = part.indexOf('='); if (i < 0) continue; const k = part.slice(0, i).trim(); const v = part.slice(i + 1).trim(); if (k === 't' && /^\d+$/.test(v)) ts = Number(v); else if (k === 'v1') { if (!/^[0-9a-fA-F]*$/.test(v) || v.length % 2) return false; sigs.push(Buffer.from(v, 'hex')); } } if (ts === null || sigs.length === 0 || Math.abs(now - ts) > toleranceSecs) return false; const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody, 'utf8'); const expected = hmac(secret, Buffer.concat([Buffer.from(`${ts}.`, 'utf8'), body])); return sigs.some((s) => s.length === expected.length && timingSafeEqual(s, expected));}Python (from examples/python/flowpay.py):
import hashlibimport hmacimport reimport time
_HEX = re.compile(r"^[0-9a-fA-F]*$")
def _mac(secret: str, data: bytes) -> bytes: return hmac.new(secret.encode("utf-8"), data, hashlib.sha256).digest()
def verify_webhook(secret: str, header: str, raw_body: bytes, now: int = None, tolerance: int = 300) -> bool: """`FlowPay-Signature: t=<unix seconds>,v1=<hex>` over b"<t>.<raw body>"; any v1 may match (rotation).""" if not secret or not header: return False now = int(time.time()) if now is None else now ts, sigs = None, [] for part in header.split(","): key, sep, value = part.strip().partition("=") if not sep: continue if key == "t" and value.isdigit(): ts = int(value) elif key == "v1": if not _HEX.match(value) or len(value) % 2: return False sigs.append(bytes.fromhex(value)) if ts is None or not sigs or abs(now - ts) > tolerance: return False if isinstance(raw_body, str): raw_body = raw_body.encode("utf-8") expected = _mac(secret, str(ts).encode() + b"." + raw_body) return any(hmac.compare_digest(s, expected) for s in sigs)Test vectors
Section titled “Test vectors”docs/developers/vectors.json in the repository is produced by the server’s signature implementation and can be used to check verification code you write yourself. The repository’s tests fail when the implementation and the file disagree.
A webhook vector has the fields secret, header, body, now, tolerance and the expected result valid. A valid vector:
{ "body": "{\"created_at\":\"2026-01-01T00:00:00Z\",\"data\":{\"amount\":\"100.00\",\"description\":\"年度会员 × 1\",\"merchant_order_no\":\"SO-10023\",\"order_id\":\"0b3f5a52-8f7e-4c1e-9d2a-6c1f0e9b7a31\"},\"id\":\"evt_01\",\"type\":\"order.paid\"}", "header": "t=1767225600,v1=d559f5ea11b41db6052b42de11701d3f9ef12a4c92169e9a534f8f8bb4c0de9c", "name": "valid", "now": 1767225605, "secret": "whsec_4f1b2c3d4e5f60718293a4b5c6d7e8f9", "tolerance": 300, "valid": true}| Webhook vector | Expected |
|---|---|
valid |
Accepted |
valid, two v1 values (secret rotation): the header carries two v1 values, one of which matches |
Accepted |
valid, spaces after commas |
Accepted |
wrong secret |
Rejected |
body changed: the body was tampered with |
Rejected |
body re-serialized: the body was re-serialized |
Rejected |
timestamp too old: the timestamp is outside the tolerance |
Rejected |
timestamp changed: the timestamp was altered |
Rejected |
no v1: the signature is missing |
Rejected |
not hex: the signature is not hexadecimal |
Rejected |
Return URL signature
Section titled “Return URL signature”Once an order reaches a final state, the checkout returns the payer to return_url with four parameters appended:
https://shop.example/orders/done?order_id=0b3f…7a31&status=paid&ts=1767225600&sig=8c1d…40sig = hex(HMAC-SHA256(secret, "<order_id>.<status>.<ts>")), with the same secret as webhooks (test orders use the test webhook secret).statusispaidorexpired.- Your own
return_urlmay carry query parameters; the system’s parameters are appended last, so take the last occurrence of each parameter when verifying. - Check the age of
ts(the examples default to 600 seconds).
verifyReturnUrl / verify_return_url in the language examples implement these rules. The return_url vectors in vectors.json (fields secret, url, now, max_age, valid) cover: a valid signature, a valid signature for an expired order, merchant parameters placed first including one with the same name, a changed status, a wrong secret, a timestamp that is too old, and a missing signature. A valid vector:
{ "max_age": 600, "name": "valid", "now": 1767225630, "secret": "whsec_4f1b2c3d4e5f60718293a4b5c6d7e8f9", "url": "https://shop.example/orders/done?order_id=0b3f5a52-8f7e-4c1e-9d2a-6c1f0e9b7a31&status=paid&ts=1767225600&sig=ea5f2a5e1015520542bba291f9278904eee1158c2dd929e45a752282ff8ceade", "valid": true}Event envelope
Section titled “Event envelope”{ "id": "…", "type": "order.paid", "created_at": "2026-10-22T14:16:07.746192Z", "livemode": true, "data": { … } }data is the object as it was when the event was written and takes one of four shapes by type: an order (order.*), a subscription (subscription.*), a help ticket (support.ticket_created) or a system alert (system.*). Test mode events carry livemode: false, go to the test endpoint and are signed with the test secret.
Event types
Section titled “Event types”Order events
Section titled “Order events”data is the complete order (the same as GET /v1/orders/{id}, without checkout_url), plus payments (every on-chain payment, the booked one first) and customer_email.
| Event | When | Additional data fields |
|---|---|---|
order.paid |
The first payment reached its confirmations (order paid; sent again after a reverted order is paid anew) |
— |
order.duplicate_paid |
A further payment reached its confirmations (order duplicate_paid); a refund is opened automatically |
— |
order.payment_frozen |
A payment arrived from an address that fails risk screening (a block-level entry or a built-in list): it is frozen and does not count, and the order stays unpaid. Do not fulfil the order, do not refund the payer, and handle the funds (already in the receiving wallets) according to your compliance process | frozen_payment |
order.payment_reverted |
A confirmed payment disappeared in a chain reorganization (order reverted); stop fulfilment |
— |
order.expired |
Unpaid at expires_at |
— |
order.refunded |
A refund was confirmed on chain (order partially_refunded, refunded, or paid again after a duplicate’s refund) |
refund |
Subscription events
Section titled “Subscription events”data is the complete subscription (the same as GET /v1/subscriptions/{id}, without checkout_url), plus the fields in the table.
| Event | When | Additional data fields |
|---|---|---|
subscription.activated |
The on-chain subscription reached its confirmations (for an immediate start, subscription.charged for the first period follows) |
— |
subscription.trial_will_end |
N days before the trial ends (receipt setting, 3 days by default) | — |
subscription.charged |
A period’s charge reached its confirmations | charge: {id, period_index, amount, tx_hash} |
subscription.charge_failed |
A charge failed; the subscription becomes past_due |
charge: {id, period_index, error}, retry_at |
subscription.unpaid |
The grace period ran out; the subscription becomes unpaid |
As above |
subscription.paused / subscription.resumed |
Paused / resumed | paused: previous_status |
subscription.risk_paused |
Screening before a charge matched a block-level entry; the subscription was paused by risk control | — |
subscription.canceled |
Canceled (with charge and retry_at when the grace period ran out on a plan set to “cancel”; with canceled_by after an on-chain cancel) |
Depends |
subscription.charged_after_cancel |
A period was charged after the subscription was canceled in the system and before the on-chain cancel: a refund is due; no receipt is sent | charge |
subscription.completed |
Every period has passed | — |
subscription.allowance_low |
The remaining allowance no longer covers the remaining periods (sent once) | allowance, needed |
subscription.payment_method_changed |
The payer moved to another wallet, token or network in “My subscriptions” | previous: {chain_id, token, payer}, switch: {chain_id, payer} |
subscription.migration_requested |
After the merchant replaced the quote signer key, the payer is asked to migrate to the new payment contracts | migration: {reason, action} |
subscription.plan_change_pending / _expired / _canceled |
A plan change was requested, expired or withdrawn (sent on the old subscription) | plan_change |
subscription.plan_changed |
The plan change took effect (sent on the new subscription, instead of activated) |
previous: {id, plan_id, plan_name}, effective_at |
subscription.replaced |
The old subscription of a plan change ended (sent on the old subscription, now canceled with cancel_source: plan_changed, usually together with plan_changed). Not a cancellation: the service goes on with the new subscription |
replaced_by, effective_at |
The business meaning of each event and the recommended handling are given in the integration guide: Subscriptions.
Help ticket and system events
Section titled “Help ticket and system events”| Event | data |
|---|---|
support.ticket_created |
A payer submitted the checkout’s payment help form: {id, ticket_no, livemode, order_id, merchant_order_no, kind, tx_hash, payer, customer_email, attachments} |
system.<kind> |
A notification of the alert center: {alert_id, status: open | resolved | event, subject, details}; system.payee_blocked is the exception, with {payee: {ref, name}, address, chain_id, hits} |
{ "type": "support.ticket_created", "data": { "id": "fe5970ad-9c67-4378-a1d0-01ffcf439843", "ticket_no": "T-20261022-0001", "livemode": true, "order_id": "8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9", "merchant_order_no": "SO-10023", "kind": "not_credited", "tx_hash": null, "payer": null, "customer_email": "[email protected]", "attachments": 0 } }{ "type": "system.rpc_down", "data": { "alert_id": "70e6b891-7624-45e7-80c5-0bf3f7213cde", "status": "open", "subject": "31338", "details": { "chain_id": 31338, "endpoints": 1 } } }System events system.<kind>
Section titled “System events system.<kind>”System events are intended for operations; most business systems only need to log them or forward them to monitoring. The ones that require action are mainly those marked as requiring a refund. The opening (open) and the resolution (resolved) of an alert share one alert_id; a one-off notification has the status event. Alerts about test data carry livemode: false and go to the test endpoint.
kind |
Type | Description |
|---|---|---|
rpc_down |
Open / resolved | Every RPC endpoint of a chain is unavailable (subject is the chain ID) |
relayer_low_balance |
Open / resolved | The sponsoring hot wallet’s balance is below its minimum |
walletconnect_down |
Open / resolved | The WalletConnect relay is unavailable |
keeper_idle |
Open / resolved | Live subscription charges have been due for 15 minutes while the keeper has not run for 5 minutes |
keeper_stalled |
Open / resolved | Subscription charges or on-chain cancels cannot be sent on a chain (hot wallet balance, gas price cap or RPC) |
charge_failure_rate |
Open / resolved | The subscription charge failure rate is above the threshold |
reconcile_recovered |
One-off | Reconciliation recovered events the indexer had missed |
split_mismatch |
Open | A payment’s on-chain splits match none of the order’s quotes |
unquoted_payment |
Open | A payment not quoted by this system appeared on the contracts of a replaced key (it is not booked) |
payment_unquoted_chain |
Open | A payment on a chain where its order has no quote for that token and amount, or whose network does not serve the order’s mode (a live order paid with test coins): not booked (reason tells which) |
sub_event_wrong_network |
Open | A subscription event on a chain whose network does not serve the subscription’s mode: not booked |
sub_foreign_payer |
Open | Solana: another payer opened an on-chain subscription with the terms quoted for a subscription; it is canceled on chain and its charges are recorded as duplicates: refund them |
payee_ata_recreated |
One-off | A payee token account the hot wallet created was closed and is needed again: the payer pays instead of the sponsor, the keeper funds it again, or past the limit the charge fails (action tells which) |
token_paused, token_depeg, price_feed_stale, token_impl_changed |
Open / resolved | A token is paused, has lost its peg, its price feed is stale, or an upgradeable token’s implementation changed |
sub_charge_after_cancel |
Open | A charge landed after the subscription was canceled and before the on-chain cancel: a refund is required |
sub_charge_retired_method, sub_duplicate_charge |
Open / resolved | A charge landed on a replaced payment method; a second on-chain charge for the same period: a refund is required (resolved when the other charge leaves the chain) |
sub_duplicate_subscribe |
Open | The payer subscribed again with replaced terms; the second on-chain subscription will be canceled |
sub_onchain_cancel_failed |
Open | The on-chain cancel of a subscription failed |
sub_subscribe_front_run, sub_funding_missing |
One-off / open | A sponsored subscribe was front-run with its funding stripped; the allowance is missing after subscribing and the payer must authorize it |
payer_risk_blocked |
One-off | Risk screening refused a payer at quote time or at a sponsored submission (at most once a day per payer and chain) |
risk_provider_down, ofac_import_failed, risk_list_import_failed |
Open / resolved | A third-party risk provider is unavailable; the OFAC or a URL feed import failed (the existing entries are kept) |
email_suppressed |
One-off | Sending to an address stopped after repeated bounces |
signer_rotated |
One-off | A new quote signer key was activated (emergency means the old key is treated as compromised) |
signer_mismatch, signer_unavailable |
Open / resolved | The signer address embedded in the contracts differs from the recorded one; a signer key kept in a KMS cannot sign (quotes answer 503) |
payee_blocked |
One-off | A payee address was blocked by screening on a chain (the data shape is given above) |
Duplicate payments, payments booked with a risk hit, frozen payments and risk pauses are reported by business events (order.duplicate_paid, the order’s risk_flag, order.payment_frozen, subscription.risk_paused) and not additionally as system.*. Dual approval requests appear in the alert center only. Alert kinds may be added in later versions; handle unknown kinds generically.
Alert channel webhooks
Section titled “Alert channel webhooks”The alert center’s generic webhook channel is independent of the business webhook and is suited to operations tooling. The body is {id, type: alert.open | alert.resolved | alert.event, created_at, data: {alert_id, kind, title, status, subject, details, at, console_url}}, signed with the channel’s own secret using the same FlowPay-Signature scheme. id identifies the delivery and stays the same across retries; created_at is the time of the attempt. Only alerts about live data are delivered, deliveries are not ordered, and failures are retried on the same schedule for about a day.
{ "id": "57096b05-9d75-47bc-ac14-d03d29f96823", "type": "alert.open", "created_at": "2026-10-22T14:16:11.970582Z", "data": { "alert_id": "70e6b891-7624-45e7-80c5-0bf3f7213cde", "kind": "rpc_down", "title": "RPC 节点全部不可用", "status": "open", "subject": "31338", "details": { "chain_id": 31338, "endpoints": 1 }, "at": "2026-10-22T14:16:11.889963Z", "console_url": "https://pay.example.com/admin/" } }The event feed GET /v1/events
Section titled “The event feed GET /v1/events”The event feed is the pull alternative to webhooks and requires the events:read scope.
curl "$BASE/v1/events?since=0&limit=7" -H "Authorization: Bearer $KEY"{ "data": [ { "type": "order.paid", … }, { "type": "order.paid", … }, { "type": "order.duplicate_paid", … }, { "type": "order.expired", … }, { "type": "order.refunded", … }, { "type": "support.ticket_created", … }, { "type": "subscription.activated", … } ], "next_since": 8 }- It lists every event of the key’s mode (whether or not the webhook was delivered) in commit order, with the same content as webhooks (order events carry
customer_emailhere too). - Pass the
next_sinceof a response as the nextsince. With no new events,datais empty andnext_sinceequalssince. Positions are shared by both modes, so a mode’s feed skips numbers (in the example, 7 events are followed by 8 because one position belongs to a test event). - A position never changes once returned, and no event is ever placed before a position already returned. An event appears once every database transaction that could still commit an earlier one has ended; the feed may trail commits briefly but never skips.
limitdefaults to 100, and values outside 1–500 are clamped. Events are kept (“Delete all test data” removes test events), sosince=0replays the whole history.- Use it as a fallback for webhooks, or for polling in environments without a public endpoint (for example every 10–30 seconds). Persist
next_sinceand deduplicate by eventid(sharing the deduplication table with webhooks).