Concurrent Payment Webhook Retries Credit an Account Twice
Level 3 · node · Concurrency · Non-atomic webhook idempotency
Scenario
A payment-completed webhook service checks whether an eventId was already processed, credits the customer, and then records the event as completed. Sequential retries are ignored correctly, but operations reports that when the provider delivers the same event almost simultaneously, both requests can pass the duplicate check and credit the account twice. The service, event repository, and credit repository are separate.
Requirements
- The same eventId credits an account at most once regardless of delivery count - Concurrent processing of the same event allows only one successful credit - Different eventIds are processed normally and independently - A retry of an already completed event returns a skipped result - Reported processing results match the actual credit balance
Acceptance criteria
- The first payment event adds credit exactly once
- A sequential retry of a completed event is skipped
- Two concurrent deliveries of the same event produce only one credit
- Two different events are both credited
- After concurrent duplicate handling, the event record and balance match a single processing