fix: a new cart goes to payment instead of showing the last order already paid
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 3m19s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 3m19s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped
After a payment the browser kept the paid quote as its draft, so a cart identical to it (the same test repeated) opened the old "Pagamento confirmado" instead of a payment. The confirmation now forgets the draft, and a draft found already paid when the customer asks to pay starts a new order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,12 +23,14 @@
|
|||||||
files:(item.localFiles||[]).map(file=>({name:file.name,size:file.size,lastModified:file.lastModified}))
|
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;
|
draftId=null;quotedCart=null;requestKey=null;requestBody=null;
|
||||||
for(const key of ['dtf-quote','dtf-quote-cart','dtf-request-key','dtf-request-body'])
|
for(const key of ['dtf-quote','dtf-quote-cart','dtf-request-key','dtf-request-body'])
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
actions.replaceChildren();
|
|
||||||
}
|
}
|
||||||
|
function clearDraft() { forgetDraft(); actions.replaceChildren(); }
|
||||||
const api = async (path, body) => {
|
const api = async (path, body) => {
|
||||||
const response = await fetch('/api'+path, {
|
const response = await fetch('/api'+path, {
|
||||||
credentials: 'same-origin', headers: {'Content-Type':'application/json'},
|
credentials: 'same-origin', headers: {'Content-Type':'application/json'},
|
||||||
@@ -324,6 +326,8 @@
|
|||||||
await ready;
|
await ready;
|
||||||
const quote=await api('/quotes/'+shownId);
|
const quote=await api('/quotes/'+shownId);
|
||||||
if(version!==refreshVersion || draftId!==shownId) return;
|
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; }
|
if (!naPagina()) { message(''); vaiPara(PAGAMENTO); return; }
|
||||||
shownCart=cartSnapshot();
|
shownCart=cartSnapshot();
|
||||||
clearInterval(pixClock);
|
clearInterval(pixClock);
|
||||||
@@ -415,6 +419,9 @@
|
|||||||
}
|
}
|
||||||
function confirmado(quote) {
|
function confirmado(quote) {
|
||||||
clearInterval(waitTimer);
|
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 box=node('div',null,'confirmado');
|
||||||
const titulo=node('h4','Pagamento confirmado');
|
const titulo=node('h4','Pagamento confirmado');
|
||||||
titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));
|
titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));
|
||||||
|
|||||||
Reference in New Issue
Block a user