Home / patterns

Webhooks processed twice: duplicate payments, emails and orders

A worker's hands pausing over two identical brown shipping boxes with identical blank packing slips on a packing table, a tablet beside them showing a blurred order list with two matching rows highlighted, a tape gun nearby, no brand logos
Quick answer: AI-generated webhook handlers usually assume each event arrives exactly once. Payment, store and code-hosting platforms say otherwise: Stripe notes your endpoint might occasionally receive the same event more than once and doesn’t guarantee event order; Shopify says your app might get the same webhook more than once after a timeout or retry. If your handler emails a receipt, adds credits, creates an order or ships a product every time it runs, a retry can do it twice. Attackers can also replay a captured delivery. The fix is to record each event ID you’ve processed and skip repeats, verify the signature and timestamp, and return a 2xx quickly.

Last updated November 13, 2026

Steps

  1. Find every webhook endpoint in your app (payments, store, auth, Git hosting, email provider) and write down what side effects each one causes.
  2. Verify the signature on every request with the provider’s library and the raw request body, and keep the timestamp check on; Stripe’s libraries use a 5-minute default tolerance and warn not to set it to 0.
  3. Store the unique delivery or event ID (Stripe event id, Shopify X-Shopify-Webhook-Id, GitHub X-GitHub-Delivery) in a table with a unique constraint, and skip any event you’ve already recorded.
  4. Insert the event ID and do the work in one database transaction, or use the unique constraint as a lock, so two copies arriving at the same moment can’t both run.
  5. Don’t rely on event order: Stripe says not to use the created timestamp to decide order or whether you’ve already processed an event. Fetch the current object from the API when order matters.
  6. Return a 2xx quickly and move slow work (emails, fulfillment) to a background job keyed by the same event ID.
  7. Make the side effects themselves safe to repeat where you can, for example “set status to paid” instead of “add 100 credits.”
  8. Retest: resend the same event from the provider’s dashboard or CLI and confirm only one email, credit or order results.

Why it matters

Stripe retries live-mode deliveries for up to three days when your endpoint doesn’t return 2xx, and a manual resend doesn’t cancel the automatic retries, so duplicates are normal, not rare. Stripe also says two separate Event objects can be sent for the same change; to catch those, combine the ID of the object in data.object with the event type. GitHub’s webhook guidance suggests using the X-GitHub-Delivery header to protect against replay attacks, and notes that a redelivery keeps the same delivery ID. This page is for checking and fixing your own app.

Sources

Stripe Docs: Receive Stripe events in your webhook endpoint (handle duplicate events, event ordering, retries, replay protection) — https://docs.stripe.com/webhooks

Shopify Dev Docs: Verify webhook deliveries (ignoring duplicates) — https://shopify.dev/docs/apps/build/webhooks/ignore-duplicates

GitHub Docs: Best practices for using webhooks — https://docs.github.com/en/webhooks/using-webhooks/best-practices-for-using-webhooks

Checked at the source on November 13, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.