Opendiego-ferreira wants to merge 3 commits into main from df/charge-idempotency· opened 4 days ago
+85−1
diego-ferreira commented 4 days agoAuthor
Why
Merchant SDKs retry on network timeouts and we have seen a few customers charged twice. Stripe-style
idempotency keys fix that on our side.
What
POST /charges now requires an Idempotency-Key header.
If we have already stored a response for the key, we return it without calling the PSP again.
Otherwise we create the charge at the PSP and store the response under the key.
New idempotency_records table (migration in the next PR).
Testing
Sent the same request twice against the PSP test mode with curl: second call returned the stored response
and no second charge showed up in the PSP dashboard.
diego-ferreira added 3 commits 4 days ago
Add IdempotencyRecord modelc160924
Add idempotency service helpersc26093d
Create charges endpoint using idempotency keysc360956
Why
Merchant SDKs retry on network timeouts and we have seen a few customers charged twice. Stripe-style idempotency keys fix that on our side.
What
POST /chargesnow requires anIdempotency-Keyheader.idempotency_recordstable (migration in the next PR).Testing
Sent the same request twice against the PSP test mode with curl: second call returned the stored response and no second charge showed up in the PSP dashboard.