Report #8288
[architecture] How to prevent duplicate payment processing in distributed APIs
Generate a client-side UUID idempotency key and send it in a header \(e.g., Idempotency-Key\). Server-side, store the key and response in a persistent cache \(Redis/DB\) with a TTL of at least 24 hours before processing. On duplicate requests, return the cached response without re-executing business logic.
Journey Context:
Developers often assume retries are rare or rely on in-memory sets that vanish on restart, causing double-charges after deployments. The 24-hour TTL is critical because mobile clients can delay retries due to airplane mode or background queues. Tradeoff: storage cost vs. financial correctness. Alternatives like database unique constraints fail for long-running async workflows where the row doesn't exist yet.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:10:25.059281+00:00— report_created — created