Re-tokenize fresh after a definitive card charge failure in all nonce flows

A cnon: nonce and its SCA verification token are consumed by a definitive charge failure (e.g. declined card) and can never succeed again, but TipPayment, UserBookingModal, UserPaymentModal and the account-page Buy-a-Gift-Card cached them and resubmitted the dead nonce on every retry — a non-retryable failure loop. The nonce/verification-token/amount/timestamp cache is now cleared in each error branch so retries re-tokenize fresh, while the idempotency key is kept for network-timeout dedup.
This commit is contained in:
2026-08-22 00:34:49 +01:00
parent 5605402e13
commit 965da86b64
4 changed files with 38 additions and 0 deletions
@@ -464,6 +464,15 @@
const msg = _err instanceof Error ? _err.message : 'Payment declined';
error = msg;
toast.error(`${msg}. Please try again or use another card.`);
// A definitive charge failure consumes the nonce + SCA verification
// token — clear the cached pair so retries re-tokenize fresh. The
// idempotency key stays for network-timeout dedup. CardSelection stays
// mounted on error, so this also stops a user who corrects their card
// digits from resubmitting the old nonce for the new card.
newCardNonce = '';
newCardVerificationToken = '';
newCardTokenAmount = 0;
newCardTokenizedAt = 0;
releaseLock();
}
}