[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#101252 X-original-commit: 6ea920d2573cf68c6a5cbaf1f6af31fd7de155ff Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
committed by
Walid HANNICHE (waha)
parent
bc0716e767
commit
9d7c2bc391
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user