BTC$68,420▲ 0.82% / ETH$3,841▼ 0.31% / LTC$94.05▲ 1.14% / SOL$221.60▲ 3.02% / USDT·TRC20$1.0000 / USDC·ERC20$0.9999 / XMR$168.42▼ 0.18% / TON$6.02▲ 0.47% / XRP$2.41▼ 0.09% / GAS·ETH18 gwei / Indicative prices · illustrative ticker / No-KYC · non-pooled · 4% flat / BTC$68,420▲ 0.82% / ETH$3,841▼ 0.31% / LTC$94.05▲ 1.14% / SOL$221.60▲ 3.02% / USDT·TRC20$1.0000 / USDC·ERC20$0.9999 / XMR$168.42▼ 0.18% / TON$6.02▲ 0.47% / XRP$2.41▼ 0.09% / GAS·ETH18 gwei / Indicative prices · illustrative ticker / No-KYC · non-pooled · 4% flat
OrbChain
UTC 18:47:02 Get started →
§ Guide · 2026-07-27

Webhooks that
never lose a payment.

The webhook is where most payment integrations quietly break — a missed retry, a double-credit, an unverified body someone forged. It's also the one part where a bug means real money is wrong. This is the short, opinionated guide to consuming OrbChain payment webhooks correctly the first time.

1. Verify the signature before you trust anything

Every webhook carries an HMAC header: HMAC-SHA512 computed over the raw request body using your webhook secret. Compute the same HMAC on your side over the exact bytes you received and compare with a constant-time check. Two failure modes to avoid: parsing the JSON before hashing (re-serialization changes the bytes, so hash the raw body), and using == instead of a timing-safe compare.

// Node — verify before doing anything else
const crypto = require("crypto");
function verify(rawBody, header, secret) {
  const expected = crypto.createHmac("sha512", secret)
    .update(rawBody)               // raw bytes, not JSON.parse(...)
    .digest("hex");
  const a = Buffer.from(expected), b = Buffer.from(header || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

If verification fails, return 401 and stop. An unverified body is an attacker telling you a payment happened.

2. Dedupe on event_id — retries are guaranteed

We retry failed deliveries 5 times with exponential backoff (2s, 4s, 8s, 16s, 32s), and a tick-level replay can re-send even after that. Every one of those carries the same event_id (it's SHA-256-derived from the event type + entity, so it's stable across every retry). Treat event_id as an idempotency key: record processed ids, and if you've seen one, acknowledge and do nothing. This is what stops a retry from crediting an order twice.

if (await seen(event.event_id)) return res.sendStatus(200); // already applied
await applyPaymentInTransaction(event);
await markSeen(event.event_id);
res.sendStatus(200);

3. Respond fast, do work async if it's slow

Acknowledge with a 2xx quickly. If your fulfillment is slow (emails, provisioning), enqueue it and return — a slow handler looks like a failed delivery and triggers retries you don't need. The webhook's job is "record that this happened," not "finish everything that follows from it."

4. Status only moves forward — don't fight it

Payment state advances in one direction (e.g. WAITING → CONFIRMING → PAID); it never goes backward. Your handler should apply the state it receives without assuming ordering beyond that. If you get PAID, provision. If a later, out-of-order delivery carries an earlier state, your event_id dedupe and a "never downgrade a paid order" guard keep you safe.

5. Reconcile — the webhook is a fast path, not the source of truth

Webhooks are best-effort by nature: your endpoint could be down for the whole retry window, or a deploy could eat a request. So never treat "no webhook arrived" as "no payment happened." Poll GET /v1/payment/:track_id for anything you're unsure about, and run a periodic sweep of recent open invoices to catch anything the webhook missed. The chain is the source of truth; the webhook just tells you sooner.

6. Local testing: we can't reach your laptop

Outbound webhooks are SSRF-hardened — we resolve and pin the destination and refuse private/loopback targets, so localhost and 127.0.0.1 will never receive a live webhook. To test locally, expose your handler through a tunnel (ngrok, Cloudflare Tunnel) and point the webhook URL at the public hostname, or use the dashboard's on-demand test dispatch. Every attempt — live or test — is logged to WebhookLog and replayable, so you can inspect exactly what we sent.

The whole checklist

Verify the HMAC over raw bytes with a constant-time compare; dedupe on event_id; respond 2xx fast and defer slow work; never downgrade a paid order; reconcile with GET instead of trusting webhook delivery; tunnel for local testing. Do those six and your integration will not lose or double-count a payment — which is the entire job.

§ Keep reading

Related posts.

Hand-picked
Same rails, next questions