Payment systems must never charge twice:
Idempotency key: Client generates unique ID per payment intent. Server checks if already processed.
Implementation:
1. Receive request with idempotency_key
2. Check database for existing result
3. If found, return cached result
4. If not, process payment
5. Store result with key
6. Return result
Key storage: Keep keys for - hours minimum.
Distributed challenge: Use database transaction to check-and-insert atomically.
Client retry: Safe to retry with same key. Different key = different charge.