E-commerce and payments

What is Idempotency?

An idempotent operation produces the same result whether it runs once or many times. In payments it is what prevents a retried request from charging a customer twice, and what stops a redelivered webhook sending two confirmation emails.

Also called: idempotent request · idempotency key

Where it is required

  • Payment creation, using the provider’s idempotency key so a retry returns the original result
  • Webhook handling, by recording the event id and skipping anything already processed
  • Stock decrementing, which is the other place double-processing does visible damage
  • Any operation a network timeout might cause a client to repeat

The implementation detail people miss

Recording the event id in a separate step from the fulfilment leaves a race: two deliveries can both check, both find nothing, and both proceed. The record and the work must happen in the same transaction.

How to test it

Replay the same webhook twice deliberately and confirm exactly one order, one email and one stock movement result. It takes two minutes and it is almost never done.

Where this is covered in depth

A definition can only go so far. Stripe checkout integration, and the four failure modes nobody tests for covers this properly — 3 minutes, free, no email required.

Who wrote this

Anas Bin Masud builds e-commerce sites and does technical SEO for businesses in the UK, Canada and Pakistan. These definitions come from client work rather than from a content brief — where an entry describes a mistake, it is usually one found on a real site. More about how I work.

Related terms

All 184 terms in the glossary →

Want this handled rather than explained?

Send the brief and you get a reply within one business day — either questions, or a scoping call. If your project is not something I should take on, I will say so then.

Response
Replies within 1 business day
Hours
Mon–Fri, 09:00–18:00 PKT — overlaps 05:00–14:00 UK, 00:00–09:00 US Eastern
Booking
Booking projects from October 2026
WhatsApp — opens a chat with +92 346 5348466 in a new tab