[FIX] pos_adyen: polling response of adyen on correct line

closes odoo/odoo#90817

X-original-commit: 749e22335d871732c8c7c4e2bc798b811b26a034
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
Pierre Masereel
2022-05-07 17:06:49 +02:00
parent abf98caf13
commit fd5a5875e7
@@ -28,6 +28,11 @@ var PaymentAdyen = PaymentInterface.extend({
this.most_recent_service_id = id;
},
pending_adyen_line() {
return this.pos.get_order().paymentlines.find(
paymentLine => paymentLine.payment_method.use_payment_terminal === 'adyen' && (!paymentLine.is_done()));
},
// private methods
_reset_state: function () {
this.was_cancelled = false;
@@ -38,7 +43,7 @@ var PaymentAdyen = PaymentInterface.extend({
_handle_odoo_connection_failure: function (data) {
// handle timeout
var line = this.pos.get_order().selected_paymentline;
var line = this.pending_adyen_line();
if (line) {
line.set_payment_status('retry');
}
@@ -209,7 +214,7 @@ var PaymentAdyen = PaymentInterface.extend({
var notification = status.latest_response;
var last_diagnosis_service_id = status.last_received_diagnosis_id;
var order = self.pos.get_order();
var line = order.selected_paymentline;
var line = self.pending_adyen_line();
if (self.last_diagnosis_service_id != last_diagnosis_service_id) {
@@ -277,7 +282,7 @@ var PaymentAdyen = PaymentInterface.extend({
},
_adyen_handle_response: function (response) {
var line = this.pos.get_order().selected_paymentline;
var line = this.pending_adyen_line();
if (response.error && response.error.status_code == 401) {
this._show_error(_t('Authentication failed. Please check your Adyen credentials.'));