Create charges with Idempotency-Key support #2003

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

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick