From 68c2d651c667d9bbeed550a57730dd4d582d45cf Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Mon, 2 Feb 2026 17:30:17 +0100 Subject: [PATCH] update --- .htaccess | 2 +- .../classes/PaynowCompatibilityHelper.php | 33 ++++++++++ .../paynow/classes/PaynowFrontController.php | 2 +- modules/paynow/classes/PaynowLinkHelper.php | 2 +- modules/paynow/classes/PaynowLogger.php | 2 +- .../classes/PaynowOrderStateProcessor.php | 11 +++- .../paynow/classes/PaynowPaymentOptions.php | 4 +- modules/paynow/composer.lock | 51 +++++++++------ .../paynow/controllers/front/chargeBlik.php | 2 +- modules/paynow/controllers/front/payment.php | 2 +- modules/paynow/controllers/front/return.php | 14 ++-- modules/paynow/paynow.php | 13 ++-- modules/paynow/upgrade/upgrade-1.7.13.php | 64 +++++++++++++++++++ modules/paynow/vendor/composer/installed.json | 10 ++- modules/paynow/views/css/front.css | 4 ++ modules/paynow/views/js/front.js | 1 + 16 files changed, 173 insertions(+), 44 deletions(-) create mode 100644 modules/paynow/classes/PaynowCompatibilityHelper.php create mode 100644 modules/paynow/upgrade/upgrade-1.7.13.php diff --git a/.htaccess b/.htaccess index 0e7eacf4..bdf9b4aa 100644 --- a/.htaccess +++ b/.htaccess @@ -29,7 +29,7 @@ RewriteRule ^145-materace-180x200/?$ https://lulandia.pl/s/680/materace-180x200- -SecRuleEngine Off +SecRuleEngine On diff --git a/modules/paynow/classes/PaynowCompatibilityHelper.php b/modules/paynow/classes/PaynowCompatibilityHelper.php new file mode 100644 index 00000000..6f83fe4b --- /dev/null +++ b/modules/paynow/classes/PaynowCompatibilityHelper.php @@ -0,0 +1,33 @@ +context->customer->secure_key); + return PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key); } public function isTokenValid(): bool diff --git a/modules/paynow/classes/PaynowLinkHelper.php b/modules/paynow/classes/PaynowLinkHelper.php index 1b2efa81..8462d763 100644 --- a/modules/paynow/classes/PaynowLinkHelper.php +++ b/modules/paynow/classes/PaynowLinkHelper.php @@ -29,7 +29,7 @@ class PaynowLinkHelper ); } - return PaynowLinkHelper::getReturnUrl($external_id, Tools::encrypt($secure_key)); + return PaynowLinkHelper::getReturnUrl($external_id, PaynowCompatibilityHelper::encrypt($secure_key)); } public static function getPaymentUrl($url_params = null): string diff --git a/modules/paynow/classes/PaynowLogger.php b/modules/paynow/classes/PaynowLogger.php index 3d3c2177..0c16b404 100644 --- a/modules/paynow/classes/PaynowLogger.php +++ b/modules/paynow/classes/PaynowLogger.php @@ -21,7 +21,7 @@ class PaynowLogger { if ((int)Configuration::get('PAYNOW_DEBUG_LOGS_ENABLED') === 1) { $file_name = 'paynow-' . date('Y-m-d'); - $file_path = dirname(__FILE__) . '/../log/' . $file_name . '-' . Tools::encrypt($file_name) . '.log'; + $file_path = dirname(__FILE__) . '/../log/' . $file_name . '-' . PaynowCompatibilityHelper::encrypt($file_name) . '.log'; file_put_contents($file_path, self::processRecord($type, $message, $context), FILE_APPEND); } diff --git a/modules/paynow/classes/PaynowOrderStateProcessor.php b/modules/paynow/classes/PaynowOrderStateProcessor.php index eb6b52a2..c593b1bc 100644 --- a/modules/paynow/classes/PaynowOrderStateProcessor.php +++ b/modules/paynow/classes/PaynowOrderStateProcessor.php @@ -272,7 +272,16 @@ class PaynowOrderStateProcessor } else { $payment->status = $data['status']; $payment->sent_at = $data['modifiedAt']; - $payment->save(); + $result = $payment->save(); + + if (!$result) { + PaynowLogger::debug( + 'Can\'t update paynow data entry on notification processing end', + [ + 'DB error' => Db::getInstance()->getMsgError(), + ] + ); + } } $this->lockingHelper->delete($externalIdForLockingSystem); diff --git a/modules/paynow/classes/PaynowPaymentOptions.php b/modules/paynow/classes/PaynowPaymentOptions.php index eafcf513..7f631f7a 100644 --- a/modules/paynow/classes/PaynowPaymentOptions.php +++ b/modules/paynow/classes/PaynowPaymentOptions.php @@ -160,7 +160,7 @@ class PaynowPaymentOptions 'paymentMethodId' => $payment_method->getId() ] ), - 'action_token' => Tools::encrypt($this->context->customer->secure_key ?? ''), + 'action_token' => PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key ?? ''), 'action_token_refresh' => Context::getContext()->link->getModuleLink('paynow', 'customerToken'), 'error_message' => $this->getMessage('An error occurred during the payment process'), 'terms_message' => $this->getMessage('First accept the terms of service, then click pay.'), @@ -175,7 +175,7 @@ class PaynowPaymentOptions 'paynow', 'removeSavedInstrument' ), - 'action_remove_saved_instrument_token' => Tools::encrypt($this->context->customer->secure_key ?? ''), + 'action_remove_saved_instrument_token' => PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key ?? ''), 'default_card_image' => Media::getMediaPath(_PS_MODULE_DIR_ . $this->module->name . '/views/img/card-default.svg'), 'paynow_card_instruments' => $payment_method->getSavedInstruments(), ]); diff --git a/modules/paynow/composer.lock b/modules/paynow/composer.lock index 1380a541..8a77ec2b 100644 --- a/modules/paynow/composer.lock +++ b/modules/paynow/composer.lock @@ -872,7 +872,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -932,7 +932,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" }, "funding": [ { @@ -943,6 +943,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -1025,16 +1029,16 @@ }, { "name": "composer/semver", - "version": "3.4.3", + "version": "3.4.4", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12" + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", - "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", "shasum": "" }, "require": { @@ -1086,7 +1090,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.3" + "source": "https://github.com/composer/semver/tree/3.4.4" }, "funding": [ { @@ -1096,13 +1100,9 @@ { "url": "https://github.com/composer", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" } ], - "time": "2024-09-19T14:15:21+00:00" + "time": "2025-08-20T19:15:30+00:00" }, { "name": "composer/xdebug-handler", @@ -1244,6 +1244,7 @@ "issues": "https://github.com/doctrine/annotations/issues", "source": "https://github.com/doctrine/annotations/tree/1.14.4" }, + "abandoned": true, "time": "2024-09-05T10:15:52+00:00" }, { @@ -1787,16 +1788,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.13.2", + "version": "3.13.4", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c" + "reference": "ad545ea9c1b7d270ce0fc9cbfb884161cd706119" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ad545ea9c1b7d270ce0fc9cbfb884161cd706119", + "reference": "ad545ea9c1b7d270ce0fc9cbfb884161cd706119", "shasum": "" }, "require": { @@ -1867,7 +1868,7 @@ "type": "thanks_dev" } ], - "time": "2025-06-17T22:17:01+00:00" + "time": "2025-09-05T05:47:09+00:00" }, { "name": "symfony/console", @@ -2311,7 +2312,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2370,7 +2371,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" }, "funding": [ { @@ -2381,6 +2382,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -2390,7 +2395,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -2451,7 +2456,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" }, "funding": [ { @@ -2462,6 +2467,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" diff --git a/modules/paynow/controllers/front/chargeBlik.php b/modules/paynow/controllers/front/chargeBlik.php index 2a8729f1..cffb1e10 100644 --- a/modules/paynow/controllers/front/chargeBlik.php +++ b/modules/paynow/controllers/front/chargeBlik.php @@ -81,7 +81,7 @@ class PaynowChargeBlikModuleFrontController extends PaynowFrontController 'external_id' => $payment_data['external_id'], 'paymentId' => $payment_data['payment_id'], 'paymentStatus' => $payment_data['status'], - 'token' => Tools::encrypt($this->context->customer->secure_key) + 'token' => PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key) ]) ]); diff --git a/modules/paynow/controllers/front/payment.php b/modules/paynow/controllers/front/payment.php index 62734be5..8213efd7 100644 --- a/modules/paynow/controllers/front/payment.php +++ b/modules/paynow/controllers/front/payment.php @@ -155,7 +155,7 @@ class PaynowPaymentModuleFrontController extends PaynowFrontController ])) { return PaynowLinkHelper::getReturnUrl( $payment_data['external_id'], - Tools::encrypt($payment_data['external_id']) + PaynowCompatibilityHelper::encrypt($payment_data['external_id']) ); } diff --git a/modules/paynow/controllers/front/return.php b/modules/paynow/controllers/front/return.php index 8df4fc2a..998100b2 100644 --- a/modules/paynow/controllers/front/return.php +++ b/modules/paynow/controllers/front/return.php @@ -66,12 +66,14 @@ class PaynowReturnModuleFrontController extends PaynowFrontController PaynowLogger::debug('Return: status processing failed', $statusToProcess); } - Tools::redirectLink(PaynowLinkHelper::getContinueUrl( - $this->order->id_cart, - $this->module->id, - $this->order->secure_key, - $this->payment->external_id - )); + PaynowCompatibilityHelper::redirect( + PaynowLinkHelper::getContinueUrl( + $this->order->id_cart, + $this->module->id, + $this->context->customer->secure_key, + $this->payment->external_id + ) + ); } $currentState = $this->order->getCurrentStateFull($this->context->language->id); diff --git a/modules/paynow/paynow.php b/modules/paynow/paynow.php index 9be668fe..9e4009b5 100644 --- a/modules/paynow/paynow.php +++ b/modules/paynow/paynow.php @@ -16,6 +16,7 @@ if (!defined('_PS_VERSION_')) { include_once(dirname(__FILE__) . '/vendor/autoload.php'); include_once(dirname(__FILE__) . '/classes/PaynowFrontController.php'); +include_once(dirname(__FILE__) . '/classes/PaynowCompatibilityHelper.php'); include_once(dirname(__FILE__) . '/classes/PaynowLogger.php'); include_once(dirname(__FILE__) . '/classes/PaynowHelper.php'); include_once(dirname(__FILE__) . '/classes/PaynowKeysGenerator.php'); @@ -50,7 +51,7 @@ class Paynow extends PaymentModule { $this->name = 'paynow'; $this->tab = 'payments_gateways'; - $this->version = '1.7.12'; + $this->version = '1.7.13'; $this->ps_versions_compliancy = ['min' => '1.6.0', 'max' => _PS_VERSION_]; $this->author = 'mElements S.A.'; $this->is_eu_compatible = 1; @@ -522,7 +523,7 @@ class Paynow extends PaymentModule 'paymentMethodId' => $payment_method->getId() ] ), - 'action_token' => Tools::encrypt($this->context->customer->secure_key), + 'action_token' => PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key), 'action_token_refresh' => Context::getContext()->link->getModuleLink('paynow', 'customerToken'), 'error_message' => $this->getTranslationsArray()['An error occurred during the payment process'], 'terms_message' => $this->getTranslationsArray()['First accept the terms of service, then click pay.'], @@ -548,7 +549,7 @@ class Paynow extends PaymentModule 'paynow', 'removeSavedInstrument' ), - 'action_token' => Tools::encrypt($this->context->customer->secure_key), + 'action_token' => PaynowCompatibilityHelper::encrypt($this->context->customer->secure_key), 'default_card_image' => Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/card-default.svg'), 'instruments' => $payment_method->getSavedInstruments(), ]); @@ -680,7 +681,7 @@ class Paynow extends PaymentModule public function hookDisplayAdminAfterHeader() { $file_name = 'paynow-' . date('Y-m-d'); - $file_path = dirname(__FILE__) . '/log/' . $file_name . '-' . Tools::encrypt($file_name) . '.log'; + $file_path = dirname(__FILE__) . '/log/' . $file_name . '-' . PaynowCompatibilityHelper::encrypt($file_name) . '.log'; if (Tools::getValue('show_paynow_logs')) { echo '
';
@@ -708,7 +709,9 @@ class Paynow extends PaymentModule
     public function hookActionAdminControllerSetMedia($params)
     {
         if (Tools::getValue("configure") && Tools::getValue("configure") == "paynow") {
-            ContextCore::getContext()->controller->addJquery();
+			if (method_exists(ContextCore::getContext()->controller, 'addJquery')) {
+				ContextCore::getContext()->controller->addJquery();
+			}
             ContextCore::getContext()->controller->addJS(($this->_path) . '/views/js/admin.js', 'all');
         }
     }
