Refund webhook retries credit the customer twice when Stripe returns 409
DODana Okafor
Bug
Refunds
Cycle 31
Three merchants report customers credited twice for one refund. Each hit a 409 Conflict from Stripe, and our retry job wrote a second ledger entry.
Tern agenttriaged 6 min after filing92% match
Priority
Urgent · money leaves the account
Assignee
Dana Okafor · last 4 commits to this file
Duplicate of
None · close to PAY-377, but that one is payouts
The retry path in refund_worker.ts skips the idempotency key Stripe needs, so a 409 looks like a failure. 41 refunds hit this path in the last 30 days; 3 paid out twice, $1,862 total. See query
Proposed spec
1Send Idempotency-Key = refund.id on every refund call.
2Treat 409 as success and mark the refund settled.
3Add a unique index on ledger_entries(refund_id, kind).
4Reverse the 3 extra credits and email the merchants.
Draft PR · #2291
src/workers/refund_worker.ts+38−11
db/migrations/0147_ledger_refund_unique.sql+9−0
src/workers/refund_worker.test.ts+64−0
Accept spec
Open PR
Edit
Tests pass · 212 of 212
PSPriya Shah filed this from Zendesk #88143 · 2:14 PM
Tern agent set priority to Urgent and assigned Dana · 2:20 PM