From 486e3b6f4fa683d6bfe643f406d6e455e9a6c635 Mon Sep 17 00:00:00 2001 From: Mateusz Twardowski Date: Wed, 12 Jun 2024 02:24:53 +0200 Subject: [PATCH 1/5] add support for php 8 and prestashop 8 --- .gitignore | 8 +++++++- README.EN.md | 2 +- README.md | 4 ++-- composer.json | 6 +++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6236da1..b617cf7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,10 @@ composer.lock .idea # composer dependencies -vendor \ No newline at end of file +vendor + +# built +dist + +# docker +docker-compose.yml diff --git a/README.EN.md b/README.EN.md index 1819345..515416c 100755 --- a/README.EN.md +++ b/README.EN.md @@ -16,7 +16,7 @@ The `paynow` plugin adds quick bank transfers, BLIK and cards payments to Presta ## Prerequisites -- PHP since 7.1 +- PHP since 7.2 - PrestaShop 1.6.0 and higher ## Installation diff --git a/README.md b/README.md index fd7e15e..dd73786 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Wtyczka `paynow` dodaje bezpieczne płatności BLIK, szybkie przelewy internetow ## Wymgania -- PHP od wersji 7.1 +- PHP od wersji 7.2 - PrestaShop od wersji 1.6.0 ## Instalacja @@ -93,4 +93,4 @@ Licencja MIT. Szczegółowe informacje znajdziesz w pliku LICENSE. [ext8]: https://paynow.wistia.com/medias/nym9wdwdwl [ext9]: instruction/step6.png [ext10]: https://panel.sandbox.paynow.pl/merchant/payments -[ext11]: instruction/step4b.png \ No newline at end of file +[ext11]: instruction/step4b.png diff --git a/composer.json b/composer.json index 460a3bc..4c6e6ad 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,9 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "ext-json": "*", - "pay-now/paynow-php-sdk": "^2.3.1", + "pay-now/paynow-php-sdk": "^2.4.0", "nyholm/psr7": "^1.2", "php-http/curl-client": "^2.1" }, @@ -22,7 +22,7 @@ }, "config": { "platform": { - "php": "7.1" + "php": "7.2" }, "prepend-autoloader": false, "optimize-autoloader": true From 233335422d9a14363bb55811a4ec2c74b4a5b029 Mon Sep 17 00:00:00 2001 From: Mateusz Twardowski Date: Wed, 19 Jun 2024 16:25:59 +0200 Subject: [PATCH 2/5] fix front scripts --- views/js/front.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/views/js/front.js b/views/js/front.js index 56bb256..fdb1050 100644 --- a/views/js/front.js +++ b/views/js/front.js @@ -76,9 +76,9 @@ var paynow = { paynow.closeMiniMenu(ev) }); - var termsErrorPlaceholderExists = $(paynow.selectors.terms).length != 0 - && $(paynow.selectors.termsLabel).length != 0 - && $(paynow.selectors.termsErrorLabel).length == 0 + var termsErrorPlaceholderExists = $(paynow.selectors.terms).length !== 0 + && $(paynow.selectors.termsLabel).length !== 0 + && $(paynow.selectors.termsErrorLabel).length === 0 if (termsErrorPlaceholderExists) { $(paynow.selectors.termsLabel).after('') @@ -173,13 +173,11 @@ var paynow = { }, onPaymentOptionChange: function () { - if ($(paynow.selectors.blikCode).length != 1) { - return + if ($(paynow.selectors.blikCode).length === 1) { + $(paynow.selectors.blikCode).mask('000 000', {placeholder: "___ ___"}) } - $(paynow.selectors.blikCode).mask('000 000', {placeholder: "___ ___"}) - - if ($(paynow.selectors.form).data('blik-autofocus') == '1') { + if ($(paynow.selectors.form).data('blik-autofocus') === '1') { $(paynow.selectors.blikCode).focus(); } @@ -188,6 +186,8 @@ var paynow = { paynow.paymentButton.hide() } 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.pblValidate() } else { paynow.paymentButton.enable() paynow.paymentButton.show() @@ -200,7 +200,7 @@ var paynow = { }, blikValidate: function () { - blik_code_value = $(paynow.selectors.blikCode).val().replace(/\s/g, ''); + const blik_code_value = $(paynow.selectors.blikCode).val().replace(/\s/g, ''); if (blik_code_value.length === 6 && !isNaN(parseInt(blik_code_value)) && parseInt(blik_code_value)) { $(paynow.selectors.blikErrorLabel).text(''); @@ -225,7 +225,7 @@ var paynow = { }, pblValidate: function () { - if (paynow.config.validateTerms && paynow.isTermsChecked()) { + if (!(paynow.config.validateTerms && !paynow.isTermsChecked()) && $(paynow.selectors.pblMethod + ':checked').length > 0) { paynow.paymentButton.enable(); return true } else { From 04c675ace0884e8d1f337a73ee4ba115b9fdb523 Mon Sep 17 00:00:00 2001 From: Mateusz Twardowski Date: Wed, 26 Jun 2024 13:51:00 +0200 Subject: [PATCH 3/5] fix checking is buyer a guest --- classes/PaynowPaymentDataBuilder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/PaynowPaymentDataBuilder.php b/classes/PaynowPaymentDataBuilder.php index b5e353b..3f6992e 100644 --- a/classes/PaynowPaymentDataBuilder.php +++ b/classes/PaynowPaymentDataBuilder.php @@ -114,8 +114,12 @@ private function build( ) ]; - if (!empty($id_customer) && $this->context->customer && $this->context->customer->is_guest === '0'){ - $request['buyer']['externalId'] = PaynowKeysGenerator::generateBuyerExternalId($id_customer, $this->module); + if (!empty($id_customer) && $this->context->customer){ + if (method_exists($this->context->customer, 'isGuest') && !$this->context->customer->isGuest()) { + $request['buyer']['externalId'] = PaynowKeysGenerator::generateBuyerExternalId($id_customer, $this->module); + } elseif ($this->context->customer->is_guest === '0') { + $request['buyer']['externalId'] = PaynowKeysGenerator::generateBuyerExternalId($id_customer, $this->module); + } } if (! empty(Tools::getValue('paymentMethodId'))) { From 39d72c0b2f09c05e0360626cdfd66e005f0c8c30 Mon Sep 17 00:00:00 2001 From: Mateusz Twardowski Date: Wed, 4 Sep 2024 14:47:38 +0200 Subject: [PATCH 4/5] add version info into payment methods --- classes/PaynowPaymentOptions.php | 3 ++- paynow.php | 3 ++- .../front/1.7/_partials/payment_data_processing_info.tpl | 6 +++++- .../hook/_partials/payment_data_processing_info.tpl | 6 +++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/classes/PaynowPaymentOptions.php b/classes/PaynowPaymentOptions.php index 3916035..3a67a06 100644 --- a/classes/PaynowPaymentOptions.php +++ b/classes/PaynowPaymentOptions.php @@ -65,7 +65,8 @@ public function generate(): array $this->context->smarty->assign([ 'action' => PaynowLinkHelper::getPaymentUrl(), - 'data_processing_notices' => $this->data_processing_notices + 'data_processing_notices' => $this->data_processing_notices, + 'data_paynow_plugin_version' => $this->module->version, ]); $isAnyPblEnabled = false; diff --git a/paynow.php b/paynow.php index 01d8ca6..a27aade 100644 --- a/paynow.php +++ b/paynow.php @@ -443,7 +443,8 @@ public function hookPayment($params) 'cta_text' => $this->getCallToActionText(), 'logo' => $this->getLogo(), 'paynow_url' => PaynowLinkHelper::getPaymentUrl(), - 'data_processing_notices' => $gdpr_notices ?? null + 'data_processing_notices' => $gdpr_notices ?? null, + 'data_paynow_plugin_version' => $this->version, ]); $digital_wallets = [ diff --git a/views/templates/front/1.7/_partials/payment_data_processing_info.tpl b/views/templates/front/1.7/_partials/payment_data_processing_info.tpl index ce15440..eea4831 100644 --- a/views/templates/front/1.7/_partials/payment_data_processing_info.tpl +++ b/views/templates/front/1.7/_partials/payment_data_processing_info.tpl @@ -13,4 +13,8 @@ {/if} {/foreach} -{/if} \ No newline at end of file +{/if} + +{if $data_paynow_plugin_version} + +{/if} diff --git a/views/templates/hook/_partials/payment_data_processing_info.tpl b/views/templates/hook/_partials/payment_data_processing_info.tpl index 231f787..7ea5518 100644 --- a/views/templates/hook/_partials/payment_data_processing_info.tpl +++ b/views/templates/hook/_partials/payment_data_processing_info.tpl @@ -29,4 +29,8 @@ -{/if} \ No newline at end of file +{/if} + +{if $data_paynow_plugin_version} + +{/if} From 60d8c50578521c4b1f0b25ebcccf3618147104a2 Mon Sep 17 00:00:00 2001 From: Mateusz Twardowski Date: Wed, 16 Oct 2024 12:33:50 +0200 Subject: [PATCH 5/5] up versions --- composer.json | 2 +- paynow.php | 2 +- upgrade/{upgrade-1.7.8.php => upgrade-1.7.9.php} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename upgrade/{upgrade-1.7.8.php => upgrade-1.7.9.php} (98%) diff --git a/composer.json b/composer.json index cc5a45d..0ee0b7d 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": ">=7.2", "ext-json": "*", - "pay-now/paynow-php-sdk": "^2.4.1", + "pay-now/paynow-php-sdk": "^2.4.2", "nyholm/psr7": "^1.2", "php-http/curl-client": "^2.1" }, diff --git a/paynow.php b/paynow.php index 01d8ca6..6fa79f4 100644 --- a/paynow.php +++ b/paynow.php @@ -49,7 +49,7 @@ public function __construct() { $this->name = 'paynow'; $this->tab = 'payments_gateways'; - $this->version = '1.7.8'; + $this->version = '1.7.9'; $this->ps_versions_compliancy = ['min' => '1.6.0', 'max' => _PS_VERSION_]; $this->author = 'mElements S.A.'; $this->is_eu_compatible = 1; diff --git a/upgrade/upgrade-1.7.8.php b/upgrade/upgrade-1.7.9.php similarity index 98% rename from upgrade/upgrade-1.7.8.php rename to upgrade/upgrade-1.7.9.php index e16ebef..aadbb3a 100644 --- a/upgrade/upgrade-1.7.8.php +++ b/upgrade/upgrade-1.7.9.php @@ -17,7 +17,7 @@ /** * @throws PrestaShopDatabaseException */ -function upgrade_module_1_7_8($module) +function upgrade_module_1_7_9($module) { try {