System design · interactive
Receiving webhooks safely
A payment provider calls your endpoint when a payment succeeds. Webhooks are retried until you answer 200, so the same event can arrive twice. And your URL is public, so anyone can call it. Turn on the two defences.
- 0sproviderPOST evt_123 payment.succeeded (signed)
- 0syouVerify, credit the order, reply 200
- 10sproviderNo 200 within 10 s (you were slow), so it counts as failed and retries.
- 1mproviderretry 1: POST evt_123 again
- 1myouCredit the order AGAIN
Order credited 2× (should be once)
You processed it but answered too slowly. The provider retried, and you credited the order twice.
Scenario
Verify signature
Dedupe by event id
Step 2 of 4 · read left to right
In production
Tools and technologies
Every payment and SaaS platform sends webhooks.
Not tied to one language — use these names when you search docs or design a system.