PRODUCTION GUIDE / STRIPE-WEBHOOK-IDEMPOTENCY
Stripe webhook idempotency without duplicate side effects
Stripe retries deliveries. Your database—not process memory—must decide whether an event has already committed.
Use event.id as a unique key
Insert the Stripe event ID into a table with a unique constraint inside the same transaction as the side effect.
Mark after success
If the handler fails, do not mark the event complete. Return a non-2xx response so Stripe can retry.
Memory sets are not production storage
Serverless instances are recycled and concurrent instances do not share memory. Use Postgres, Redis with durable policy, or another atomic store.
Need the tested implementation?
The Hookproof kit includes the typed router, persistent idempotency adapters, fixtures, and deployment runbook.
GET THE $29 KIT