In plain words
A webhook is a request another service sends to your server when something happens, like a payment succeeding, so your app can react without asking repeatedly.
Where you see it
After a QuickBite order is paid, Stripe sends checkout.session.completed to /api/webhooks/stripe. If your server is slow or errors, Stripe sends it again, which is how one order reaches the kitchen twice.
What goes wrong
- Skipping the signature check
Without it, anyone who finds the URL can post a fake "payment succeeded" event and collect free orders.
const event = await req.json(); // trusted blindly - Processing the same event twice
Providers may deliver an event more than once, so duplicates are normal. Save each event ID and skip ones you've seen; this is called making the handler idempotent.
- Doing slow work before replying
A handler that sends emails and builds PDFs before replying can make Stripe give up waiting and resend. Record the event, reply 200, and hand the slow part to a background job.
What to tell your agent
Quick check
Sign in to earn +10 XP for itA customer was charged once, but two identical QuickBite orders appeared. Most likely?