Webhooks
If an invoice has a webhook_url, the server POSTs a JSON payload to it as the invoice’s
status changes — payment detected, confirmed, cancelled, and so on.
Headers
Every delivery carries:
| Header | Contents |
|---|---|
X-Webhook-Signature | sha256=<hex> — HMAC-SHA256 of the raw body, keyed with your webhook secret |
X-Webhook-Signature-Timestamped | t=<unix>,v1=<hex> — HMAC over "<unix>.<body>", so a reused request older than your tolerance can be rejected even though retries redeliver identical bytes |
X-Webhook-Event | The event type |
X-Webhook-Id | A unique ID for this event |
X-Webhook-Idempotency-Key | Safe to dedupe deliveries on — retries of the same event reuse it |
Verifying a delivery
Recompute the HMAC-SHA256 of the raw request body using your store’s webhook secret, and
compare it — in constant time — against X-Webhook-Signature. Reject anything that doesn’t
match.
import hashlib
import hmac
def verify(raw_body: bytes, signature_header: str, secret: str) -> bool:
expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature_header)
Use the raw request body — not a re-serialized version of the parsed JSON. Reformatting (key order, whitespace) changes the bytes the signature was computed over, and the comparison will fail even for a genuine delivery.
Retries
A delivery that fails (connection refused, timeout, non-2xx response) is retried with backoff. After repeated failures, delivery for that webhook is treated as unreachable rather than retried forever — see the API Reference for the webhook-delivery endpoints that let you inspect and manually replay a specific delivery.
Configuring a webhook per store
Stores can also have a store-level webhook, independent of any single invoice’s webhook_url —
see the store configuration endpoints in the API Reference.