Idempotency
also: idempotent, idempotency key, idempotency keys
Doing the same action twice has the same result as doing it once. Tapping "Pay" twice should still charge the card only once.
An operation is idempotent if repeating it produces the same end state as running it once. It matters because networks retry and people double-click. Payment APIs often accept an idempotency key so repeated requests are recognized and ignored.
Pressing an elevator button five times doesn't summon five elevators. The first press does the work. The extra presses change nothing.
Real users double-click, refresh, and lose signal mid-request. Apps and services also retry automatically. If charging a card or sending an email isn't idempotent, every repeat does it again. Ask about this for anything involving money or messages.
The webhook handler isn't idempotent. Stripe can deliver the same event more than once, so I'll store processed event IDs and skip duplicates.
Make the checkout request idempotent so a double-click or an automatic retry can never charge the customer twice. Explain how you detect duplicates.
Thinking that disabling the button after one click is enough. It helps, but retries, slow networks, and duplicate webhooks can still send the same request twice. The server must handle repeats safely.