Webhooks
Building a reliable handler
- Deduplicate on
id. Delivery is at-least-once; a network failure between your200and our recording of it produces one honest duplicate. Persist the event ids you have processed. - Do not depend on order. A
payment.sentcan arrive before thepayment.processingthat preceded it. Apply events as state, not as transitions: if your record already sayssent, ignore a laterprocessingfor the same payment. - Do not treat a webhook as an instruction to release goods without checking your own state. It is a notification about a payment you created; reconcile it against the payment id you hold.
- Verify every delivery. An endpoint that skips verification is a public URL that anyone can POST a fake payout notification to.
- Acknowledge fast, work later. The timeout is 10 seconds, and slow handlers turn into retries.
- Reconcile anyway. Webhooks are the fast path, not the books. Compare your ledger against
GET /v1/paymentson a schedule; that is what catches the case where both the webhook and the replay were missed.