From b8a6d8095c13d889cf2291c42705cdcfa78ab952 Mon Sep 17 00:00:00 2001 From: tomjas1997 Date: Wed, 16 Nov 2022 16:18:05 +0200 Subject: [PATCH 1/3] SL-133 iframe fail issues --- controllers/front/fail.php | 5 +++++ controllers/front/notify.php | 8 +++----- controllers/front/successHosted.php | 6 ++---- controllers/front/successIFrame.php | 14 ++++---------- src/Service/SaferPay3DSecureService.php | 1 - 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/controllers/front/fail.php b/controllers/front/fail.php index be498353d..de48cd5c4 100755 --- a/controllers/front/fail.php +++ b/controllers/front/fail.php @@ -23,6 +23,7 @@ use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Controller\AbstractSaferPayController; +use Invertus\SaferPay\Service\CartDuplicationService; use PrestaShop\PrestaShop\Adapter\Order\OrderPresenter; class SaferPayOfficialFailModuleFrontController extends AbstractSaferPayController @@ -86,6 +87,10 @@ public function init() if ($order->module !== $this->module->name) { Tools::redirect($redirectLink); } + + $cartDuplicationService = $this->module->getService(CartDuplicationService::class); + $cartDuplicationService->restoreCart($this->id_cart); + $this->order_presenter = new OrderPresenter(); } diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 784003986..1b97a0277 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -57,8 +57,8 @@ public function postProcess() //NOTE must be left below assert action to get newest information. $order = new Order($orderId); - /** @var SaferPay3DSecureService $secureService */ - $secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class); + /** @var SaferPayOrderStatusService $orderStatusService */ + $orderStatusService = $this->module->getModuleContainer()->get(SaferPayOrderStatusService::class); $paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D); @@ -67,7 +67,7 @@ public function postProcess() in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) && $paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL ) { - $secureService->cancelPayment($order); + $orderStatusService->cancel($order); die($this->module->l('Liability shift is false', self::FILENAME)); } @@ -81,8 +81,6 @@ public function postProcess() $paymentBehaviour === SaferPayConfig::DEFAULT_PAYMENT_BEHAVIOR_CAPTURE && $assertResponseBody->getTransaction()->getStatus() !== 'CAPTURED' ) { - /** @var SaferPayOrderStatusService $orderStatusService */ - $orderStatusService = $this->module->getModuleContainer()->get(SaferPayOrderStatusService::class); $orderStatusService->capture($order); } } catch (Exception $e) { diff --git a/controllers/front/successHosted.php b/controllers/front/successHosted.php index 51d70f673..f590faeab 100755 --- a/controllers/front/successHosted.php +++ b/controllers/front/successHosted.php @@ -73,16 +73,14 @@ public function postProcess() $selectedCard ); - /** @var SaferPay3DSecureService $secureService */ - $secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class); - $paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D); if ( !$authResponseBody->getLiability()->getLiabilityShift() && + in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) && $paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL ) { - $secureService->cancelPayment($order); + $orderStatusService->cancel($order); $this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME); diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index 9c66a1d97..c176d3028 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -78,7 +78,7 @@ public function postProcess() $this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME); $this->redirectWithNotifications($this->context->link->getModuleLink( $this->module->name, - ControllerName::FAIL_VALIDATION, + ControllerName::FAIL_IFRAME, [ 'cartId' => $cartId, 'secureKey' => $secureKey, @@ -89,23 +89,20 @@ public function postProcess() )); } - /** @var SaferPay3DSecureService $secureService */ - $secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class); - $paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D); if ( - $authResponseBody->getLiability()->getThreeDs() && !$authResponseBody->getLiability()->getLiabilityShift() && + in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) && $paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL ) { - $secureService->cancelPayment($order); + $orderStatusService->cancel($order); $this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME); $this->redirectWithNotifications($this->context->link->getModuleLink( $this->module->name, - ControllerName::FAIL, + ControllerName::FAIL_IFRAME, [ 'cartId' => $cartId, 'secureKey' => $secureKey, @@ -125,10 +122,7 @@ public function postProcess() $authResponseBody->getLiability()->getThreeDs() ) { $orderStatusService->capture($order); - Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey)); } - - Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey)); } public function initContent() diff --git a/src/Service/SaferPay3DSecureService.php b/src/Service/SaferPay3DSecureService.php index a3050b22f..b29c9b882 100755 --- a/src/Service/SaferPay3DSecureService.php +++ b/src/Service/SaferPay3DSecureService.php @@ -60,7 +60,6 @@ public function __construct( */ public function cancelPayment(Order $order) { - $this->cartDuplicationService->restoreCart($order->id_cart); $this->orderStatusService->cancel($order); } } From e62123ef44bfaae37a3368d1fe8b62600dfe64b5 Mon Sep 17 00:00:00 2001 From: tomjas1997 Date: Wed, 16 Nov 2022 16:20:09 +0200 Subject: [PATCH 2/3] Removal 3d secure service --- config/service.yml | 7 --- controllers/front/notify.php | 3 -- controllers/front/successHosted.php | 3 -- controllers/front/successIFrame.php | 3 -- src/Service/SaferPay3DSecureService.php | 65 ------------------------- 5 files changed, 81 deletions(-) delete mode 100755 src/Service/SaferPay3DSecureService.php diff --git a/config/service.yml b/config/service.yml index 0acfb3385..222d296d5 100755 --- a/config/service.yml +++ b/config/service.yml @@ -169,13 +169,6 @@ services: Invertus\SaferPay\Service\CartDuplicationService: class: Invertus\SaferPay\Service\CartDuplicationService - Invertus\SaferPay\Service\SaferPay3DSecureService: - class: Invertus\SaferPay\Service\SaferPay3DSecureService - arguments: - - '@Invertus\SaferPay\Service\SaferPayOrderStatusService' - - '@Invertus\SaferPay\Repository\SaferPayOrderRepository' - - '@Invertus\SaferPay\Service\CartDuplicationService' - Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate: class: Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate arguments: diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 1b97a0277..4db55b88a 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -24,11 +24,8 @@ use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Controller\AbstractSaferPayController; use Invertus\SaferPay\DTO\Response\Assert\AssertBody; -use Invertus\SaferPay\Repository\SaferPayOrderRepository; -use Invertus\SaferPay\Service\SaferPay3DSecureService; use Invertus\SaferPay\Service\SaferPayOrderStatusService; use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAssertion; -use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionRefundAssertion; class SaferPayOfficialNotifyModuleFrontController extends AbstractSaferPayController { diff --git a/controllers/front/successHosted.php b/controllers/front/successHosted.php index f590faeab..5e1290ea9 100755 --- a/controllers/front/successHosted.php +++ b/controllers/front/successHosted.php @@ -23,10 +23,7 @@ use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Controller\AbstractSaferPayController; -use Invertus\SaferPay\DTO\Response\Assert\AssertBody; use Invertus\SaferPay\Enum\ControllerName; -use Invertus\SaferPay\Repository\SaferPayOrderRepository; -use Invertus\SaferPay\Service\SaferPay3DSecureService; use Invertus\SaferPay\Service\SaferPayOrderStatusService; use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAuthorization; diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index c176d3028..8d31fc827 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -26,9 +26,6 @@ use Invertus\SaferPay\Controller\AbstractSaferPayController; use Invertus\SaferPay\Enum\ControllerName; use Invertus\SaferPay\Exception\Api\SaferPayApiException; -use Invertus\SaferPay\Repository\SaferPayOrderRepository; -use Invertus\SaferPay\Service\Request\AuthorizationRequestObjectCreator; -use Invertus\SaferPay\Service\SaferPay3DSecureService; use Invertus\SaferPay\Service\SaferPayOrderStatusService; use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAuthorization; diff --git a/src/Service/SaferPay3DSecureService.php b/src/Service/SaferPay3DSecureService.php deleted file mode 100755 index b29c9b882..000000000 --- a/src/Service/SaferPay3DSecureService.php +++ /dev/null @@ -1,65 +0,0 @@ - - *@copyright SIX Payment Services - *@license SIX Payment Services - */ - -namespace Invertus\SaferPay\Service; - -use Configuration; -use Invertus\SaferPay\Config\SaferPayConfig; -use Invertus\SaferPay\Repository\SaferPayOrderRepository; -use Order; -use SaferPayOrder; - -class SaferPay3DSecureService -{ - - /** - * @var SaferPayOrderStatusService - */ - private $orderStatusService; - /** - * @var SaferPayOrderRepository - */ - private $orderRepository; - /** - * @var CartDuplicationService - */ - private $cartDuplicationService; - - public function __construct( - SaferPayOrderStatusService $orderStatusService, - SaferPayOrderRepository $orderRepository, - CartDuplicationService $cartDuplicationService - ) { - $this->orderStatusService = $orderStatusService; - $this->orderRepository = $orderRepository; - $this->cartDuplicationService = $cartDuplicationService; - } - - /** - * @param Order $order - */ - public function cancelPayment(Order $order) - { - $this->orderStatusService->cancel($order); - } -} From 27a57711fea4d7e35aafdae138029e7e1d43f451 Mon Sep 17 00:00:00 2001 From: tomjas1997 Date: Wed, 16 Nov 2022 16:51:50 +0200 Subject: [PATCH 3/3] Typehint --- controllers/front/fail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/front/fail.php b/controllers/front/fail.php index de48cd5c4..c354b0563 100755 --- a/controllers/front/fail.php +++ b/controllers/front/fail.php @@ -88,6 +88,7 @@ public function init() Tools::redirect($redirectLink); } + /** @var CartDuplicationService $cartDuplicationService */ $cartDuplicationService = $this->module->getService(CartDuplicationService::class); $cartDuplicationService->restoreCart($this->id_cart);