From 974e8fa980d4a8c60ac6241084aa809a3e581025 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 22 Oct 2024 17:11:51 +0300 Subject: [PATCH 1/3] added log --- controllers/front/return.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/front/return.php b/controllers/front/return.php index 27fd10b91..bbd3c7b74 100755 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -80,7 +80,11 @@ public function postProcess() ); $transactionStatus = $assertResponseBody->getTransaction()->getStatus(); } catch (Exception $e) { - \PrestaShopLogger::addLog($e->getMessage()); + $logger->error($e->getMessage(), [ + 'context' => [], + 'exceptions' => ExceptionUtility::getExceptions($e), + ]); + $this->warning[] = $this->module->l('An error occurred. Please contact support', self::FILE_NAME); $this->redirectWithNotifications($this->getRedirectionToControllerUrl('fail')); } From 237af0e546bf6ddded319d3c33976660f74c1585 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 23 Oct 2024 09:36:27 +0300 Subject: [PATCH 2/3] fail controller function --- controllers/front/return.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/controllers/front/return.php b/controllers/front/return.php index bbd3c7b74..53abd4303 100755 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -27,6 +27,7 @@ use Invertus\SaferPay\Core\Payment\DTO\CheckoutData; use Invertus\SaferPay\DTO\Response\Assert\AssertBody; use Invertus\SaferPay\Enum\ControllerName; +use Invertus\SaferPay\Enum\PaymentType; use Invertus\SaferPay\Exception\Api\SaferPayApiException; use Invertus\SaferPay\Logger\LoggerInterface; use Invertus\SaferPay\Processor\CheckoutProcessor; @@ -58,14 +59,16 @@ public function postProcess() $cart = new Cart($cartId); + $failController = $this->getFailController($order); + if (!Validate::isLoadedObject($cart)) { $this->warning[] = $this->module->l('An unknown error error occurred. Please contact support', self::FILE_NAME); - $this->redirectWithNotifications($this->getRedirectionToControllerUrl('fail')); + $this->redirectWithNotifications($this->getRedirectionToControllerUrl($failController)); } if ($cart->secure_key !== $secureKey) { $this->warning[] = $this->module->l('Error. Insecure cart', self::FILE_NAME); - $this->redirectWithNotifications($this->getRedirectionToControllerUrl('fail')); + $this->redirectWithNotifications($this->getRedirectionToControllerUrl($failController)); } /** @var SaferPayTransactionAssertion $transactionAssert */ @@ -86,7 +89,7 @@ public function postProcess() ]); $this->warning[] = $this->module->l('An error occurred. Please contact support', self::FILE_NAME); - $this->redirectWithNotifications($this->getRedirectionToControllerUrl('fail')); + $this->redirectWithNotifications($this->getRedirectionToControllerUrl($failController)); } $orderPayment = $assertResponseBody->getPaymentMeans()->getBrand()->getPaymentMethod(); @@ -376,4 +379,17 @@ private function createAndValidateOrder($assertResponseBody, $transactionStatus, return; } } + + private function getFailController($order) + { + /** @var \Invertus\SaferPay\Provider\PaymentTypeProvider $isIframe */ + $paymentTypeProvider = $this->module->getService(\Invertus\SaferPay\Provider\PaymentTypeProvider::class); + $paymentRedirectType = $paymentTypeProvider->get($order->payment); + + if ($paymentRedirectType === PaymentType::IFRAME) { + return ControllerName::FAIL_IFRAME; + } + + return ControllerName::FAIL; + } } From 2a6987a16ae6917f3b56cfc48c5bbf677d326150 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 23 Oct 2024 10:03:30 +0300 Subject: [PATCH 3/3] renamed annotation --- controllers/front/return.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/return.php b/controllers/front/return.php index 53abd4303..439517d68 100755 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -382,7 +382,7 @@ private function createAndValidateOrder($assertResponseBody, $transactionStatus, private function getFailController($order) { - /** @var \Invertus\SaferPay\Provider\PaymentTypeProvider $isIframe */ + /** @var \Invertus\SaferPay\Provider\PaymentTypeProvider $paymentTypeProvider */ $paymentTypeProvider = $this->module->getService(\Invertus\SaferPay\Provider\PaymentTypeProvider::class); $paymentRedirectType = $paymentTypeProvider->get($order->payment);