From f599f44d276920174165065854befd36ac430b7c Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 23 Jul 2024 10:05:23 +0300 Subject: [PATCH 1/6] ps16 compatibility --- controllers/front/notify.php | 50 ++++++++++++++++++- controllers/front/return.php | 4 -- src/Controller/AbstractSaferPayController.php | 12 +++++ 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 0c6def53..2b607f74 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -66,8 +66,14 @@ public function postProcess() $secureKey )); - if (!$lockResult->isSuccessful()) { - die($this->module->l('Lock already exist', self::FILENAME)); + if (!SaferPayConfig::isVersion17()) { + if ($lockResult > 200) { + die($this->module->l('Lock already exists', self::FILENAME)); + } + } else { + if (!$lockResult->isSuccessful()) { + die($this->module->l('Lock already exists', self::FILENAME)); + } } if ($cart->orderExists()) { @@ -96,7 +102,34 @@ public function postProcess() $checkoutData->setOrderStatus($transactionStatus); + PrestaShopLogger::addLog( + sprintf( + 'Order %s has been updated to status %s', + $cart->id, + $transactionStatus + ), + 1, + null, + null, + null, + true + ); + $checkoutProcessor->run($checkoutData); + + + PrestaShopLogger::addLog( + sprintf( + 'Order %s has been updated to status %s', + $cart->id, + $transactionStatus + ), + 1, + null, + null, + null, + true + ); $orderId = $this->getOrderId($cartId); //TODO look into pipeline design pattern to use when object is modified in multiple places to avoid this issue. @@ -186,6 +219,19 @@ public function postProcess() die($this->module->l($e->getMessage(), self::FILENAME)); } + PrestaShopLogger::addLog( + sprintf( + 'Order %s has been updated to status %s', + $order->reference, + $transactionStatus + ), + 1, + null, + null, + null, + true + ); + die($this->module->l('Success', self::FILENAME)); } diff --git a/controllers/front/return.php b/controllers/front/return.php index 473997c4..1ce79fd0 100755 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -175,10 +175,6 @@ private function executeTransaction($orderId, $selectedCard) ); } - private function assertTransaction($cartId) { - - } - /** * @param int $cartId * diff --git a/src/Controller/AbstractSaferPayController.php b/src/Controller/AbstractSaferPayController.php index d62b5e46..cac8b4a2 100755 --- a/src/Controller/AbstractSaferPayController.php +++ b/src/Controller/AbstractSaferPayController.php @@ -82,6 +82,10 @@ protected function applyLock($resource) $this->lock->create($resource); if (!$this->lock->acquire()) { + + if (!SaferPayConfig::isVersion17()) { + return http_response_code(409); + } return Response::respond( $this->module->l('Resource conflict', self::FILE_NAME), Response::HTTP_CONFLICT @@ -93,12 +97,20 @@ protected function applyLock($resource) $logger->payload = $resource; $logger->save(); + if (!SaferPayConfig::isVersion17()) { + return http_response_code(500); + } + return Response::respond( $this->module->l('Internal error', self::FILE_NAME), Response::HTTP_INTERNAL_SERVER_ERROR ); } + if (!SaferPayConfig::isVersion17()) { + return http_response_code(200); + } + return Response::respond( '', Response::HTTP_OK From 1ae06bf0f4a065954bf39739b05f163ff51369b6 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 23 Jul 2024 10:06:34 +0300 Subject: [PATCH 2/6] not needed logs deleted --- controllers/front/notify.php | 41 ------------------------------------ 1 file changed, 41 deletions(-) diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 2b607f74..2e6b2d43 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -102,34 +102,6 @@ public function postProcess() $checkoutData->setOrderStatus($transactionStatus); - PrestaShopLogger::addLog( - sprintf( - 'Order %s has been updated to status %s', - $cart->id, - $transactionStatus - ), - 1, - null, - null, - null, - true - ); - - $checkoutProcessor->run($checkoutData); - - - PrestaShopLogger::addLog( - sprintf( - 'Order %s has been updated to status %s', - $cart->id, - $transactionStatus - ), - 1, - null, - null, - null, - true - ); $orderId = $this->getOrderId($cartId); //TODO look into pipeline design pattern to use when object is modified in multiple places to avoid this issue. @@ -219,19 +191,6 @@ public function postProcess() die($this->module->l($e->getMessage(), self::FILENAME)); } - PrestaShopLogger::addLog( - sprintf( - 'Order %s has been updated to status %s', - $order->reference, - $transactionStatus - ), - 1, - null, - null, - null, - true - ); - die($this->module->l('Success', self::FILENAME)); } From 2070564ff6fcd2ee81afdbeccdb6c3b5e4937687 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 23 Jul 2024 15:09:21 +0300 Subject: [PATCH 3/6] fix bo for ps 1.6 --- saferpayofficial.php | 195 +++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 108 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 4df48920..0ea4645c 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -21,30 +21,6 @@ *@license SIX Payment Services */ -use Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate; -use Invertus\SaferPay\Config\SaferPayConfig; -use Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail; -use Invertus\SaferPay\Exception\Api\SaferPayApiException; -use Invertus\SaferPay\Install\Installer; -use Invertus\SaferPay\Install\Uninstaller; -use Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader; -use Invertus\SaferPay\Presenter\AdminOrderPagePresenter; -use Invertus\SaferPay\Presenter\AssertPresenter; -use Invertus\SaferPay\Provider\PaymentRedirectionProvider; -use Invertus\SaferPay\Provider\PaymentTypeProvider; -use Invertus\SaferPay\Repository\SaferPayCardAliasRepository; -use Invertus\SaferPay\Repository\SaferPayOrderRepository; -use Invertus\SaferPay\Repository\SaferPayPaymentRepository; -use Invertus\SaferPay\Service\LegacyTranslator; -use Invertus\SaferPay\Service\PaymentRestrictionValidation; -use Invertus\SaferPay\Service\SaferPayCartService; -use Invertus\SaferPay\Service\SaferPayErrorDisplayService; -use Invertus\SaferPay\Service\SaferPayMailService; -use Invertus\SaferPay\Service\SaferPayObtainPaymentMethods; -use Invertus\SaferPay\Service\SaferPayPaymentNotation; -use Invertus\SaferPay\ServiceProvider\LeagueServiceContainerProvider; -use PrestaShop\PrestaShop\Core\Payment\PaymentOption; - if (!defined('_PS_VERSION_')) { exit; } @@ -81,7 +57,7 @@ public function __construct($name = null) public function getContent() { - if (Configuration::get(SaferPayConfig::USERNAME)) { + if (Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::USERNAME)) { Tools::redirectAdmin($this->context->link->getAdminLink(self::ADMIN_PAYMENTS_CONTROLLER)); } Tools::redirectAdmin($this->context->link->getAdminLink(self::ADMIN_SETTINGS_CONTROLLER)); @@ -89,7 +65,7 @@ public function getContent() public function install() { - $installer = new Installer($this); + $installer = new \Invertus\SaferPay\Install\Installer($this); if (!parent::install()) { return false; @@ -104,7 +80,7 @@ public function install() public function uninstall() { - $uninstaller = new Uninstaller($this); + $uninstaller = new \Invertus\SaferPay\Install\Uninstaller($this); if (!$uninstaller->uninstall()) { $this->_errors += $uninstaller->getErrors(); return false; @@ -114,7 +90,7 @@ public function uninstall() public function getTabs() { - $installer = new Installer($this); + $installer = new \Invertus\SaferPay\Install\Installer($this); return $installer->tabs(); } @@ -133,7 +109,7 @@ private function loadConfig() } public function getService($service) { - $containerProvider = new LeagueServiceContainerProvider(); + $containerProvider = new \Invertus\SaferPay\ServiceProvider\LeagueServiceContainerProvider(); return $containerProvider->getService($service); } @@ -147,8 +123,9 @@ public function hookDisplayOrderConfirmation($params) /** @var Order $psOrder */ $psOrder = $params['order']; - /** @var SaferPayOrderRepository $repository */ - $repository = $this->getService(SaferPayOrderRepository::class); + /** @var \Invertus\SaferPay\Repository\SaferPayOrderRepository $repository */ + $repository = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class); + $sfOrder = $repository->getByOrderId((int) $psOrder->id); if (!$sfOrder->pending) { @@ -172,8 +149,8 @@ public function hookActionObjectOrderPaymentAddAfter($params) return; } - /** @var SaferPayOrderRepository $saferPayOrderRepository */ - $saferPayOrderRepository = $this->getService(SaferPayOrderRepository::class); + /** @var \Invertus\SaferPay\Repository\SaferPayOrderRepository $saferPayOrderRepository */ + $saferPayOrderRepository = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class); $orders = Order::getByReference($orderPayment->order_reference); @@ -203,32 +180,33 @@ public function hookActionObjectOrderPaymentAddAfter($params) public function hookPaymentOptions($params) { /** @var Invertus\SaferPay\Service\SaferPayCartService $assertService */ - $cartService = $this->getService(SaferPayCartService::class); + $cartService = $this->getService(\Invertus\SaferPay\Service\SaferPayCartService::class); if (!$cartService->isCurrencyAvailable($params['cart'])) { return; } - /** @var PaymentTypeProvider $paymentTypeProvider */ - $paymentTypeProvider = $this->getService(PaymentTypeProvider::class); + /** @var \Invertus\SaferPay\Provider\PaymentTypeProvider $paymentTypeProvider */ + $paymentTypeProvider = $this->getService(\Invertus\SaferPay\Provider\PaymentTypeProvider::class); - /** @var SaferPayObtainPaymentMethods $obtainPaymentMethods */ - $obtainPaymentMethods = $this->getService(SaferPayObtainPaymentMethods::class); - /** @var SaferPayPaymentRepository $paymentRepository */ - $paymentRepository = $this->getService(SaferPayPaymentRepository::class); + /** @var \Invertus\SaferPay\Service\SaferPayObtainPaymentMethods $obtainPaymentMethods */ + $obtainPaymentMethods = $this->getService(\Invertus\SaferPay\Service\SaferPayObtainPaymentMethods::class); + /** @var \Invertus\SaferPay\Repository\SaferPayPaymentRepository $paymentRepository */ + $paymentRepository = $this->getService(\Invertus\SaferPay\Repository\SaferPayPaymentRepository::class); try { $paymentMethods = $obtainPaymentMethods->obtainPaymentMethods(); - } catch (SaferPayApiException $exception) { + } catch (\Invertus\SaferPay\Exception\Api\SaferPayApiException $exception) { return []; } $paymentOptions = []; - /** @var PaymentRestrictionValidation $paymentRestrictionValidation */ + /** @var \Invertus\SaferPay\Service\PaymentRestrictionValidation $paymentRestrictionValidation */ $paymentRestrictionValidation = $this->getService( - PaymentRestrictionValidation::class + \Invertus\SaferPay\Service\PaymentRestrictionValidation::class ); + foreach ($paymentMethods as $paymentMethod) { $paymentMethod['paymentMethod'] = str_replace(' ', '', $paymentMethod['paymentMethod']); @@ -241,20 +219,20 @@ public function hookPaymentOptions($params) $isCreditCard = in_array( $paymentMethod['paymentMethod'], - SaferPayConfig::TRANSACTION_METHODS + \Invertus\SaferPay\Config\SaferPayConfig::TRANSACTION_METHODS ); $isBusinessLicenseEnabled = Configuration::get( - SaferPayConfig::BUSINESS_LICENSE - . SaferPayConfig::getConfigSuffix() + \Invertus\SaferPay\Config\SaferPayConfig::BUSINESS_LICENSE + . \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix() ); - /** @var SaferPayCardAliasRepository $cardAliasRep */ + /** @var \Invertus\SaferPay\Repository\SaferPayCardAliasRepository $cardAliasRep */ $cardAliasRep = $this->getService( - SaferPayCardAliasRepository::class + \Invertus\SaferPay\Repository\SaferPayCardAliasRepository::class ); $isCreditCardSavingEnabled = Configuration::get( - SaferPayConfig::CREDIT_CARD_SAVE + \Invertus\SaferPay\Config\SaferPayConfig::CREDIT_CARD_SAVE ); $selectedCard = 0; if ($this->context->customer->is_guest) { @@ -262,15 +240,15 @@ public function hookPaymentOptions($params) $selectedCard = -1; } - /** @var PaymentRedirectionProvider $paymentRedirectionProvider */ - $paymentRedirectionProvider = $this->getService(PaymentRedirectionProvider::class); + /** @var \Invertus\SaferPay\Provider\PaymentRedirectionProvider $paymentRedirectionProvider */ + $paymentRedirectionProvider = $this->getService(\Invertus\SaferPay\Provider\PaymentRedirectionProvider::class); - $newOption = new PaymentOption(); + $newOption = new \PrestaShop\PrestaShop\Core\Payment\PaymentOption(); $translator = $this->getService( - LegacyTranslator::class + \Invertus\SaferPay\Service\LegacyTranslator::class ); - /** @var SaferPayPaymentNotation $saferPayPaymentNotation */ - $saferPayPaymentNotation = $this->getService(SaferPayPaymentNotation::class); + /** @var \Invertus\SaferPay\Service\SaferPayPaymentNotation $saferPayPaymentNotation */ + $saferPayPaymentNotation = $this->getService(\Invertus\SaferPay\Service\SaferPayPaymentNotation::class); $paymentMethodName = $saferPayPaymentNotation->getForDisplay($paymentMethod['paymentMethod']); $inputs = [ @@ -285,7 +263,7 @@ public function hookPaymentOptions($params) 'value' => $selectedCard, ], ]; - + if ($isCreditCardSavingEnabled && $isCreditCard && $isBusinessLicenseEnabled) { $currentDate = date('Y-m-d h:i:s'); @@ -337,7 +315,7 @@ public function hookPaymentOptions($params) public function hookDisplayAdminOrderTabContent(array $params) { - $isVersionAbove177 = SaferPayConfig::isVersionAbove177(); + $isVersionAbove177 = \Invertus\SaferPay\Config\SaferPayConfig::isVersionAbove177(); return !$isVersionAbove177 ? false : $this->displayInAdminOrderPage($params); } @@ -345,20 +323,20 @@ public function hookDisplayAdminOrderTabContent(array $params) public function hookDisplayAdminOrder(array $params) { - $isVersionAbove177 = SaferPayConfig::isVersionAbove177(); + $isVersionAbove177 = \Invertus\SaferPay\Config\SaferPayConfig::isVersionAbove177(); return $isVersionAbove177 ? false : $this->displayInAdminOrderPage($params); } public function hookActionFrontControllerSetMedia() { - /** @var PaymentFormAssetLoader $paymentFormAssetsLoader */ - $paymentFormAssetsLoader = $this->getService(PaymentFormAssetLoader::class); + /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ + $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); $paymentFormAssetsLoader->register($this->context->controller); if ($this->context->controller instanceof OrderController) { - if (SaferPayConfig::isVersion17()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $this->context->controller->registerJavascript( 'saved-card', 'modules/' . $this->name . '/views/js/front/saferpay_saved_card.js' @@ -368,13 +346,13 @@ public function hookActionFrontControllerSetMedia() } else { $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); $this->context->controller->addJS("{$this->getPathUri()}views/js/front/saferpay_saved_card_16.js"); - $fieldsLibrary = SaferPayConfig::FIELDS_LIBRARY; - $configSuffix = SaferPayConfig::getConfigSuffix(); + $fieldsLibrary = \Invertus\SaferPay\Config\SaferPayConfig::FIELDS_LIBRARY; + $configSuffix = \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix(); $this->context->controller->addJs(Configuration::get($fieldsLibrary . $configSuffix)); } - /** @var SaferPayErrorDisplayService $errorDisplayService */ - $errorDisplayService = $this->getService(SaferPayErrorDisplayService::class); + /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ + $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); } } @@ -382,11 +360,11 @@ public function hookActionFrontControllerSetMedia() public function hookDisplayCustomerAccount() { $isCreditCardSaveEnabled = - Configuration::get(SaferPayConfig::CREDIT_CARD_SAVE); + Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::CREDIT_CARD_SAVE); if (!$isCreditCardSaveEnabled) { return; } - if (SaferPayConfig::isVersion17()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { return $this->context->smarty->fetch( $this->getLocalPath() . 'views/templates/hook/front/MyAccount.tpl' ); @@ -399,7 +377,7 @@ public function hookDisplayCustomerAccount() public function displayNavigationTop() { - if (SaferPayConfig::isVersion17()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { return; } @@ -464,27 +442,27 @@ public function hookDisplayPayment($params) return; } - /** @var SaferPayCartService $assertService */ - $cartService = $this->getService(SaferPayCartService::class); + /** @var \Invertus\SaferPay\Service\SaferPayCartService $assertService */ + $cartService = $this->getService(\Invertus\SaferPay\Service\SaferPayCartService::class); if (!$cartService->isCurrencyAvailable($params['cart'])) { return; } - /** @var PaymentRestrictionValidation $paymentRestrictionValidation */ - $paymentRepository = $this->getService(SaferPayPaymentRepository::class); + /** @var \Invertus\SaferPay\Service\PaymentRestrictionValidation $paymentRestrictionValidation */ + $paymentRepository = $this->getService(\Invertus\SaferPay\Repository\SaferPayPaymentRepository::class); - /** @var SaferPayObtainPaymentMethods $obtainPaymentMethods */ - $obtainPaymentMethods = $this->getService(SaferPayObtainPaymentMethods::class); + /** @var \Invertus\SaferPay\Service\SaferPayObtainPaymentMethods $obtainPaymentMethods */ + $obtainPaymentMethods = $this->getService(\Invertus\SaferPay\Service\SaferPayObtainPaymentMethods::class); try { $paymentMethods = $obtainPaymentMethods->obtainPaymentMethods(); - } catch (SaferPayApiException $exception) { + } catch (\Invertus\SaferPay\Exception\Api\SaferPayApiException $exception) { return ''; } $paymentOptions = []; $paymentRestrictionValidation = $this->getService( - PaymentRestrictionValidation::class + \Invertus\SaferPay\Service\PaymentRestrictionValidation::class ); foreach ($paymentMethods as $paymentMethod) { @@ -496,20 +474,20 @@ public function hookDisplayPayment($params) $imageUrl = ($paymentRepository->isLogoEnabledByName($paymentMethod['paymentMethod'])) ? $paymentMethod['logoUrl'] : ''; - $isCreditCard = in_array($paymentMethod['paymentMethod'], SaferPayConfig::TRANSACTION_METHODS); + $isCreditCard = in_array($paymentMethod['paymentMethod'], \Invertus\SaferPay\Config\SaferPayConfig::TRANSACTION_METHODS); $isBusinessLicenseEnabled = Configuration::get( - SaferPayConfig::BUSINESS_LICENSE - . SaferPayConfig::getConfigSuffix() + \Invertus\SaferPay\Config\SaferPayConfig::BUSINESS_LICENSE + . \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix() ); - /** @var SaferPayCardAliasRepository $cardAliasRep */ + /** @var \Invertus\SaferPay\Repository\SaferPayCardAliasRepository $cardAliasRep */ $cardAliasRep = $this->getService( - SaferPayCardAliasRepository::class + \Invertus\SaferPay\Repository\SaferPayCardAliasRepository::class ); $displayTpl = 'front/payment.tpl'; - $isCardSaveEnabled = Configuration::get(SaferPayConfig::CREDIT_CARD_SAVE); + $isCardSaveEnabled = Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::CREDIT_CARD_SAVE); $currentDate = date('Y-m-d h:i:s'); if ($isBusinessLicenseEnabled && $isCreditCard && $isCardSaveEnabled) { @@ -536,11 +514,11 @@ public function hookDisplayPayment($params) $displayTpl = 'front/payment_with_cards.tpl'; } - /** @var PaymentRedirectionProvider $paymentRedirectionProvider */ - $paymentRedirectionProvider = $this->getService(PaymentRedirectionProvider::class); + /** @var \Invertus\SaferPay\Provider\PaymentRedirectionProvider $paymentRedirectionProvider */ + $paymentRedirectionProvider = $this->getService(\Invertus\SaferPay\Provider\PaymentRedirectionProvider::class); - /** @var PaymentTypeProvider $paymentTypeProvider */ - $paymentTypeProvider = $this->getService(PaymentTypeProvider::class); + /** @var \Invertus\SaferPay\Provider\PaymentTypeProvider $paymentTypeProvider */ + $paymentTypeProvider = $this->getService(\Invertus\SaferPay\Provider\PaymentTypeProvider::class); $this->smarty->assign( [ @@ -565,13 +543,13 @@ public function hookDisplayPayment($params) public function hookPaymentReturn() { - if (SaferPayConfig::isVersion17()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { return; } - /** @var OrderConfirmationMessageTemplate $OrderConfirmationMessageTemplate */ + /** @var \Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate $OrderConfirmationMessageTemplate */ $OrderConfirmationMessageTemplate = $this->getService( - OrderConfirmationMessageTemplate::class + \Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate::class ); $OrderConfirmationMessageTemplate->setSmarty($this->context->smarty); @@ -602,7 +580,7 @@ public function hookActionEmailSendBefore($params) } $cart = new Cart($params['cart']->id); - /** @var Order $order */ + /** @var \Order $order */ $order = Order::getByCartId($cart->id); if (!$order) { @@ -613,15 +591,15 @@ public function hookActionEmailSendBefore($params) return true; } - /** @var CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */ - $canSendOrderConfirmationEmail = $this->getService(CanSendOrderConfirmationEmail::class); + /** @var \Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */ + $canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class); if ($params['template'] === 'order_conf') { return $canSendOrderConfirmationEmail->verify((int) $order->current_state); } if ($params['template'] === 'new_order') { - if ((int) Configuration::get(SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL)) { + if ((int) Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL)) { return true; } @@ -654,11 +632,11 @@ public function hookActionOrderHistoryAddAfter($params = []) return; } - /** @var SaferPayMailService $mailService */ - $mailService = $this->getService(SaferPayMailService::class); + /** @var \Invertus\SaferPay\Service\SaferPayMailService $mailService */ + $mailService = $this->getService(\Invertus\SaferPay\Service\SaferPayMailService::class); - /** @var CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */ - $canSendOrderConfirmationEmail = $this->getService(CanSendOrderConfirmationEmail::class); + /** @var \Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */ + $canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class); if ($canSendOrderConfirmationEmail->verify((int) $orderStatus->id)) { try { @@ -667,8 +645,8 @@ public function hookActionOrderHistoryAddAfter($params = []) // emailalert module sometimes throws error which leads into failed payment issue } - if ((int) Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { - $mailService->sendOrderConfMail($order, (int) $orderStatus->id); + if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { + $mailService->sendOrderConfMail($order, (int) $orderStatus->id); } } } @@ -683,8 +661,9 @@ public function hookActionAdminControllerSetMedia() $orderId = Tools::getValue('id_order'); $order = new Order($orderId); - /** @var SaferPayOrderRepository $orderRepo */ - $orderRepo = $this->getService(SaferPayOrderRepository::class); + /** @var \Invertus\SaferPay\Repository\SaferPayOrderRepository $orderRepo */ + $orderRepo = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class); + $saferPayOrderId = $orderRepo->getIdByOrderId($orderId); $saferPayOrder = new SaferPayOrder($saferPayOrderId); @@ -730,7 +709,7 @@ private function displayInAdminOrderPage(array $params) $orderId = $params['id_order']; $order = new Order($orderId); /** @var SaferPayOrderRepository $orderRepo */ - $orderRepo = $this->getService(SaferPayOrderRepository::class); + $orderRepo = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class); $saferPayOrderId = $orderRepo->getIdByOrderId($orderId); $saferPayOrder = new SaferPayOrder($saferPayOrderId); @@ -742,7 +721,7 @@ private function displayInAdminOrderPage(array $params) return ''; } - if (SaferPayConfig::isVersionAbove177()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersionAbove177()) { $action = $this->context->link->getAdminLink( self::ADMIN_ORDER_CONTROLLER, true, @@ -757,9 +736,9 @@ private function displayInAdminOrderPage(array $params) $assertId = $orderRepo->getAssertIdBySaferPayOrderId($saferPayOrderId); $assertData = new SaferPayAssert($assertId); - $assertPresenter = new AssertPresenter($this); + $assertPresenter = new \Invertus\SaferPay\Presenter\AssertPresenter($this); $assertData = $assertPresenter->present($assertData); - $supported3DsPaymentMethods = SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS; + $supported3DsPaymentMethods = \Invertus\SaferPay\Config\SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS; // Note: This condition check or Payment method supports 3DS. // If payment method does not supports 3DS , when we change 'liability_shift' @@ -772,11 +751,11 @@ private function displayInAdminOrderPage(array $params) $this->context->smarty->assign($assertData); $currency = new Currency($order->id_currency); - $adminOrderPagePresenter = new AdminOrderPagePresenter(); + $adminOrderPagePresenter = new \Invertus\SaferPay\Presenter\AdminOrderPagePresenter(); $orderPageData = $adminOrderPagePresenter->present( $saferPayOrder, $action, - SaferPayConfig::AMOUNT_MULTIPLIER_FOR_API, + \Invertus\SaferPay\Config\SaferPayConfig::AMOUNT_MULTIPLIER_FOR_API, $currency->sign ); @@ -789,7 +768,7 @@ private function displayInAdminOrderPage(array $params) public function addFlash($msg, $type) { - if (SaferPayConfig::isVersionAbove177()) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersionAbove177()) { return $this->get('session')->getFlashBag()->add($type, $msg); } From ce1555bcbda29d00a316c1620e7e0ac9a313ea50 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 25 Jul 2024 10:43:26 +0300 Subject: [PATCH 4/6] fix payments on 1.6 ps --- saferpayofficial.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 0ea4645c..cfd291d6 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -645,7 +645,7 @@ public function hookActionOrderHistoryAddAfter($params = []) // emailalert module sometimes throws error which leads into failed payment issue } - if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { + if ((int) \Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { $mailService->sendOrderConfMail($order, (int) $orderStatus->id); } } From c2b7205183a7831bc6c630d399eae0f7b962d03a Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 25 Jul 2024 13:06:50 +0300 Subject: [PATCH 5/6] fix --- controllers/front/notify.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 2e6b2d43..04fb8da6 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -60,21 +60,21 @@ public function postProcess() die($this->module->l('Error. Insecure cart', self::FILENAME)); } - $lockResult = $this->applyLock(sprintf( - '%s-%s', - $cartId, - $secureKey - )); - - if (!SaferPayConfig::isVersion17()) { - if ($lockResult > 200) { - die($this->module->l('Lock already exists', self::FILENAME)); - } - } else { - if (!$lockResult->isSuccessful()) { - die($this->module->l('Lock already exists', self::FILENAME)); - } - } +// $lockResult = $this->applyLock(sprintf( +// '%s-%s', +// $cartId, +// $secureKey +// )); + +// if (!SaferPayConfig::isVersion17()) { +// if ($lockResult > 200) { +// die($this->module->l('Lock already exists', self::FILENAME)); +// } +// } else { +// if (!$lockResult->isSuccessful()) { +// die($this->module->l('Lock already exists', self::FILENAME)); +// } +// } if ($cart->orderExists()) { $order = new Order($this->getOrderId($cartId)); @@ -101,6 +101,7 @@ public function postProcess() ); $checkoutData->setOrderStatus($transactionStatus); + $checkoutProcessor->run($checkoutData); $orderId = $this->getOrderId($cartId); From 2e3bc850eb0a7f1ef5fb2fd6055acc23ae05dad4 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 25 Jul 2024 13:07:17 +0300 Subject: [PATCH 6/6] fix --- controllers/front/notify.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/controllers/front/notify.php b/controllers/front/notify.php index 04fb8da6..41d32347 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -60,21 +60,21 @@ public function postProcess() die($this->module->l('Error. Insecure cart', self::FILENAME)); } -// $lockResult = $this->applyLock(sprintf( -// '%s-%s', -// $cartId, -// $secureKey -// )); - -// if (!SaferPayConfig::isVersion17()) { -// if ($lockResult > 200) { -// die($this->module->l('Lock already exists', self::FILENAME)); -// } -// } else { -// if (!$lockResult->isSuccessful()) { -// die($this->module->l('Lock already exists', self::FILENAME)); -// } -// } + $lockResult = $this->applyLock(sprintf( + '%s-%s', + $cartId, + $secureKey + )); + + if (!SaferPayConfig::isVersion17()) { + if ($lockResult > 200) { + die($this->module->l('Lock already exists', self::FILENAME)); + } + } else { + if (!$lockResult->isSuccessful()) { + die($this->module->l('Lock already exists', self::FILENAME)); + } + } if ($cart->orderExists()) { $order = new Order($this->getOrderId($cartId));