diff --git a/web/checkout.js b/web/checkout.js index ba57974..293348f 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -23,12 +23,14 @@ files:(item.localFiles||[]).map(file=>({name:file.name,size:file.size,lastModified:file.lastModified})) }))}); } - function clearDraft() { + // The quote this browser is paying, forgotten. clearDraft also empties the + // payment area; forgetDraft leaves on screen what is there (a confirmation). + function forgetDraft() { draftId=null;quotedCart=null;requestKey=null;requestBody=null; for(const key of ['dtf-quote','dtf-quote-cart','dtf-request-key','dtf-request-body']) localStorage.removeItem(key); - actions.replaceChildren(); } + function clearDraft() { forgetDraft(); actions.replaceChildren(); } const api = async (path, body) => { const response = await fetch('/api'+path, { credentials: 'same-origin', headers: {'Content-Type':'application/json'}, @@ -324,6 +326,8 @@ await ready; const quote=await api('/quotes/'+shownId); if(version!==refreshVersion || draftId!==shownId) return; + // Asked to pay a cart identical to one already paid: that is a new order. + if (go && quote.status==='paid') { forgetDraft(); return window.dtfCheckout(); } if (!naPagina()) { message(''); vaiPara(PAGAMENTO); return; } shownCart=cartSnapshot(); clearInterval(pixClock); @@ -415,6 +419,9 @@ } function confirmado(quote) { clearInterval(waitTimer); + // Paid: the next cart is a new order, even one identical to this (the same + // test repeated), never this quote shown again as already paid. + forgetDraft(); const box=node('div',null,'confirmado'); const titulo=node('h4','Pagamento confirmado'); titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));