Webhooks
Get a signed event the moment a payment succeeds.
Set a webhook URL under Developers. When a live or test payment succeeds we POST a JSON event to it. The URL must be https:// and reachable from the public internet.
The event
POST your-url
{
"id": "evt_3f9a1c5e7b2d4a60b8c1",
"type": "payment.succeeded",
"created": 1764362582,
"data": { /* the payment object */ }
}Verify the signature
Every request carries a Hephaestus-Signature header: t=<unix seconds>,v1=<hex>. The v1 value is an HMAC-SHA256 of "{t}.{raw request body}" using your signing secret (shown on the Developers page). Compute it over the raw bytes you received, before any JSON parsing, and reject anything that doesn't match or is older than five minutes.
webhook.mjs
import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(rawBody, header, secret) {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
if (!m) return false;
const [, t, v1] = m;
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false; // replay window
const expected = createHmac("sha256", secret).update(t + "." + rawBody).digest();
return timingSafeEqual(expected, Buffer.from(v1, "hex"));
}Respond and retry
- Answer with any
2xxstatus within 10 seconds. Do the heavy work after answering. - Anything else, or a timeout, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then we stop. Failures show on your Developers page.
- We do not follow redirects.
- Handle duplicates. A retry, or your server answering slowly, can deliver the same event twice. Use
data.idto make fulfilment idempotent. - If you are ever unsure, fetch the payment with
GET /v1/payments/{id}and trust that.