diff --git a/CHANGELOG.md b/CHANGELOG.md index 90d6305e..11017ccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ PrestaShop 1.6.x, 1.7.x and 8.x # Changelog +## [5.0.1] +### Fixed +- Fix: False "Payment service temporary unavailable" shown on redirect/wallet payments (MobilePay, Swish, Klarna, ApplePay) due to callback race condition, causing duplicate orders. +- Fix: Fatal error in `callbackform` when cart cannot be resolved, causing unnecessary gateway retries. +- Fix: Fatal error in `checkorderstatus` when cart cannot be resolved while polling for order status. +- Fix: `CheckoutSession` incorrectly called for Apple Pay payments; `setSessionID` now skipped when session is not applicable. + ## [5.0.0] ### Added - Add support for `checkoutSession` for reusable checkout sessions improving fraud detection and conversion. diff --git a/altapay.php b/altapay.php index 637eae76..0e432eed 100644 --- a/altapay.php +++ b/altapay.php @@ -33,7 +33,7 @@ public function __construct() { $this->name = 'altapay'; $this->tab = 'payments_gateways'; - $this->version = '5.0.0'; + $this->version = '5.0.1'; $this->author = 'AltaPay A/S'; $this->is_eu_compatible = 1; $this->ps_versions_compliancy = ['min' => '1.6.0.1', 'max' => '8.2.3']; @@ -3186,21 +3186,15 @@ public function createTransaction($savecard, $results = false; } + $config = new API\PHP\Altapay\Request\Config(); + $config->setCallbackOk($callback['callback_ok']); + $config->setCallbackFail($callback['callback_fail']); + $config->setCallbackOpen($callback['callback_open']); + $config->setCallbackNotification($callback['callback_notification']); + $config->setCallbackRedirect($callback['callback_redirect']); + $config->setCallbackForm($callback['callback_form']); + try { - $sessionRequest = new API\PHP\Altapay\Api\Payments\CheckoutSession(getAuth()); - $sessionRequest->setTerminals([$cgConf['terminal']]) - ->setShopOrderId($requestShopOrderId) - ->setAmount($requestAmount) - ->setCurrency($cgConf['currency']); - $sessionResponse = $sessionRequest->call(); - $sessionId = $sessionResponse->Session->Id; - $config = new API\PHP\Altapay\Request\Config(); - $config->setCallbackOk($callback['callback_ok']); - $config->setCallbackFail($callback['callback_fail']); - $config->setCallbackOpen($callback['callback_open']); - $config->setCallbackNotification($callback['callback_notification']); - $config->setCallbackRedirect($callback['callback_redirect']); - $config->setCallbackForm($callback['callback_form']); $request = new API\PHP\Altapay\Api\Ecommerce\PaymentRequest(getAuth()); if ($terminal->applepay) { $response['apple_pay_terminal'] = true; @@ -3230,11 +3224,12 @@ public function createTransaction($savecard, $request->setAgreement(['type' => 'recurring']); } + $this->createCheckoutSession($request, $requestShopOrderId, $requestAmount, $cgConf['currency'], $cgConf['terminal'], $cart->id); + $request->setType($type)->setTerminal($cgConf['terminal']) ->setShopOrderId($requestShopOrderId) ->setAmount($requestAmount) ->setCurrency($cgConf['currency']) - ->setSessionID($sessionId) ->setCustomerInfo($customer) ->setTransactionInfo($transactionInfo) ->setCookie($cgConf['cookie']) @@ -3244,7 +3239,7 @@ public function createTransaction($savecard, if (!$isReservation) { $request->setConfig($config)->setLanguage($cgConf['language']); - if (!$terminal->applepay) { + if ($request instanceof API\PHP\Altapay\Api\Ecommerce\PaymentRequest) { $formTemplate = getFormTemplate(); if (!empty($formTemplate)) { $request->setFormTemplate($formTemplate); @@ -3253,9 +3248,8 @@ public function createTransaction($savecard, } try { $response = $request->call(); - $responseUrl = $response->Url ?? ($terminal->applepay ? 'cardwallet' : 'reservation'); + $responseUrl = $response->Url ?? ($request instanceof API\PHP\Altapay\Api\Payments\CardWalletAuthorize ? 'cardwallet' : 'reservation'); $orderStatus = (int) Configuration::get('ALTAPAY_OS_PENDING'); - // Handling for Apple Pay and reservation if ($responseUrl === 'cardwallet' || $responseUrl === 'reservation') { if (strtolower($response->Result) === 'success') { $orderStatus = (int) Configuration::get('authorized_payments_status'); @@ -3292,7 +3286,7 @@ public function createTransaction($savecard, $message = $e->getMessage(); } } catch (API\PHP\Altapay\Exceptions\ClientException $e) { - $message = $e->getResponse()->getBody(); + $message = (string) $e->getResponse()->getBody(); } catch (API\PHP\Altapay\Exceptions\ResponseHeaderException $e) { $message = $e->getHeader()->ErrorMessage; } catch (API\PHP\Altapay\Exceptions\ResponseMessageException $e) { @@ -3306,6 +3300,83 @@ public function createTransaction($savecard, return $response; } + /** + * Builds the list of active terminal names for a CheckoutSession request. + * + * @param string $currentTerminal + * @param string $currency + * @param int $shopId + * + * @return string[] + */ + private function getActiveTerminals($currentTerminal, $currency, $shopId) + { + $activeTerminals = []; + + if (!empty(trim($currentTerminal))) { + $activeTerminals[] = $currentTerminal; + } + + $allActive = Altapay_Models_Terminal::getActiveTerminalsForCurrency($currency, $shopId); + foreach ($allActive as $t) { + $name = $t['remote_name']; + if (!empty(trim((string) $name)) && $name !== $currentTerminal) { + $activeTerminals[] = $name; + } + } + + return $activeTerminals; + } + + /** + * Calls CheckoutSession and sets the session ID on the request. + * + * @param mixed $request + * @param string $shopOrderId + * @param float $amount + * @param string $currency + * @param string $terminal + * @param int $cartId + * + * @return void + */ + private function createCheckoutSession($request, $shopOrderId, $amount, $currency, $terminal, $cartId) + { + if (!($request instanceof API\PHP\Altapay\Api\Ecommerce\PaymentRequest)) { + return; + } + + $shopId = (int) Context::getContext()->shop->id ?: 1; + $activeTerminals = $this->getActiveTerminals($terminal, $currency, $shopId); + + $sessionKey = 'altapay_checkout_session_id_' . $cartId; + $sessionId = Context::getContext()->cookie->{$sessionKey}; + + $sessionToken = rtrim(strtr(base64_encode(hex2bin(hash_hmac('sha256', (string) $cartId, _COOKIE_KEY_))), '+/', '-_'), '='); + + if (empty($sessionId)) { + try { + $sessionRequest = new API\PHP\Altapay\Api\Payments\CheckoutSession(getAuth()); + $sessionRequest->setTerminals($activeTerminals) + ->setTerminal($terminal) + ->setShopOrderId($shopOrderId) + ->setAmount($amount) + ->setCurrency($currency) + ->setSessionId($sessionToken); + $sessionResponse = $sessionRequest->call(); + $sessionId = $sessionResponse->Session->Id ?? null; + Context::getContext()->cookie->{$sessionKey} = $sessionId; + Context::getContext()->cookie->write(); + } catch (Exception $e) { + PrestaShopLogger::addLog('CheckoutSession Exception: ' . $e->getMessage(), 3, null, $this->name, $this->id, true); + } + } + + if ($sessionId) { + $request->setSessionID($sessionId); + } + } + /** * @param array $arr * diff --git a/composer.json b/composer.json old mode 100755 new mode 100644 index 79ed11f1..c1acb00e --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require": { "php": "^7.0", - "altapay/api-php": "^3.5.8", + "altapay/api-php": "^3.5.9", "humbug/php-scoper": "0.13.9", "nikic/php-parser": "4.x-dev", "symfony/options-resolver": "^3.0", diff --git a/composer.lock b/composer.lock index b2b424a4..72e46ab6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "69fa74e65019cb9b3625cacb762206c3", + "content-hash": "3dc1a24f690a575e801dfa8b2b5b8961", "packages": [ { "name": "altapay/api-php", - "version": "3.5.8", + "version": "3.5.9", "source": { "type": "git", "url": "https://github.com/AltaPay/api-php.git", - "reference": "31202d5f34309eaf62199c90bf6520d3272a4678" + "reference": "9459d5f5f2d0a1bbed07d88328f67130a5d39b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/AltaPay/api-php/zipball/31202d5f34309eaf62199c90bf6520d3272a4678", - "reference": "31202d5f34309eaf62199c90bf6520d3272a4678", + "url": "https://api.github.com/repos/AltaPay/api-php/zipball/9459d5f5f2d0a1bbed07d88328f67130a5d39b62", + "reference": "9459d5f5f2d0a1bbed07d88328f67130a5d39b62", "shasum": "" }, "require": { @@ -58,9 +58,9 @@ ], "support": { "issues": "https://github.com/AltaPay/api-php/issues", - "source": "https://github.com/AltaPay/api-php/tree/3.5.8" + "source": "https://github.com/AltaPay/api-php/tree/3.5.9" }, - "time": "2026-03-03T12:37:33+00:00" + "time": "2026-05-12T08:50:55+00:00" }, { "name": "composer/package-versions-deprecated", @@ -133,29 +133,31 @@ "type": "tidelift" } ], + "abandoned": true, "time": "2022-01-17T14:14:24+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.10.0", + "version": "7.13.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" + "reference": "bcd989ad36c92d42a3715379af91f2defee5b8dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", - "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/bcd989ad36c92d42a3715379af91f2defee5b8dd", + "reference": "bcd989ad36c92d42a3715379af91f2defee5b8dd", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^2.3", - "guzzlehttp/psr7": "^2.8", + "guzzlehttp/promises": "^2.5", + "guzzlehttp/psr7": "^2.12.3", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-client-implementation": "1.0" @@ -163,9 +165,10 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "guzzle/client-integration-tests": "3.0.2", + "guzzle/client-integration-tests": "3.0.3", + "guzzlehttp/test-server": "^0.6", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "phpunit/phpunit": "^8.5.52 || ^9.6.34", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -243,7 +246,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.10.0" + "source": "https://github.com/guzzle/guzzle/tree/7.13.2" }, "funding": [ { @@ -259,28 +262,29 @@ "type": "tidelift" } ], - "time": "2025-08-23T22:36:01+00:00" + "time": "2026-07-05T19:00:11+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.3.0", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "481557b130ef3790cf82b713667b43030dc9c957" + "reference": "4360e982f87f5f258bf872d094647791db2f4c8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", - "reference": "481557b130ef3790cf82b713667b43030dc9c957", + "url": "https://api.github.com/repos/guzzle/promises/zipball/4360e982f87f5f258bf872d094647791db2f4c8e", + "reference": "4360e982f87f5f258bf872d094647791db2f4c8e", "shasum": "" }, "require": { - "php": "^7.2.5 || ^8.0" + "php": "^7.2.5 || ^8.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.44 || ^9.6.25" + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "type": "library", "extra": { @@ -326,7 +330,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.3.0" + "source": "https://github.com/guzzle/promises/tree/2.5.0" }, "funding": [ { @@ -342,27 +346,29 @@ "type": "tidelift" } ], - "time": "2025-08-22T14:34:08+00:00" + "time": "2026-06-02T12:23:43+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.9.0", + "version": "2.12.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "7d0ed42f28e42d61352a7a79de682e5e67fec884" + "reference": "7ec62dc3f44aa218487dbed81a9bf9bc647be55d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/7d0ed42f28e42d61352a7a79de682e5e67fec884", - "reference": "7d0ed42f28e42d61352a7a79de682e5e67fec884", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/7ec62dc3f44aa218487dbed81a9bf9bc647be55d", + "reference": "7ec62dc3f44aa218487dbed81a9bf9bc647be55d", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" + "ralouphie/getallheaders": "^3.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-factory-implementation": "1.0", @@ -370,9 +376,9 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "0.9.0", + "http-interop/http-factory-tests": "1.1.0", "jshttp/mime-db": "1.54.0.1", - "phpunit/phpunit": "^8.5.44 || ^9.6.25" + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -443,7 +449,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.9.0" + "source": "https://github.com/guzzle/psr7/tree/2.12.3" }, "funding": [ { @@ -459,7 +465,7 @@ "type": "tidelift" } ], - "time": "2026-03-10T16:41:02+00:00" + "time": "2026-06-23T15:21:08+00:00" }, { "name": "humbug/php-scoper", @@ -547,12 +553,12 @@ "source": { "type": "git", "url": "https://github.com/JetBrains/phpstorm-stubs", - "reference": "cf7bde202a8ead67564ae9008e2badb0dc760891" + "reference": "48f5d22369e2acaacc85fa4b64273812702fa8d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/cf7bde202a8ead67564ae9008e2badb0dc760891", - "reference": "cf7bde202a8ead67564ae9008e2badb0dc760891", + "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/48f5d22369e2acaacc85fa4b64273812702fa8d5", + "reference": "48f5d22369e2acaacc85fa4b64273812702fa8d5", "shasum": "" }, "require-dev": { @@ -584,7 +590,7 @@ "stubs", "type" ], - "time": "2026-03-17T19:50:07+00:00" + "time": "2026-07-05T15:55:54+00:00" }, { "name": "nikic/php-parser", @@ -1401,16 +1407,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.33.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + "reference": "141046a8f9477948ff284fa65be2095baafb94f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2", + "reference": "141046a8f9477948ff284fa65be2095baafb94f2", "shasum": "" }, "require": { @@ -1460,7 +1466,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0" }, "funding": [ { @@ -1480,20 +1486,20 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.33.0", + "version": "v1.38.2", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", "shasum": "" }, "require": { @@ -1545,7 +1551,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.38.2" }, "funding": [ { @@ -1565,11 +1571,11 @@ "type": "tidelift" } ], - "time": "2024-12-23T08:48:59+00:00" + "time": "2026-05-27T06:59:30+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.33.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -1625,7 +1631,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.37.0" }, "funding": [ { @@ -1649,16 +1655,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.33.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dfb55726c3a76ea3b6459fcfda1ec2d80a682411", + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411", "shasum": "" }, "require": { @@ -1709,7 +1715,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0" }, "funding": [ { @@ -1729,7 +1735,7 @@ "type": "tidelift" } ], - "time": "2025-01-02T08:10:11+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/service-contracts", diff --git a/config.xml b/config.xml index 7c2468de..dcea2cf1 100644 --- a/config.xml +++ b/config.xml @@ -10,7 +10,7 @@ altapay - + diff --git a/controllers/front/callbackform.php b/controllers/front/callbackform.php index 58964ee6..cd145bf3 100644 --- a/controllers/front/callbackform.php +++ b/controllers/front/callbackform.php @@ -34,6 +34,9 @@ public function postProcess() $shopOrderId = $postData['shop_orderid']; $cart = getCartFromUniqueId($shopOrderId); + if (!Validate::isLoadedObject($cart)) { + exit('Could not load cart - exiting'); + } $checksum = !empty($postData['checksum']) ? $postData['checksum'] : ''; $terminalRemoteName = getCvvLess($cart->id, $shopOrderId); $terminal_name = getTransactionTerminalByUniqueId($shopOrderId); diff --git a/controllers/front/callbackok.php b/controllers/front/callbackok.php index 9e11b6c5..4e75bfbe 100644 --- a/controllers/front/callbackok.php +++ b/controllers/front/callbackok.php @@ -32,7 +32,12 @@ public function postProcess() // Locking prevents attempt to create order in PrestaShop if notification & ok callbacks get processed simultaneously. $lockFileName = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'callback_lock_' . md5($postData['transaction_id']) . '.lock'; - $lockFileHandle = lockCallback($lockFileName); + $lockFileHandle = lockCallback($lockFileName, false); + + if ($lockFileHandle === false) { + $pollingUrl = $this->context->link->getModuleLink('altapay', 'callbackopenvalidate', ['order_id' => $postData['shop_orderid']]); + Tools::redirect($pollingUrl); + } $message = ''; $callback = new API\PHP\Altapay\Api\Ecommerce\Callback($postData); @@ -140,6 +145,13 @@ public function postProcess() } catch (Exception $e) { $message = $e->getMessage(); } + + if (!empty($postData['status']) && $postData['status'] === 'succeeded') { + unlockCallback($lockFileName, $lockFileHandle); + $pollingUrl = $this->context->link->getModuleLink('altapay', 'callbackopenvalidate', ['order_id' => $postData['shop_orderid']]); + Tools::redirect($pollingUrl); + } + saveLogs($message); redirectUserToCheckoutPaymentStep($lockFileName, $lockFileHandle); } diff --git a/controllers/front/checkorderstatus.php b/controllers/front/checkorderstatus.php index 9ff7d733..63924af1 100644 --- a/controllers/front/checkorderstatus.php +++ b/controllers/front/checkorderstatus.php @@ -38,6 +38,9 @@ public function initContent() if (!in_array($transactionStatus, $errorStatus, true)) { // Load the order object $cart = getCartFromUniqueId($shopOrderId); + if (!Validate::isLoadedObject($cart)) { + $this->ajaxDie(json_encode(['success' => false])); + } $orderId = Order::getOrderByCartId((int) ($cart->id)); $order = new Order($orderId); $customer = new Customer($cart->id_customer); diff --git a/helpers.php b/helpers.php index c7a5f438..c7b0c25a 100644 --- a/helpers.php +++ b/helpers.php @@ -24,7 +24,7 @@ function transactionInfo($transactionInfo = []) { $pluginName = 'altapay'; - $pluginVersion = '5.0.0'; + $pluginVersion = '5.0.1'; // Transaction info $transactionInfo['ecomPlatform'] = 'PrestaShop'; @@ -891,14 +891,15 @@ function getAltaPayCallbackData() } /** - * @param $lockFileName + * @param string $lockFileName + * @param bool $blocking * - * @return false|mixed|resource|void + * @return false|resource */ -function lockCallback($lockFileName) +function lockCallback($lockFileName, $blocking = true) { - $maxRetries = 10; // Maximum number of retry attempts - $retryDelay = 1000000; // 1-second delay between retries (in microseconds) + $maxRetries = $blocking ? 10 : 3; // Maximum number of retry attempts + $retryDelay = $blocking ? 1000000 : 200000; // blocking: 1 s, non-blocking: 200 ms // Attempt to acquire the lock with retry mechanism $lockAcquired = false; @@ -927,6 +928,9 @@ function lockCallback($lockFileName) if (!$lockAcquired) { // Lock acquisition failed after maximum retries, handle appropriately + if (!$blocking) { + return false; + } $message = 'Unable to acquire lock after maximum retries'; $module = Module::getInstanceByName('altapay'); PrestaShopLogger::addLog($message, 3, '1004', $module->name, $module->id, true); diff --git a/tests/integration-tests-1.6.1.x/cypress/e2e/PageObjects/objects.cy.js b/tests/integration-tests-1.6.1.x/cypress/e2e/PageObjects/objects.cy.js index 65c8f1ab..b7b73074 100644 --- a/tests/integration-tests-1.6.1.x/cypress/e2e/PageObjects/objects.cy.js +++ b/tests/integration-tests-1.6.1.x/cypress/e2e/PageObjects/objects.cy.js @@ -39,8 +39,6 @@ class Order cy.contains(CC_TERMINAL_NAME).click({force: true}) cy.get('[id=creditCardNumberInput]').type('4111111111111111') - cy.get('#emonth').select('12') - cy.get('#eyear').select('2025') cy.get('#cvcInput').type('123') cy.get('#cardholderNameInput').type('testname') cy.get('#pensioCreditCardPaymentSubmitButton').click().wait(4000) diff --git a/tests/integration-tests-1.7.7.x/cypress/e2e/PageObjects/objects.cy.js b/tests/integration-tests-1.7.7.x/cypress/e2e/PageObjects/objects.cy.js index b5aa751f..6f9bef56 100644 --- a/tests/integration-tests-1.7.7.x/cypress/e2e/PageObjects/objects.cy.js +++ b/tests/integration-tests-1.7.7.x/cypress/e2e/PageObjects/objects.cy.js @@ -47,8 +47,6 @@ class Order cy.get('.condition-label > .js-terms').click() cy.get('.ps-shown-by-js > .btn').click() cy.get('[id=creditCardNumberInput]').type('4111111111111111') - cy.get('#emonth').select('12') - cy.get('#eyear').select('2025') cy.get('#cvcInput').type('123') cy.get('#cardholderNameInput').type('testname') cy.get('#pensioCreditCardPaymentSubmitButton').click().wait(4000) @@ -389,8 +387,6 @@ class Order cy.get('#generate-payment-link-btn').click().wait(8000) cy.get('a[href^="https://testgateway.pensio.com/eCommerce/API/requestForm?pid="]').click() cy.get('[id=creditCardNumberInput]').type('4111111111111111') - cy.get('#emonth').select('12') - cy.get('#eyear').select('2025') cy.get('#cvcInput').type('123') cy.get('#cardholderNameInput').type('testname') cy.get('#pensioCreditCardPaymentSubmitButton').click().wait(4000)