diff --git a/modules/paynow/upgrade/upgrade-1.7.13.php b/modules/paynow/upgrade/upgrade-1.7.13.php
new file mode 100644
index 00000000..7beadf9a
--- /dev/null
+++ b/modules/paynow/upgrade/upgrade-1.7.13.php
@@ -0,0 +1,64 @@
+executeS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "external_id"') == false) {
+			Db::getInstance()->execute('ALTER TABLE ' . _DB_PREFIX_ . 'paynow_payments ADD external_id VARCHAR(50) NOT NULL AFTER `order_reference`');
+		}
+
+		if (Db::getInstance()->ExecuteS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "total"') == false) {
+			Db::getInstance()->Execute("ALTER TABLE `" . _DB_PREFIX_ . "paynow_payments` ADD `total` DECIMAL(20,6) NOT NULL DEFAULT '0.000000' AFTER `status`;");
+		}
+
+		if (Db::getInstance()->ExecuteS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "locked"') == false) {
+			Db::getInstance()->Execute("ALTER TABLE `" . _DB_PREFIX_ . "paynow_payments` ADD `locked` TINYINT(1) NOT NULL DEFAULT 0 AFTER `total`;");
+		}
+
+		if (Db::getInstance()->ExecuteS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "counter"') == false) {
+			Db::getInstance()->Execute("ALTER TABLE `" . _DB_PREFIX_ . "paynow_payments` ADD `counter` TINYINT(1) NOT NULL DEFAULT 0 AFTER `locked`;");
+		}
+
+		if (Db::getInstance()->ExecuteS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "active"') == false) {
+			Db::getInstance()->Execute("ALTER TABLE `" . _DB_PREFIX_ . "paynow_payments` ADD `active` TINYINT(1) NOT NULL DEFAULT 0 AFTER `counter`;");
+		}
+
+		if (Db::getInstance()->ExecuteS('SHOW COLUMNS FROM ' . _DB_PREFIX_ . 'paynow_payments LIKE "sent_at"') == false) {
+			Db::getInstance()->Execute("ALTER TABLE `" . _DB_PREFIX_ . "paynow_payments` ADD `sent_at` datetime NULL AFTER `active`;");
+		}
+
+		Db::getInstance()->Execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'paynow_payment_locks` (
+			`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+			`id_order` INT(10) UNSIGNED NOT NULL DEFAULT 0,
+			`id_cart` INT(10) UNSIGNED NOT NULL DEFAULT 0,
+			`counter` tinyint(1) NOT NULL DEFAULT 0,
+			`created_at` datetime,
+			`modified_at` datetime,
+			INDEX `index_payment_cart_reference` (`id_cart`),
+			INDEX `index_payment_order_reference` (`id_order`)
+		)');
+
+	} catch (PrestaShopDatabaseException $exception) {
+        PaynowLogger::error('Fatal error on upgrade: ' . $exception->getMessage() . ' ' . $exception->getTraceAsString());
+    }
+
+    return true;
+}
diff --git a/modules/paynow/vendor/composer/installed.json b/modules/paynow/vendor/composer/installed.json
index 6132be68..401c2a45 100644
--- a/modules/paynow/vendor/composer/installed.json
+++ b/modules/paynow/vendor/composer/installed.json
@@ -908,8 +908,8 @@
         },
         {
             "name": "symfony/polyfill-php80",
-            "version": "v1.32.0",
-            "version_normalized": "1.32.0.0",
+            "version": "v1.33.0",
+            "version_normalized": "1.33.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
@@ -971,7 +971,7 @@
                 "shim"
             ],
             "support": {
-                "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0"
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0"
             },
             "funding": [
                 {
@@ -982,6 +982,10 @@
                     "url": "https://github.com/fabpot",
                     "type": "github"
                 },
+                {
+                    "url": "https://github.com/nicolas-grekas",
+                    "type": "github"
+                },
                 {
                     "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
                     "type": "tidelift"
diff --git a/modules/paynow/views/css/front.css b/modules/paynow/views/css/front.css
index 6cb02fd9..bbee051a 100644
--- a/modules/paynow/views/css/front.css
+++ b/modules/paynow/views/css/front.css
@@ -99,6 +99,7 @@ p.payment_module .paynow img {
     padding: 0;
 }
 
+button.payment__option,
 button.payment-option {
     width: 100%;
     padding: 33px 40px 34px 17px;
@@ -137,6 +138,8 @@ p.payment_module.paynow button:after {
     height: auto !important;
 }
 
+
+.payment__option img,
 .payment-option img {
     max-height: 1rem !important;
     /*max-width: 80px !important;*/
@@ -145,6 +148,7 @@ p.payment_module.paynow button:after {
     margin-left: 10px;
 }
 
+.paynow .payment__option:disabled img,
 .paynow .payment-option:disabled img {
     opacity: 0.3;
     filter: grayscale(1);
diff --git a/modules/paynow/views/js/front.js b/modules/paynow/views/js/front.js
index 3968d7c4..61318ebb 100644
--- a/modules/paynow/views/js/front.js
+++ b/modules/paynow/views/js/front.js
@@ -177,6 +177,7 @@ var paynow = {
         } else if ($(paynow.selectors.cardMethodOptions).is(':visible') && !$(paynow.selectors.cardMethod + ':checked').length) {
             paynow.paymentButton.disable()
         } else if ($('div.paynow-payment-pbls .paynow-payment-option-pbl').is(':visible')) {
+            paynow.paymentButton.show()
             paynow.pblValidate()
         } else {
             paynow.paymentButton.enable()