From ba49048318bd1a0f3744e386221c0ed5bf583601 Mon Sep 17 00:00:00 2001 From: Julius Zukauskas Date: Mon, 1 Jul 2024 14:47:16 +0300 Subject: [PATCH] apply changes from branch SL-232/conflicting-calls. Return contorller left todo --- controllers/front/notify.php | 2 ++ src/Controller/AbstractSaferPayController.php | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/controllers/front/notify.php b/controllers/front/notify.php index e6031a71..0ac0d22f 100755 --- a/controllers/front/notify.php +++ b/controllers/front/notify.php @@ -146,6 +146,7 @@ public function postProcess() $orderStatusService->capture($order); } } catch (Exception $e) { + $this->releaseLock(); // this might be executed after pending transaction is declined (e.g. with accountToAccount payment) if (!isset($order)) { $orderId = $this->getOrderId($cartId); @@ -176,6 +177,7 @@ public function postProcess() null, true ); + $this->releaseLock(); die($this->module->l($e->getMessage(), self::FILENAME)); } diff --git a/src/Controller/AbstractSaferPayController.php b/src/Controller/AbstractSaferPayController.php index 74d4ba95..d62b5e46 100755 --- a/src/Controller/AbstractSaferPayController.php +++ b/src/Controller/AbstractSaferPayController.php @@ -42,7 +42,7 @@ class AbstractSaferPayController extends \ModuleFrontControllerCore /** * @var Lock */ - private $lock; + protected $lock; public function __construct() { @@ -82,11 +82,6 @@ protected function applyLock($resource) $this->lock->create($resource); if (!$this->lock->acquire()) { - $logger = new SaferPayLog(); - $logger->message = 'Lock resource conflict'; - $logger->payload = $resource; - $logger->save(); - return Response::respond( $this->module->l('Resource conflict', self::FILE_NAME), Response::HTTP_CONFLICT @@ -110,6 +105,15 @@ protected function applyLock($resource) ); } + protected function lockExist() + { + try { + return $this->lock->acquire(); + } catch (\Exception $exception) { + return false; + } + } + protected function releaseLock() { try {