Duplicate Payment Webhooks Can Double-Credit Accounts Without Atomic Dedupe

Payment providers retry webhooks whenever an endpoint is slow or a response is lost, so a handler can receive the same event twice. A common pattern that checks for an existing event ID before inserting fails when two deliveries arrive close together, because both checks pass before either write completes. In a reproduction on a SQL Server ledger, a 1,500.00 payment was credited twice, with both requests returning success. Wrapping the check and insert in a transaction did not prevent the race under default isolation levels. Adding a unique constraint on the event ID let the database enforce a single credit, though the duplicate request then returned an error, which can trigger alerts and provider-side retries.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in