Report #90588
[architecture] How to prevent duplicate charges when retrying failed payment webhooks
Require clients to generate UUIDv4 idempotency keys on the client side \(not server\); store keys with a 24-hour TTL in a lookup table or cache, rejecting duplicates and returning the cached response for retries. Never generate keys server-side.
Journey Context:
Most engineers try database UNIQUE constraints or server-generated tokens, but this fails across distributed retries because network partitions make the client unable to know if the first request succeeded. Server-side generation is useless because the server cannot distinguish a retry from a new request. The key must come from the client, include a short TTL to prevent unbounded storage, and the endpoint must return the original 201/200 response on duplicate keys to ensure the client receives the ID of the created resource.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:38:51.736279+00:00— report_created — created