From cb606256ceaa9e150b20b5345daf155ef2d6b5e8 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 24 Sep 2025 16:06:43 -0400 Subject: [PATCH] Restore automatic redirect on payment confirmation via JavaScript polling - Add redirect logic when status changes from non-confirmed to confirmed - Only redirect when detected via JavaScript polling, not when browsing to already-confirmed quote - Uses existing lastKnownStatus tracking to detect legitimate status changes - 2 second delay to show confirmation message before redirect - Fixes regression where payments stayed on quote page after confirmation --- make_post_sell/templates/crypto_checkout.j2 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/make_post_sell/templates/crypto_checkout.j2 b/make_post_sell/templates/crypto_checkout.j2 index c0901de..35ce460 100644 --- a/make_post_sell/templates/crypto_checkout.j2 +++ b/make_post_sell/templates/crypto_checkout.j2 @@ -372,13 +372,21 @@ expiresEl.parentNode.style.display = 'none'; } } else if (currentStatus === 'confirmed' || currentStatus === 'confirmed-overpaid') { - // Payment confirmed - replace with invoice link and redirect + // Payment confirmed - replace with invoice link replaceButtonsWithInvoiceLink(data.invoice_url); // Hide countdown if (expiresEl && expiresEl.parentNode) { expiresEl.parentNode.style.display = 'none'; } + + // Redirect only if status changed from non-confirmed to confirmed (via polling) + // Don't redirect if user browsed directly to already-confirmed quote + if (lastKnownStatus && lastKnownStatus !== 'confirmed' && lastKnownStatus !== 'confirmed-overpaid' && data.redirect_url) { + setTimeout(() => { + window.location.href = data.redirect_url; + }, 2000); // 2 second delay to show confirmation message + } } else if (terminalStatuses.includes(currentStatus)) { // Terminal status - replace with invoice link replaceButtonsWithInvoiceLink(data.invoice_url);