Handling Stripe Webhooks Reliably in Node.js
Verification, idempotency, and retries: the three things that separate a toy webhook handler from a production one.
Zeeshan
Founder · Published
Verification, idempotency, and retries: the three things that separate a toy webhook handler from a production one.
Zeeshan
Founder · Published
Most webhook bugs aren't about Stripe. They're about the three things a production HTTP handler needs that a tutorial handler skips: signature verification, idempotency, and fast acknowledgment.
Never process a webhook payload without verifying its signature against your webhook secret. This is the single most common security gap we find auditing existing integrations.
Stripe can and will deliver the same event more than once. Store processed event IDs and check them before acting. Otherwise a retried webhook can double-fulfill an order or double-send a confirmation email.
Respond within a few seconds. Stripe times out and retries otherwise. If your processing is heavier than that, acknowledge immediately and hand off to a queue.
Stripe insights, monthly
One email a month, no spam, unsubscribe anytime.
No spam, unsubscribe anytime.
One line of body-parser middleware silently breaks every signature check. Here's the correct route ordering.
Let Stripe own the billing state and Django own the entitlement. Mixing the two is where it goes wrong.
The raw-body problem bites PHP integrations harder than most. Here's the correct shape.