Skip to content

Commit

Permalink
[FIX] payment: fix payment processing payment_redirect
Browse files Browse the repository at this point in the history
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]:odoo@7612659

closes odoo#100440

X-original-commit: 0420a0b
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
  • Loading branch information
d-fence authored and HANNICHE-Walid committed Sep 27, 2022
1 parent 9ba8e65 commit 6ea920d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions addons/payment/static/src/js/post_processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,26 @@ odoo.define('payment.post_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_post_processed) {
window.location = render_values['tx_done'][0].landing_route;
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.landing_route;
return;
Expand Down

0 comments on commit 6ea920d

Please sign in to comment.