From f599f44d276920174165065854befd36ac430b7c Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 23 Jul 2024 10:05:23 +0300 Subject: [PATCH 1/2] 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/2] 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)); }