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
What If Your AI Didn't Need to Generate Text?
The usual AI pipeline — prompt in, text out — breaks down the moment your application needs a decision instead of a paragraph. A typed-question approach can replace an entire generation-and-parsing pipeline.
Why Does Your AI Coding Agent Need to Understand Your Whole Codebase?
An AI coding agent can add role-based access, pass its tests, and still violate the authorization architecture already sitting around it — because writing code is easy, and knowing where it belongs is harder.
How Does Netflix Load Your Home Screen So Fast?
Netflix doesn't build your home screen after you open the app — it prepares most of it before you arrive. Why precomputation and caching beat request-time work.