Bugpit

Lessons › Real apps

Stripe: the order that never shipped

From Black Friday to Cyber Monday 2025, businesses on Stripe took more than 578 million payments, up to 152,000 a minute. Your shop is one of them: 3,000 req/s at the peak, and 3 in 100 are people paying, 90 a second. Payments work. But support says some people paid and never got their order, and a few got it twice.

Play this level

Part of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

A payment doesn't end when the card is charged. Stripe sends the buyer's browser back to your site, and separately calls your server with a webhook: a message saying the payment went through.

Your shop sends the order when the browser comes back. But a buyer who closes the tab or loses signal has paid and never comes back. The webhook arrives anyway, so the webhook is what should send the order. The thank-you page is just a page.

Webhooks come at least once, not exactly once. Stripe says the same event can arrive twice, and in any order. Save each event's ID when you handle it and skip any ID you've already seen. For order, don't trust which event came last: ask Stripe for the payment's current state.

Answer fast. If your handler saves the order, emails the receipt and books the courier before replying, slow ones time out. Stripe marks them failed and sends them again, for up to three days. Save the event, answer OK, and let a worker do the rest from a queue.

What you have to achieve

3,000 requests a second at the busiest hour, 3% of them writes.

What you learn

Treat a webhook like a letter: it can come late, twice or out of order, so save it, answer, and act on it once. Every provider that calls you back works this way, so the same three ticks apply to PayPal, Razorpay, Shopify and GitHub.

The real numbers behind it

Check yourself

A buyer pays, then closes the tab before Stripe sends them back to your site. What sends their order?

Show the answer

The webhook Stripe sends to your server. The webhook arrives whether or not the browser comes back. The thank-you page is only for the buyer.

The same payment_intent.succeeded event arrives twice. What stops the order going out twice?

Show the answer

Saving each event's ID and skipping any ID already handled. Stripe says events can repeat and arrive in any order, so it tells you to track event IDs, not times.

Why answer a webhook before emailing the receipt and booking the courier?

Show the answer

A slow answer times out, and Stripe sends the event again. Stripe treats a slow reply as a failure and retries for up to three days. Save it, answer, then work from a queue.

Try it yourself

More in Real apps

← UPI: 25 billion payments a month Video platform: upload to play →