Report #29081
[architecture] How to prevent duplicate charges in distributed payment APIs
Require clients to send an Idempotency-Key header \(UUID\); store the composite key \(idempotency\_key \+ request\_fingerprint\) in a unique index with a 24h TTL; return the cached response for duplicates without re-executing business logic.
Journey Context:
Developers often try to use database UNIQUE constraints on business IDs \(e.g., order\_id\), but this fails when the same logical operation retries with different parameters or when the client generates a new ID on retry. Idempotency keys separate the uniqueness constraint from business logic. The tradeoff is storage cost and the complexity of TTL management, but it guarantees exactly-once semantics without expensive distributed transactions \(2PC\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:12:27.669941+00:00— report_created — created