LogicTrail
  • Trails
  • Check my app
  • Pricing
  • Sign in
  1. Trails
  2. /
  3. Money and secrets
  4. · 5 minutes · Pro

The webhook that arrived twice

A customer bought one month of credits. Their account shows two months. Your dashboard shows one payment.

This answers: Why did my Stripe webhook run twice? No coding needed. 3 quick decisions.

  • Payments and webhooks
  • Where your data lives
  • Debugging without panic

Checking your access…

Why did my Stripe webhook run twice?

delivers at least once and retries when your endpoint is slow or fails, so the same event id can arrive twice. Record each processed event id in a table with a unique key and skip repeats, and always verify the signature against the raw request body.

Trail of the bug
  1. Stripe
  2. Your server
  3. Database

Breaks at Your server: Same event processed twice

How it works

One payment, two deliveriesRemember event ids
  1. 0sStripeSends evt_1Q8: 'checkout completed'
  2. 0–31sYour serverAdds one month of credits… but replies slowly
  3. 31sStripeNo reply in time, so it sends evt_1Q8 again
  4. 31sYour serverAdds a second month of credits
Without a record of event ids, the server treats the retry as a new payment and adds a second month.

Why AI tools write this bug

Generated handlers usually process every delivery as new. When signature verification fails because the body was parsed as JSON, AI fixes often remove the verification instead of reading the raw body.

How to fix it

  1. Verify the Stripe-Signature header against the raw request body.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock

Common questions

Why does Stripe signature verification keep failing?
Usually because the body was parsed as JSON before verification. Verify against the exact raw text Stripe sent.

Related scenarios

  • Off by one centPro · 4 min
  • One field, a million creditsPro · 4 min
  • Permission denied for tablePro · 4 min

More on this trail

Money and secrets: Keys, payments, webhooks, and reading what your AI changed.

Want someone to look?

We check AI-built apps for this and three other common leaks, in plain English.

Check my app
Sign in

Sign in to walk this one

3 decisions, about 5 minutes, and a prompt to check your own app for the same problem.

Sign in No password. We email you a link.

How to fix it

  1. Verify the Stripe-Signature header against the raw request body.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock