Skip to content
Snippets Groups Projects
Commit 0420a0b6 authored by Walid HANNICHE (waha)'s avatar Walid HANNICHE (waha)
Browse files

[FIX] payment: fix payment processing payment_redirect

Steps to reproduce:
- create and send a quotation
- make a failed payment (through cutomer preview)
- create and send a second quotation to the same customer
- make a succesful payment this time
- redirect takes to the wrong quotation (failed one)

Bug:
polling the processed payments initially returns both transaction
but the following polls only returns the rejected payment
(introduced in [1] processed transactions are filtered out)
since there's only a single transaction, redirect takes to it

Fix:
if there's only a single succesful transaction (regardless of the rest)
it means the current payment was successfull so we redirect to it

opw-2954162

[1]:https://github.com/odoo/odoo/pull/31741/commits/7612659565ee24f1c878b81e6c86b5780fbd5a3d



closes odoo/odoo#99969

Signed-off-by: default avatarAntoine Vandevenne (anv) <anv@odoo.com>
parent daec19f7
No related branches found
No related tags found
No related merge requests found
......@@ -93,9 +93,26 @@ odoo.define('payment.processing', function (require) {
}
return nbTx;
}
// if there's only one tx to manage
/*
* When the server sends the list of monitored transactions, it tries to post-process
* all the successful ones. If it succeeds or if the post-process has already been made,
* the transaction is removed from the list of monitored transactions and won't be
* included in the next response. We assume that successful and post-process
* transactions should always prevail on others, regardless of their number or state.
*/
if (render_values['tx_done'].length === 1 &&
render_values['tx_done'][0].is_processed) {
window.location = render_values['tx_done'][0].return_url;
return;
}
// If there are multiple transactions monitored, display them all to the customer. If
// there is only one transaction monitored, redirect directly the customer to the
// landing route.
if(countTxInState(['tx_done', 'tx_error', 'tx_pending', 'tx_authorized']) === 1) {
var tx = render_values['tx_done'][0] || render_values['tx_authorized'][0] || render_values['tx_error'][0];
// We don't want to redirect customers to the landing page when they have a pending
// transaction. The successful transactions are dealt with before.
var tx = render_values['tx_authorized'][0] || render_values['tx_error'][0];
if (tx) {
window.location = tx.return_url;
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment