From 8af6d576e96983288236c22447eb9bceac4e2347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Thu, 26 Nov 2026 16:42:11 -0300 Subject: [PATCH] fix: a quote this session no longer owns sends the customer back to the cart, not to an error (DTF-WEB-1Y) Co-Authored-By: Claude Opus 5.5 (1M context) --- web/checkout.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/checkout.js b/web/checkout.js index ab1cd56..001e145 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -573,7 +573,7 @@ if (naPagina() && !actions.children.length) esqueletoPagamento(); try { await ready; - const quote=await api('/quotes/'+shownId); + const quote=await api('/quotes/'+shownId,undefined,{expected:[404]}); if(version!==refreshVersion || draftId!==shownId) return; // Asked to pay a cart identical to one already paid (the same test // repeated): that is a new order, never the paid one shown again. The @@ -628,6 +628,15 @@ } } catch(error) { if(version!==refreshVersion || draftId!==shownId) return; + // The quote this browser remembers is not this session's any more (the + // session changed, or it is gone): an old reference, not an error + // (Sentry DTF-WEB-1Y). The cart is still here to send again. + if(error.status===404){ + clearDraft(); + message('Este pagamento não está mais disponível nesta sessão. Seu carrinho continua aqui: envie de novo para pagar.','warn'); + button('Voltar ao carrinho',()=>vaiPara(CARRINHO)); + return; + } message(error.message,'error'); actions.replaceChildren(); button('Limpar referência e tentar de novo',clearDraft);