From 5f5fd1602323ce7921295b5b1e607265bc77766b Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 8 Aug 2024 16:59:49 +0300 Subject: [PATCH 1/3] duplicate mail fix --- Makefile | 14 +++++++++++++- saferpayofficial.php | 6 ------ src/Api/ApiRequest.php | 1 + .../Verification/CanSendOrderConfirmationEmail.php | 4 ---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 46a952d83..5c405d40d 100755 --- a/Makefile +++ b/Makefile @@ -142,4 +142,16 @@ e2e-1786-prepare: # Run e2e tests in headless way. e2eh1786: test-e2e-headless-1786 test-e2e-headless-1786: - make e2e1786p \ No newline at end of file + make e2e1786p + +prepare-zip: + rm -rf vendor && \ + composer install --no-dev --optimize-autoloader && \ + cp .github/.htaccess vendor/.htaccess && \ + rm -rf .git .github tests cypress .docker && \ + mkdir saferpayofficial && \ + rsync -Rr ./ ./saferpayofficial && \ + bash -c 'shopt -s extglob; rm -r !(saferpayofficial)' && \ + find . -maxdepth 1 -type f -exec rm "{}" \; && \ + cd saferpayofficial && rm -rf saferpayofficial && \ + cd ../ && zip -r saferpayofficial.zip saferpayofficial/ \ No newline at end of file diff --git a/saferpayofficial.php b/saferpayofficial.php index cfd291d6c..a2e19ba3a 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -639,12 +639,6 @@ public function hookActionOrderHistoryAddAfter($params = []) $canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class); if ($canSendOrderConfirmationEmail->verify((int) $orderStatus->id)) { - try { - $mailService->sendNewOrderMail($order, (int) $orderStatus->id); - } catch (Exception $e) { - // emailalert module sometimes throws error which leads into failed payment issue - } - if ((int) \Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { $mailService->sendOrderConfMail($order, (int) $orderStatus->id); } diff --git a/src/Api/ApiRequest.php b/src/Api/ApiRequest.php index a35267376..a005d7e91 100755 --- a/src/Api/ApiRequest.php +++ b/src/Api/ApiRequest.php @@ -54,6 +54,7 @@ public function post($url, $params = []) json_encode($params) ); + $this->isValidResponse($response); return json_decode($response->raw_body); diff --git a/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php b/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php index 62e735db2..3ecb1cab3 100644 --- a/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php +++ b/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php @@ -46,10 +46,6 @@ private function isOrderStatusValid($orderStatusId) return true; } - if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_COMPLETED) === (int) $orderStatusId) { - return true; - } - if ((int) \Configuration::get(SaferPayConfig::STATUS_PS_OS_OUTOFSTOCK_PAID) === (int) $orderStatusId) { return true; } From 52a0ae553ca794b817e388c6c2eabf6f15730fb7 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 9 Aug 2024 14:33:09 +0300 Subject: [PATCH 2/3] fix order conf mail --- saferpayofficial.php | 45 --------------------------------------- upgrade/install-1.2.3.php | 1 + 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index a2e19ba3a..a4a4e230d 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -591,13 +591,6 @@ public function hookActionEmailSendBefore($params) return true; } - /** @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(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL)) { return true; @@ -607,44 +600,6 @@ public function hookActionEmailSendBefore($params) } } - public function hookActionOrderHistoryAddAfter($params = []) - { - /** @var OrderHistory $orderHistory */ - $orderHistory = $params['order_history']; - - if (!$orderHistory instanceof OrderHistory) { - return; - } - - $idOrder = (int) $orderHistory->id_order; - - $internalOrder = new Order($idOrder); - - if (!Validate::isLoadedObject($internalOrder)) { - return; - } - - $order = new Order($idOrder); - - $orderStatus = new OrderState((int) $order->current_state); - - if (!Validate::isLoadedObject($orderStatus)) { - return; - } - - /** @var \Invertus\SaferPay\Service\SaferPayMailService $mailService */ - $mailService = $this->getService(\Invertus\SaferPay\Service\SaferPayMailService::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)) { - if ((int) \Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) { - $mailService->sendOrderConfMail($order, (int) $orderStatus->id); - } - } - } - public function hookActionAdminControllerSetMedia() { if ('AdminOrders' === Tools::getValue('controller') && diff --git a/upgrade/install-1.2.3.php b/upgrade/install-1.2.3.php index b5ce3a0b6..07ac45fe3 100644 --- a/upgrade/install-1.2.3.php +++ b/upgrade/install-1.2.3.php @@ -36,6 +36,7 @@ function upgrade_module_1_2_3(SaferPayOfficial $module) $installer->createPendingOrderStatus() && Db::getInstance()->execute('ALTER TABLE ' . _DB_PREFIX_ . 'saferpay_order ADD COLUMN `pending` TINYINT(1) DEFAULT 0') && $module->registerHook('displayOrderConfirmation') && + $module->unregisterHook('actionOrderHistoryAddAfter') && Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION) && Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION); } From fed9698d246f428c24a62c433d1d3b51dc751df7 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 9 Aug 2024 15:16:22 +0300 Subject: [PATCH 3/3] make file updated for module preparation --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5c405d40d..2d5ffac0e 100755 --- a/Makefile +++ b/Makefile @@ -151,7 +151,7 @@ prepare-zip: rm -rf .git .github tests cypress .docker && \ mkdir saferpayofficial && \ rsync -Rr ./ ./saferpayofficial && \ - bash -c 'shopt -s extglob; rm -r !(saferpayofficial)' && \ + find . -maxdepth 1 ! -name saferpayofficial -exec mv {} saferpayofficial/ \; && \ find . -maxdepth 1 -type f -exec rm "{}" \; && \ cd saferpayofficial && rm -rf saferpayofficial && \ - cd ../ && zip -r saferpayofficial.zip saferpayofficial/ \ No newline at end of file + cd ../ && zip -r saferpayofficial.zip saferpayofficial/