fix: the Site stops waiting for a payment's order once the page lets the quote go (DTF-WEB-29)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 8m10s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m7s
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 8m10s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m7s
waitForOrder polled /quotes/<draftId> every 3 s after a PIX or a card challenge; "Voltar ao carrinho" (an expired PIX) cleared draftId and the poll went on asking /quotes/null, which reached Sentry as a 422. The wait now keeps the quote it started for and stops when the page's quote changes or is gone, and each wait clears only its own timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -679,21 +679,31 @@
|
|||||||
let waitTimer=null;
|
let waitTimer=null;
|
||||||
function waitForOrder() {
|
function waitForOrder() {
|
||||||
clearInterval(waitTimer);
|
clearInterval(waitTimer);
|
||||||
waitTimer=setInterval(async()=>{
|
// The quote it waits for. When the page lets it go ("Voltar ao carrinho"
|
||||||
|
// after an expired PIX, another cart), the wait stops: it asked for
|
||||||
|
// /quotes/null every 3 s (Sentry DTF-WEB-29).
|
||||||
|
const waited=draftId;
|
||||||
|
if (!waited) return;
|
||||||
|
// Each wait stops only its own timer: an answer still on its way when a
|
||||||
|
// new wait starts must not stop the new one.
|
||||||
|
const timer=setInterval(async()=>{
|
||||||
|
if (draftId!==waited) { clearInterval(timer); return; }
|
||||||
try {
|
try {
|
||||||
const quote=await api('/quotes/'+draftId);
|
const quote=await api('/quotes/'+waited);
|
||||||
|
if (draftId!==waited) { clearInterval(timer); return; }
|
||||||
if (quote.status==='paid') {
|
if (quote.status==='paid') {
|
||||||
clearInterval(waitTimer);
|
clearInterval(timer);
|
||||||
await pagos();
|
await pagos();
|
||||||
await refresh();
|
await refresh();
|
||||||
} else if (quote.payment?.status==='rejected') {
|
} else if (quote.payment?.status==='rejected') {
|
||||||
// Refused after the bank's confirmation or the provider's review.
|
// Refused after the bank's confirmation or the provider's review.
|
||||||
clearInterval(waitTimer);
|
clearInterval(timer);
|
||||||
await refresh();
|
await refresh();
|
||||||
message(quote.payment.message||'O pagamento foi recusado. Tente de novo ou escolha outra forma de pagamento.','error');
|
message(quote.payment.message||'O pagamento foi recusado. Tente de novo ou escolha outra forma de pagamento.','error');
|
||||||
}
|
}
|
||||||
} catch(_) {}
|
} catch(_) {}
|
||||||
},3000);
|
},3000);
|
||||||
|
waitTimer=timer;
|
||||||
}
|
}
|
||||||
// 3-D Secure: the bank's own page, opened by posting its request in a frame.
|
// 3-D Secure: the bank's own page, opened by posting its request in a frame.
|
||||||
function showChallenge(challenge, into) {
|
function showChallenge(challenge, into) {
|
||||||
|
|||||||
Reference in New Issue
Block a user