diff --git a/CHANGELOG b/CHANGELOG index 1b4e110..23542dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +4.2.9 + - FN-14233 Fixed a bug in extra commission calculation for loan amount (priceModifier) and in plugin update notification display logic. + 4.2.8 - FN-14209 Fixed some bugs. diff --git a/CHANGELOG.md b/CHANGELOG.md index b1fffa5..5b966cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [4.2.9](https://github.com/comfino/PrestaShop/tree/4.2.9) (2026-03-06) + +[Full Changelog](https://github.com/comfino/PrestaShop/compare/4.2.8...4.2.9) + +**Merged pull requests:** + +- FN-14233 Fixed a bug in extra commission calculation for loan amount (priceModifier) and in plugin update notification display logic. [\#113](https://github.com/comfino/PrestaShop/pull/113) ([akozubskicr](https://github.com/akozubskicr)) + ## [4.2.8](https://github.com/comfino/PrestaShop/tree/4.2.8) (2026-03-04) [Full Changelog](https://github.com/comfino/PrestaShop/compare/4.2.7...4.2.8) diff --git a/comfino.php b/comfino.php index 217d096..567d2ee 100644 --- a/comfino.php +++ b/comfino.php @@ -37,11 +37,11 @@ } if (!defined('COMFINO_VERSION')) { - define('COMFINO_VERSION', '4.2.8'); + define('COMFINO_VERSION', '4.2.9'); } if (!defined('COMFINO_BUILD_TS')) { - define('COMFINO_BUILD_TS', 1772632040); + define('COMFINO_BUILD_TS', 1772806598); } if (!defined('WIDGET_INIT_SCRIPT_HASH')) { @@ -63,7 +63,7 @@ public function __construct() { $this->name = 'comfino'; $this->tab = 'payments_gateways'; - $this->version = '4.2.8'; + $this->version = '4.2.9'; $this->author = 'Comfino'; $this->module_key = '3d3e14c65281e816da083e34491d5a7f'; @@ -426,8 +426,15 @@ private function checkGithubVersion() $lastCheckTime = Configuration::get('COMFINO_GITHUB_VERSION_CHECK_TIME'); if ($lastCheckTime && (time() - (int) $lastCheckTime) < 86400) { - // Checked within last 24 hours, skip. - return; + // Checked within last 24 hours - but bypass if the running version changed (e.g. after an update). + if (is_array($cachedInfo = json_decode(Configuration::get('COMFINO_GITHUB_VERSION_INFO'), true)) + && (isset($cachedInfo['current_version']) ? $cachedInfo['current_version'] : '') === COMFINO_VERSION + ) { + return; + } + + // Version changed since last cache - force refresh. + Comfino\Update\UpdateManager::forceCheckForUpdates(); } $updateInfo = Comfino\Update\UpdateManager::checkForUpdates(); diff --git a/composer.lock b/composer.lock index 3d88705..aa3a843 100644 --- a/composer.lock +++ b/composer.lock @@ -344,12 +344,12 @@ "source": { "type": "git", "url": "git@github.com:comfino/shop-plugins-shared.git", - "reference": "dbf46b5bd29989c047254c147fd3c9adfb8637dc" + "reference": "2fd36377577438e5b05a341fd9d7c6c98deee1ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/comfino/shop-plugins-shared/zipball/dbf46b5bd29989c047254c147fd3c9adfb8637dc", - "reference": "dbf46b5bd29989c047254c147fd3c9adfb8637dc", + "url": "https://api.github.com/repos/comfino/shop-plugins-shared/zipball/2fd36377577438e5b05a341fd9d7c6c98deee1ce", + "reference": "2fd36377577438e5b05a341fd9d7c6c98deee1ce", "shasum": "" }, "require": { @@ -399,7 +399,7 @@ "source": "https://github.com/comfino/shop-plugins-shared/tree/master", "issues": "https://github.com/comfino/shop-plugins-shared/issues" }, - "time": "2026-01-22T11:35:36+00:00" + "time": "2026-03-06T14:15:43+00:00" }, { "name": "fig/http-message-util", @@ -4778,16 +4778,16 @@ }, { "name": "symfony/console", - "version": "v6.4.31", + "version": "v6.4.34", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f9f8a889f54c264f9abac3fc0f7a371ffca51997" + "reference": "7b1f1c37eff5910ddda2831345467e593a5120ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f9f8a889f54c264f9abac3fc0f7a371ffca51997", - "reference": "f9f8a889f54c264f9abac3fc0f7a371ffca51997", + "url": "https://api.github.com/repos/symfony/console/zipball/7b1f1c37eff5910ddda2831345467e593a5120ad", + "reference": "7b1f1c37eff5910ddda2831345467e593a5120ad", "shasum": "" }, "require": { @@ -4852,7 +4852,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.31" + "source": "https://github.com/symfony/console/tree/v6.4.34" }, "funding": [ { @@ -4872,20 +4872,20 @@ "type": "tidelift" } ], - "time": "2025-12-22T08:30:34+00:00" + "time": "2026-02-23T15:42:15+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.4.25", + "version": "v6.4.32", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "b0cf3162020603587363f0551cd3be43958611ff" + "reference": "99d7e101826e6610606b9433248f80c1997cd20b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b0cf3162020603587363f0551cd3be43958611ff", - "reference": "b0cf3162020603587363f0551cd3be43958611ff", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/99d7e101826e6610606b9433248f80c1997cd20b", + "reference": "99d7e101826e6610606b9433248f80c1997cd20b", "shasum": "" }, "require": { @@ -4936,7 +4936,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.25" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.32" }, "funding": [ { @@ -4956,7 +4956,7 @@ "type": "tidelift" } ], - "time": "2025-08-13T09:41:44+00:00" + "time": "2026-01-05T11:13:48+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5036,16 +5036,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.30", + "version": "v6.4.34", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789" + "reference": "01ffe0411b842f93c571e5c391f289c3fdd498c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/441c6b69f7222aadae7cbf5df588496d5ee37789", - "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/01ffe0411b842f93c571e5c391f289c3fdd498c3", + "reference": "01ffe0411b842f93c571e5c391f289c3fdd498c3", "shasum": "" }, "require": { @@ -5082,7 +5082,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.30" + "source": "https://github.com/symfony/filesystem/tree/v6.4.34" }, "funding": [ { @@ -5102,20 +5102,20 @@ "type": "tidelift" } ], - "time": "2025-11-26T14:43:45+00:00" + "time": "2026-02-24T17:51:06+00:00" }, { "name": "symfony/finder", - "version": "v6.4.31", + "version": "v6.4.34", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "5547f2e1f0ca8e2e7abe490156b62da778cfbe2b" + "reference": "9590e86be1d1c57bfbb16d0dd040345378c20896" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/5547f2e1f0ca8e2e7abe490156b62da778cfbe2b", - "reference": "5547f2e1f0ca8e2e7abe490156b62da778cfbe2b", + "url": "https://api.github.com/repos/symfony/finder/zipball/9590e86be1d1c57bfbb16d0dd040345378c20896", + "reference": "9590e86be1d1c57bfbb16d0dd040345378c20896", "shasum": "" }, "require": { @@ -5150,7 +5150,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.4.31" + "source": "https://github.com/symfony/finder/tree/v6.4.34" }, "funding": [ { @@ -5170,7 +5170,7 @@ "type": "tidelift" } ], - "time": "2025-12-11T14:52:17+00:00" + "time": "2026-01-28T15:16:37+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -5506,16 +5506,16 @@ }, { "name": "symfony/process", - "version": "v6.4.31", + "version": "v6.4.33", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8541b7308fca001320e90bca8a73a28aa5604a6e" + "reference": "c46e854e79b52d07666e43924a20cb6dc546644e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8541b7308fca001320e90bca8a73a28aa5604a6e", - "reference": "8541b7308fca001320e90bca8a73a28aa5604a6e", + "url": "https://api.github.com/repos/symfony/process/zipball/c46e854e79b52d07666e43924a20cb6dc546644e", + "reference": "c46e854e79b52d07666e43924a20cb6dc546644e", "shasum": "" }, "require": { @@ -5547,7 +5547,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.31" + "source": "https://github.com/symfony/process/tree/v6.4.33" }, "funding": [ { @@ -5567,7 +5567,7 @@ "type": "tidelift" } ], - "time": "2025-12-15T19:26:35+00:00" + "time": "2026-01-23T16:02:12+00:00" }, { "name": "symfony/service-contracts", @@ -5724,16 +5724,16 @@ }, { "name": "symfony/string", - "version": "v7.4.0", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003" + "reference": "9f209231affa85aa930a5e46e6eb03381424b30b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003", - "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003", + "url": "https://api.github.com/repos/symfony/string/zipball/9f209231affa85aa930a5e46e6eb03381424b30b", + "reference": "9f209231affa85aa930a5e46e6eb03381424b30b", "shasum": "" }, "require": { @@ -5791,7 +5791,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.4.0" + "source": "https://github.com/symfony/string/tree/v7.4.6" }, "funding": [ { @@ -5811,7 +5811,7 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-02-09T09:33:46+00:00" }, { "name": "webmozart/assert", diff --git a/controllers/front/payment.php b/controllers/front/payment.php index ad17b86..ebc085f 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -126,10 +126,15 @@ public function postProcess(): void } $initLoanAmount = (int) filter_var($cookie->loan_amount, FILTER_VALIDATE_INT); - $priceModifier = (int) filter_var($cookie->price_modifier, FILTER_VALIDATE_INT); $loanType = trim(filter_var($cookie->loan_type, FILTER_SANITIZE_STRING)); $loanTerm = (int) filter_var($cookie->loan_term, FILTER_VALIDATE_INT); + $priceModifier = filter_var($cookie->price_modifier, FILTER_VALIDATE_INT); + + if ($priceModifier === false || $priceModifier < 0 || $priceModifier > 1000000) { + $priceModifier = 0; + } + $psOrder = new \Order($this->module->currentOrder); try { diff --git a/controllers/front/paywall.php b/controllers/front/paywall.php index c9c54d6..f47c793 100644 --- a/controllers/front/paywall.php +++ b/controllers/front/paywall.php @@ -43,6 +43,9 @@ class ComfinoPaywallModuleFrontController extends ModuleFrontController { + /** + * @throws Exception + */ public function initContent(): void { ErrorLogger::init(); @@ -55,13 +58,17 @@ public function initContent(): void return; } - if (!Tools::isEmpty('priceModifier') && is_numeric(Tools::getValue('priceModifier'))) { - $priceModifier = (int) filter_var(Tools::getValue('priceModifier'), FILTER_VALIDATE_INT); + if (!Tools::isEmpty('priceModifier') && ctype_digit(Tools::getValue('priceModifier'))) { + $priceModifier = filter_var(Tools::getValue('priceModifier'), FILTER_VALIDATE_INT); + + if ($priceModifier === false || $priceModifier < 0 || $priceModifier > 1000000) { + $priceModifier = 0; + } } else { $priceModifier = 0; } - $loanAmount = (int) round(round($this->context->cart->getOrderTotal(), 2) * 100); + $cartTotal = (int) round(round($this->context->cart->getOrderTotal(), 2) * 100); $shopCart = OrderManager::getShopCart($this->context->cart, $priceModifier); $allowedProductTypes = SettingsManager::getAllowedProductTypes( @@ -80,7 +87,7 @@ public function initContent(): void '[PAYWALL]', 'renderPaywall', [ - '$loanAmount' => $loanAmount, + '$cartTotal' => $cartTotal, '$priceModifier' => $priceModifier, '$cartTotalValue' => $shopCart->getTotalValue(), '$allowedProductTypes' => $allowedProductTypes, @@ -99,7 +106,7 @@ public function initContent(): void try { $paywallContents = ApiClient::getInstance()->getPaywall( - new LoanQueryCriteria($loanAmount, null, null, $allowedProductTypes), + new LoanQueryCriteria($cartTotal, null, null, $priceModifier, $allowedProductTypes), $paywallUrl ); diff --git a/src/View/FrontendManager.php b/src/View/FrontendManager.php index 4ed5a7c..536726c 100644 --- a/src/View/FrontendManager.php +++ b/src/View/FrontendManager.php @@ -245,13 +245,13 @@ public static function displayGithubVersionNotice(\Comfino $module): string } $updateInfo = json_decode($updateInfoJson, true); + $githubVersion = $updateInfo['github_version'] ?? ''; - if (!isset($updateInfo['update_available']) || !$updateInfo['update_available']) { + // Re-evaluate against current version to avoid showing stale cached notice after an update. + if (empty($githubVersion) || !version_compare($githubVersion, COMFINO_VERSION, '>')) { return ''; } - $githubVersion = $updateInfo['github_version'] ?? ''; - // Check if this version was already dismissed. if ($dismissedVersion === $githubVersion) { return ''; diff --git a/upgrade/init-4.2.9.php b/upgrade/init-4.2.9.php new file mode 100644 index 0000000..1b2a64f --- /dev/null +++ b/upgrade/init-4.2.9.php @@ -0,0 +1,47 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +use Comfino\Main; + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * @return bool + */ +function upgrade_module_4_2_9(Comfino $module) +{ + if (!$module->checkEnvironment()) { + return false; + } + + @unlink(_PS_MODULE_DIR_ . $module->name . '/views/js/front/paywall-init.js'); + + Main::updateUpgradeLog('Upgrade script for 4.2.9 executed.'); + + return true; +} diff --git a/vendor/comfino/shop-plugins-shared/src/Api/Dto/Payment/LoanQueryCriteria.php b/vendor/comfino/shop-plugins-shared/src/Api/Dto/Payment/LoanQueryCriteria.php index 44d1099..3f7dc4d 100644 --- a/vendor/comfino/shop-plugins-shared/src/Api/Dto/Payment/LoanQueryCriteria.php +++ b/vendor/comfino/shop-plugins-shared/src/Api/Dto/Payment/LoanQueryCriteria.php @@ -12,6 +12,8 @@ class LoanQueryCriteria public $loanType; + public $priceModifier; + public $productTypes; public $taxId; @@ -20,14 +22,16 @@ class LoanQueryCriteria * @param int $loanAmount * @param int|null $loanTerm * @param LoanTypeEnum|null $loanType + * @param int|null $priceModifier * @param LoanTypeEnum[]|null $productTypes * @param string|null $taxId */ - public function __construct(int $loanAmount, ?int $loanTerm = null, ?LoanTypeEnum $loanType = null, ?array $productTypes = null, ?string $taxId = null) + public function __construct(int $loanAmount, ?int $loanTerm = null, ?LoanTypeEnum $loanType = null, ?int $priceModifier = null, ?array $productTypes = null, ?string $taxId = null) { $this->loanAmount = $loanAmount; $this->loanTerm = $loanTerm; $this->loanType = $loanType; + $this->priceModifier = $priceModifier; $this->productTypes = $productTypes; $this->taxId = $taxId; } diff --git a/vendor/comfino/shop-plugins-shared/src/Api/Request/GetPaywall.php b/vendor/comfino/shop-plugins-shared/src/Api/Request/GetPaywall.php index 248c6d1..9d6e779 100644 --- a/vendor/comfino/shop-plugins-shared/src/Api/Request/GetPaywall.php +++ b/vendor/comfino/shop-plugins-shared/src/Api/Request/GetPaywall.php @@ -23,6 +23,7 @@ public function __construct(LoanQueryCriteria $queryCriteria, ?string $recalcula 'loanAmount' => $queryCriteria->loanAmount, 'loanTerm' => $queryCriteria->loanTerm, 'loanTypeSelected' => $queryCriteria->loanType, + 'priceModifier' => $queryCriteria->priceModifier, 'productTypes' => ($queryCriteria->productTypes !== null ? implode(',', $queryCriteria->productTypes) : null), 'taxId' => $queryCriteria->taxId, ], diff --git a/vendor/comfino/shop-plugins-shared/src/Common/Api/Client.php b/vendor/comfino/shop-plugins-shared/src/Common/Api/Client.php index 9c4f2ff..8c7c05e 100644 --- a/vendor/comfino/shop-plugins-shared/src/Common/Api/Client.php +++ b/vendor/comfino/shop-plugins-shared/src/Common/Api/Client.php @@ -15,7 +15,6 @@ use ComfinoExternal\Sunrise\Http\Factory\RequestFactory; use ComfinoExternal\Sunrise\Http\Factory\ResponseFactory; use ComfinoExternal\Sunrise\Http\Factory\StreamFactory; -use ComfinoExternal\Sunrise\Http\Message\Response; class Client extends \Comfino\Extended\Api\Client { @@ -35,6 +34,13 @@ class Client extends \Comfino\Extended\Api\Client * @var array */ protected $options = []; + + private const MAX_CONNECTION_TIMEOUT = 30; + + private const MAX_TRANSFER_TIMEOUT = 60; + + private const DEFAULT_MAX_ATTEMPTS = 3; + /** * @var \ComfinoExternal\Sunrise\Http\Factory\ResponseFactory */ @@ -58,12 +64,13 @@ public function __construct( $this->transferTimeout = $transferTimeout; $this->connectionMaxNumAttempts = $connectionMaxNumAttempts; $this->options = $options; + if ($this->connectionTimeout >= $this->transferTimeout) { $this->transferTimeout = 3 * $this->connectionTimeout; } if ($this->connectionMaxNumAttempts === 0) { - $this->connectionMaxNumAttempts = 3; + $this->connectionMaxNumAttempts = self::DEFAULT_MAX_ATTEMPTS; } self::$responseFactory = new ResponseFactory(); @@ -125,49 +132,53 @@ public function resetClient($connectionTimeout, $transferTimeout, $connectionMax /** * @param int $connectAttemptIdx + * @return int */ public function calculateConnectionTimeout($connectAttemptIdx): int { - if ($connectAttemptIdx <= 1 || $connectAttemptIdx > $this->connectionMaxNumAttempts || $this->connectionMaxNumAttempts <= 1) { + if ($connectAttemptIdx < 1 || $connectAttemptIdx > $this->connectionMaxNumAttempts) { return $this->connectionTimeout; } - static $initSeqIndex = 0; - - if ($initSeqIndex === 0) { - $initSeqIndex = $this->findFibonacciSequenceIndex($this->connectionTimeout); + if ($this->connectionMaxNumAttempts <= 1) { + return $this->connectionTimeout; } - return $this->calcFibonacciNumber($initSeqIndex + $connectAttemptIdx - 1); + $timeout = $this->connectionTimeout << ($connectAttemptIdx - 1); + + return min($timeout, self::MAX_CONNECTION_TIMEOUT); } /** * @param int $connectAttemptIdx + * @return int */ public function calculateTransferTimeout($connectAttemptIdx): int { - if ($connectAttemptIdx <= 1 || $connectAttemptIdx > $this->connectionMaxNumAttempts || $this->connectionMaxNumAttempts <= 1) { + if ($connectAttemptIdx < 1 || $connectAttemptIdx > $this->connectionMaxNumAttempts) { return $this->transferTimeout; } - static $initSeqIndex = 0; - - if ($initSeqIndex === 0) { - $initSeqIndex = $this->findFibonacciSequenceIndex($this->transferTimeout); + if ($this->connectionMaxNumAttempts <= 1) { + return $this->transferTimeout; } - return $this->calcFibonacciNumber($initSeqIndex + $connectAttemptIdx - 1); + $timeout = $this->transferTimeout << ($connectAttemptIdx - 1); + + return min($timeout, self::MAX_TRANSFER_TIMEOUT); } /** - * @throws ClientExceptionInterface - * @param \Comfino\Api\Request $request + * @param Request $request * @param int|null $apiVersion + * @return ResponseInterface + * @throws ClientExceptionInterface + * @throws ConnectionTimeout */ protected function sendRequest($request, $apiVersion = null): ResponseInterface { - $connectionTimeout = $this->connectionTimeout; - $transferTimeout = $this->transferTimeout; + $lastConnectionTimeout = $this->connectionTimeout; + $lastTransferTimeout = $this->transferTimeout; for ($connectAttemptIdx = 1; $connectAttemptIdx <= $this->connectionMaxNumAttempts; $connectAttemptIdx++) { try { @@ -175,76 +186,50 @@ protected function sendRequest($request, $apiVersion = null): ResponseInterface } catch (ClientExceptionInterface $e) { if ($e->getCode() === CURLE_OPERATION_TIMEDOUT) { if ($connectAttemptIdx < $this->connectionMaxNumAttempts) { - $connectionTimeout = $this->calculateConnectionTimeout($connectAttemptIdx); - $transferTimeout = $this->calculateTransferTimeout($connectAttemptIdx); - - $this->client = $this->createClient($connectionTimeout, $transferTimeout, $this->options); - } else { - throw new ConnectionTimeout( - $e->getMessage(), - $e->getCode(), - $e, - $connectAttemptIdx, - $connectionTimeout, - $transferTimeout, - $request->getRequestUri() ?? '', - $request->getRequestBody() ?? '' - ); + $lastConnectionTimeout = $this->calculateConnectionTimeout($connectAttemptIdx + 1); + $lastTransferTimeout = $this->calculateTransferTimeout($connectAttemptIdx + 1); + + $this->client = $this->createClient($lastConnectionTimeout, $lastTransferTimeout, $this->options); + + continue; } - } else { - throw $e; + + throw new ConnectionTimeout( + $e->getMessage(), + $e->getCode(), + $e, + $connectAttemptIdx, + $lastConnectionTimeout, + $lastTransferTimeout, + $request->getRequestUri() ?? '', + $request->getRequestBody() ?? '' + ); } + + throw $e; } } - return new Response(); + throw new \RuntimeException('Unexpected state: retry loop completed without return or exception.'); } /** * @param int $connectionTimeout * @param int $transferTimeout - * @param mixed[] $options + * @param array $options + * @return \ComfinoExternal\Sunrise\Http\Client\Curl\Client */ protected function createClient($connectionTimeout, $transferTimeout, $options = []): \ComfinoExternal\Sunrise\Http\Client\Curl\Client { - $clientOptions = [CURLOPT_CONNECTTIMEOUT => $connectionTimeout, CURLOPT_TIMEOUT => $transferTimeout]; + $clientOptions = [ + CURLOPT_CONNECTTIMEOUT => $connectionTimeout, + CURLOPT_TIMEOUT => $transferTimeout + ]; - foreach ($options as $optionIdx => $valueValue) { - $clientOptions[$optionIdx] = $valueValue; + foreach ($options as $optionKey => $optionValue) { + $clientOptions[$optionKey] = $optionValue; } return new \ComfinoExternal\Sunrise\Http\Client\Curl\Client(self::$responseFactory, $clientOptions); } - - /** - * @param int $fibNum - * @return int - */ - protected function findFibonacciSequenceIndex($fibNum): int - { - return (int) round(2.078087 * log($fibNum) + 1.672276); - } - - /** - * @param int $n - * @return int - */ - protected function calcFibonacciNumber($n): int - { - static $phi = 1.6180339; - static $fibSequence = [0, 1, 1, 2, 3, 5]; - - if ($n < 6) { - return $fibSequence[$n]; - } - - $i = 5; - $fn = 5; - - while ($i++ < $n) { - $fn = (int) round($fn * $phi); - } - - return $fn; - } } diff --git a/vendor/comfino/shop-plugins-shared/src/Common/Backend/FileUtils.php b/vendor/comfino/shop-plugins-shared/src/Common/Backend/FileUtils.php index a02016b..d6b890d 100644 --- a/vendor/comfino/shop-plugins-shared/src/Common/Backend/FileUtils.php +++ b/vendor/comfino/shop-plugins-shared/src/Common/Backend/FileUtils.php @@ -78,6 +78,14 @@ public static function append($filePath, $content): void (new \SplFileObject($filePath, 'a'))->fwrite($content); } + /** + * @param string $filePath + */ + public static function exists($filePath): bool + { + return (new \SplFileInfo($filePath))->isFile(); + } + /** * @param string $filePath */ diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e076c77..66174c6 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -354,12 +354,12 @@ "source": { "type": "git", "url": "git@github.com:comfino/shop-plugins-shared.git", - "reference": "dbf46b5bd29989c047254c147fd3c9adfb8637dc" + "reference": "2fd36377577438e5b05a341fd9d7c6c98deee1ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/comfino/shop-plugins-shared/zipball/dbf46b5bd29989c047254c147fd3c9adfb8637dc", - "reference": "dbf46b5bd29989c047254c147fd3c9adfb8637dc", + "url": "https://api.github.com/repos/comfino/shop-plugins-shared/zipball/2fd36377577438e5b05a341fd9d7c6c98deee1ce", + "reference": "2fd36377577438e5b05a341fd9d7c6c98deee1ce", "shasum": "" }, "require": { @@ -381,7 +381,7 @@ "phpspec/prophecy-phpunit": "^1.1", "phpunit/phpunit": "^5.7" }, - "time": "2026-01-22T11:35:36+00:00", + "time": "2026-03-06T14:15:43+00:00", "default-branch": true, "type": "library", "installation-source": "dist", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 2b21aff..2fd920b 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'comfino/prestashop', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '629b6bf9df5a514b9575dafee063b2bda878a184', + 'reference' => 'c9facab6267414d880eeb084cb85f8315abc29dd', 'type' => 'prestashop-module', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -58,7 +58,7 @@ 'comfino/prestashop' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '629b6bf9df5a514b9575dafee063b2bda878a184', + 'reference' => 'c9facab6267414d880eeb084cb85f8315abc29dd', 'type' => 'prestashop-module', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -67,7 +67,7 @@ 'comfino/shop-plugins-shared' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'dbf46b5bd29989c047254c147fd3c9adfb8637dc', + 'reference' => '2fd36377577438e5b05a341fd9d7c6c98deee1ce', 'type' => 'library', 'install_path' => __DIR__ . '/../comfino/shop-plugins-shared', 'aliases' => array( diff --git a/views/js/front/paywall-init.js b/views/js/front/paywall-init.js index 1f248f7..e87d380 100644 --- a/views/js/front/paywall-init.js +++ b/views/js/front/paywall-init.js @@ -45,15 +45,11 @@ window.ComfinoPaywallInit = { const iframe = ComfinoPaywallFrontend.createPaywallIframe(ComfinoPaywallData.paywallUrl, ComfinoPaywallData.paywallOptions); const frontendInitElement = document.getElementById('pay-with-comfino') ?? document.querySelector('input[data-module-name^="comfino"]'); - let priceModifier = 0; - if ('priceModifier' in frontendInitElement.dataset) { - priceModifier = parseInt(frontendInitElement.dataset.priceModifier); + let priceModifier = parseInt(frontendInitElement.dataset.priceModifier); if (!Number.isNaN(priceModifier)) { iframe.src += ((iframe.src.includes('?') ? '&' : '?') + 'priceModifier=' + priceModifier); - } else { - priceModifier = 0; } } @@ -66,7 +62,7 @@ window.ComfinoPaywallInit = { loan_amount: loanParams.loanAmount, loan_type: loanParams.loanType, loan_term: loanParams.loanTerm, - price_modifier: priceModifier + price_modifier: loanParams.priceModifier }; for (let paramName in urlParams) { diff --git a/views/js/front/paywall-init.min.js b/views/js/front/paywall-init.min.js index e370077..3aa95e4 100644 --- a/views/js/front/paywall-init.min.js +++ b/views/js/front/paywall-init.min.js @@ -2,8 +2,8 @@ Since 2007 PrestaShop SA and Contributors @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ -window.ComfinoPaywallInit={init:()=>{const a=document.getElementById("comfino-iframe-container");document.getElementById("comfino-iframe-container")?.querySelector("#comfino-paywall-container")?.remove();if(null==a)ComfinoPaywallFrontend.logEvent("Comfino paywall iframe container not found.","warning");else if(null!==a.querySelector("#comfino-paywall-container")&&ComfinoPaywallFrontend.isFrontendInitSet())ComfinoPaywallFrontend.logEvent("Comfino paywall iframe already initialized.","info",a);else{var b= -ComfinoPaywallFrontend.createPaywallIframe(ComfinoPaywallData.paywallUrl,ComfinoPaywallData.paywallOptions),f=document.getElementById("pay-with-comfino")??document.querySelector('input[data-module-name^="comfino"]'),d=0;"priceModifier"in f.dataset&&(d=parseInt(f.dataset.priceModifier),Number.isNaN(d)?d=0:b.src+=(b.src.includes("?")?"&":"?")+"priceModifier="+d);ComfinoPaywallData.paywallOptions.onUpdateOrderPaymentState=c=>{ComfinoPaywallFrontend.logEvent("updateOrderPaymentState PrestaShop","debug", -c);const k=new URL(ComfinoPaywallData.paywallStateUrl),g=new FormData;c={loan_amount:c.loanAmount,loan_type:c.loanType,loan_term:c.loanTerm,price_modifier:d};for(let e in c)g.append(e,c[e]);const h=k.toString();fetch(h,{method:"POST",body:g}).then(e=>{ComfinoPaywallFrontend.logEvent("updateOrderPaymentState PrestaShop","debug",h,e)})};a.appendChild(b);ComfinoPaywallFrontend.init(f,b,ComfinoPaywallData.paywallOptions)}},initWithObserver:()=>{ComfinoPaywallInit.init();if(!ComfinoPaywallFrontend.isFrontendInitSet()){var a= -document.getElementById("pay-with-comfino")??document.querySelector('input[data-module-name^="comfino"]');if(a){ComfinoPaywallFrontend.logEvent("Paywall initialization with 'display' prop observer.","debug");const b=new MutationObserver(()=>{"block"===getComputedStyle(a).display&&(ComfinoPaywallInit.init(),ComfinoPaywallFrontend.isFrontendInitSet()&&b.disconnect())});b.observe(a,{attributes:!0,attributeFilter:["style"]})}}}}; +window.ComfinoPaywallInit={init:()=>{const b=document.getElementById("comfino-iframe-container");document.getElementById("comfino-iframe-container")?.querySelector("#comfino-paywall-container")?.remove();if(null==b)ComfinoPaywallFrontend.logEvent("Comfino paywall iframe container not found.","warning");else if(null!==b.querySelector("#comfino-paywall-container")&&ComfinoPaywallFrontend.isFrontendInitSet())ComfinoPaywallFrontend.logEvent("Comfino paywall iframe already initialized.","info",b);else{var c= +ComfinoPaywallFrontend.createPaywallIframe(ComfinoPaywallData.paywallUrl,ComfinoPaywallData.paywallOptions),e=document.getElementById("pay-with-comfino")??document.querySelector('input[data-module-name^="comfino"]');if("priceModifier"in e.dataset){let a=parseInt(e.dataset.priceModifier);Number.isNaN(a)||(c.src+=(c.src.includes("?")?"&":"?")+"priceModifier="+a)}ComfinoPaywallData.paywallOptions.onUpdateOrderPaymentState=a=>{ComfinoPaywallFrontend.logEvent("updateOrderPaymentState PrestaShop","debug", +a);const h=new URL(ComfinoPaywallData.paywallStateUrl),f=new FormData;a={loan_amount:a.loanAmount,loan_type:a.loanType,loan_term:a.loanTerm,price_modifier:a.priceModifier};for(let d in a)f.append(d,a[d]);const g=h.toString();fetch(g,{method:"POST",body:f}).then(d=>{ComfinoPaywallFrontend.logEvent("updateOrderPaymentState PrestaShop","debug",g,d)})};b.appendChild(c);ComfinoPaywallFrontend.init(e,c,ComfinoPaywallData.paywallOptions)}},initWithObserver:()=>{ComfinoPaywallInit.init();if(!ComfinoPaywallFrontend.isFrontendInitSet()){var b= +document.getElementById("pay-with-comfino")??document.querySelector('input[data-module-name^="comfino"]');if(b){ComfinoPaywallFrontend.logEvent("Paywall initialization with 'display' prop observer.","debug");const c=new MutationObserver(()=>{"block"===getComputedStyle(b).display&&(ComfinoPaywallInit.init(),ComfinoPaywallFrontend.isFrontendInitSet()&&c.disconnect())});c.observe(b,{attributes:!0,attributeFilter:["style"]})}}}}; "complete"===document.readyState?ComfinoPaywallInit.initWithObserver():document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&ComfinoPaywallInit.initWithObserver()});