From 65a145c3ac27c04954165c2f55568c673ec9dbe5 Mon Sep 17 00:00:00 2001 From: Peter Ojo Date: Thu, 11 Mar 2021 16:25:11 +0100 Subject: [PATCH] [PW-4225] fix bug with adyen payment (#149) * [PW-4149] fix bug with adyen payment * [PW-4255] fix bug with adyen payment --- Resources/frontend/js/jquery.adyen-confirm-order.js | 12 +++++++++--- Subscriber/CheckoutSubscriber.php | 7 +------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Resources/frontend/js/jquery.adyen-confirm-order.js b/Resources/frontend/js/jquery.adyen-confirm-order.js index c10d4267..a9d91655 100644 --- a/Resources/frontend/js/jquery.adyen-confirm-order.js +++ b/Resources/frontend/js/jquery.adyen-confirm-order.js @@ -12,6 +12,7 @@ adyenType: '', adyenGoogleConfig: {}, adyenSetSession: {}, + adyenIsAdyenPayment: false, adyenAjaxDoPaymentUrl: '/frontend/adyen/ajaxDoPayment', adyenAjaxIdentifyShopperUrl: '/frontend/adyen/ajaxIdentifyShopper', adyenAjaxChallengeShopperUrl: '/frontend/adyen/ajaxChallengeShopper', @@ -50,8 +51,13 @@ checkSetSession: function () { var me = this; - if (!$.isEmptyObject(me.opts.adyenSetSession)) { - me.sessionStorage.setItem(me.paymentMethodSession, JSON.stringify(me.opts.adyenSetSession)); + if (me.opts.adyenIsAdyenPayment) { + if (!$.isEmptyObject(me.opts.adyenSetSession)) { + me.sessionStorage.setItem(me.paymentMethodSession, JSON.stringify(me.opts.adyenSetSession)); + } else if (!me.sessionStorage.getItem(me.paymentMethodSession)) { + this.addAdyenError(me.opts.adyenSnippets.errorTransactionNoSession); + return; + } } else { me.sessionStorage.removeItem(me.paymentMethodSession); } @@ -96,7 +102,7 @@ }, }); } else { - if ($('body').data('adyenisadyenpayment')) { + if (me.opts.adyenIsAdyenPayment) { this.addAdyenError(me.opts.adyenSnippets.errorTransactionNoSession); return; } diff --git a/Subscriber/CheckoutSubscriber.php b/Subscriber/CheckoutSubscriber.php index 357ea07c..29d0a52a 100644 --- a/Subscriber/CheckoutSubscriber.php +++ b/Subscriber/CheckoutSubscriber.php @@ -441,12 +441,6 @@ private function shouldRedirectToStep2(Shopware_Controllers_Frontend_Checkout $s $currency = Shopware()->Session()->sOrderVariables['sBasket']['sCurrencyName']; $value = Shopware()->Session()->sOrderVariables['sBasket']['AmountNumeric']; - if (0 === (int)$value) { - $this->revertToDefaultPaymentMethod($subject); - return false; - } - - $selectedType = $userData['additional']['user'][AdyenPayment::ADYEN_PAYMENT_PAYMENT_METHOD]; if ($selectedType === null) { @@ -481,6 +475,7 @@ private function revertToDefaultPaymentMethod(Shopware_Controllers_Frontend_Chec $userData = $subject->View()->getAssign('sUserData'); $userData['additional']['payment'] = $defaultPayment; $subject->View()->assign('sUserData', $userData); + $subject->View()->assign('sPayment', $defaultPayment); $subject->View()->clearAssign('sAdyenSetSession'); } }