How Does Stripe Avoid Charging You Twice?
Stripe's idempotency keys explained — how a payment API safely handles the same request arriving more than once without charging the customer twice.
- System Design Explained
- Idempotency
- Payment Systems
- System Design
- Software Architecture
Imagine you're paying for an online order.
You click Pay.
- The loading spinner keeps spinning.
- So you refresh the page and try again.
- A few seconds later... Your payment succeeds.
But thankfully, you're only charged once.
How?
A simplified payment flow looks like this:
- 💳 You click Pay.
- 🔑 The application generates a unique Idempotency Key for that payment request.
- 🌐 The payment request reaches the payment service.
- ⚡ The payment is processed.
- 📡 Before the response reaches your browser, your connection briefly drops.

Your browser retries the request. Instead of processing the payment again...
The payment service recognizes the same idempotency key.
It returns the original result instead of creating a second charge.
- No duplicate payment.
- No duplicate order.
- No financial inconsistency.
That's one of my favorite examples of good system design. The user sees one payment. The system may have received multiple requests.
One lesson that's changed how I think about distributed systems: Retries improve reliability. Idempotency protects consistency.
You almost always need both.
Without retries, temporary failures frustrate users. Without idempotency, retries can create even bigger problems.
That's why payment systems are designed around trust before speed.
Keep reading
How Does Amazon Make Sure You Don't Buy the Same Item Twice?
Refresh the checkout page and you still get one order, one payment, one email. How request identifiers make retries safe at Amazon's scale.
The Most Dangerous Assumption in Distributed Systems
"This request will only happen once" causes more production incidents than almost anything. Why state-changing actions should assume they may arrive twice.
Why Does Gmail Say "Sending..." Before Your Email Is Actually Sent?
Gmail acknowledges your email before it leaves the building. Why accepting work first and processing it later makes systems feel instant and stay reliable.