The page spins for nine seconds. You press again.
transcript
Place your order. The page spins. And spins. Nine seconds. You press it again. Did you just buy it twice?
The network only promises at least once. A request that timed out may have happened anyway. Or not.
The trick is a purchase id. But where does it come from? One per click? Two clicks, two orders, two charges. One per page. Made when checkout loads. The double press and the retry share it.
First press. Checkout asks: seen this id? No. Reserve the stock, keyed by the same id. Then write the id and order together. Crash halfway? You get all of it, or none. Second press. Seen this id? Yes. Here's the same order.
But here's the catch. Same id, different cart? That's not a retry. Reject it, and ask them to review the cart.
Never answer a retry with already exists. Give back the same order instead. Now retries are invisible.
Full breakdown in the lecture.