Reuse the payment key when checkout retries. Reproduce the timeout and add a regression test.
Claude Code
Read the checkout decision from team memory
Traced the payment adapter and its callers
Reproduced the provider timeout
The retry creates a new key even though the first charge may have succeeded. I’m keeping the original key and adding a regression test.
Codex · teammate
The order activity view will group these attempts by payment key.
shop/checkout.js
Change ready to inspect
storefront / changes
Keep payment identity across retries
Sample changefix/checkout-retryintomain
1 changed file+1−1
shop/checkout.js+1−1
@@ -1,5 +1,5 @@
11// One payment identity, even when the request is retried.
22function retryCheckout(order, payments) {
3− const key = payments.newAttemptKey();
3+ const key = order.paymentKey;
44 return payments.charge(order.total, key);
55}
fix/checkout-retryStorefront
Preserve the payment key on retry
Proposalcheckout/retry→main
shop/checkout.py
12
13
14
15
16
17
def retry_checkout(order):
reserve_stock(order.sku, order.quantity)
return payments.charge(
order.total,
idempotency_key=order.payment_key,
)
End of changes
Move between the diff, review and change summary.
Review the change with the evidence beside it.
storefront
Storefront overview
Storefront coordinates the order lifecycle across checkout, inventory, and payments. Each module owns its part of the transaction.
Relevant source files
shop/checkout.py
↓
How checkout works
Checkout reserves inventory, creates a charge with the order’s payment key, and records the order. The payment key stays the same when an attempt is retried.