From bcefe713fa02668649f25d308411c1c26b153804 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 25 Oct 2024 16:34:38 +0300 Subject: [PATCH 1/6] [SL-264] init --- src/Validation/CustomerCreditCardValidation.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Validation/CustomerCreditCardValidation.php b/src/Validation/CustomerCreditCardValidation.php index b0f3037e..d487c6f1 100644 --- a/src/Validation/CustomerCreditCardValidation.php +++ b/src/Validation/CustomerCreditCardValidation.php @@ -60,9 +60,11 @@ public function __construct(SaferPayCardAliasRepository $saferPayCardAliasReposi */ public function validate($idSavedCard, $idCustomer) { - if ( - !is_numeric($idCustomer) || !is_numeric($idSavedCard) - || !isset($idCustomer) || !isset($idSavedCard)) + if ($idSavedCard <= 0 || empty($idSavedCard)) { + return true; + } + + if (!is_numeric($idCustomer) || !is_numeric($idSavedCard)) { $this->logger->error(sprintf('%s - Invalid data or bad types', self::FILE_NAME), [ 'context' => [], @@ -73,10 +75,6 @@ public function validate($idSavedCard, $idCustomer) throw SaferPayException::unknownError(); } - if ($idSavedCard <= 0) { - return true; - } - $cardOwnerId = $this->saferPayCardAliasRepository->getCustomerIdByReferenceId(pSQL($idSavedCard), pSQL($idCustomer)); if (empty($cardOwnerId)) { From 989195d429e690042e2a7adf33fc661228d73edd Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sat, 26 Oct 2024 08:52:46 +0300 Subject: [PATCH 2/6] [SL-264] disable saved cards --- ...dminSaferPayOfficialSettingsController.php | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 34864441..f08966bd 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -80,6 +80,18 @@ public function initOptions() { $this->context->smarty->assign(SaferPayConfig::PASSWORD, SaferPayConfig::WEB_SERVICE_PASSWORD_PLACEHOLDER); + $savedCardSetting = SaferPayConfig::isVersion17() ? [ + 'type' => 'radio', + 'title' => $this->l('Credit card saving for customers'), + 'validation' => 'isInt', + 'choices' => [ + 1 => $this->l('Enable'), + 0 => $this->l('Disable'), + ], + 'desc' => $this->l('Allow customers to save credit card for faster purchase'), + 'form_group_class' => 'thumbs_chose', + ] : null; + $this->fields_options = [ 'login_configurations' => [ 'title' => $this->l('TEST MODE'), @@ -261,17 +273,7 @@ public function initOptions() 'desc' => $this->l('Default payment behavior for payment without 3-D Secure'), 'form_group_class' => 'thumbs_chose', ], - SaferPayConfig::CREDIT_CARD_SAVE => [ - 'type' => 'radio', - 'title' => $this->l('Credit card saving for customers'), - 'validation' => 'isInt', - 'choices' => [ - 1 => $this->l('Enable'), - 0 => $this->l('Disable'), - ], - 'desc' => $this->l('Allow customers to save credit card for faster purchase'), - 'form_group_class' => 'thumbs_chose', - ], + SaferPayConfig::CREDIT_CARD_SAVE => $savedCardSetting, SaferPayConfig::RESTRICT_REFUND_AMOUNT_TO_CAPTURED_AMOUNT => [ 'type' => 'radio', 'title' => $this->l('Restrict RefundAmount To Captured Amount'), @@ -362,6 +364,10 @@ public function initOptions() ]; } + if (!SaferPayConfig::isVersion17()) { + unset($this->fields_options['payment_behavior']['fields'][SaferPayConfig::CREDIT_CARD_SAVE]); + } + $this->fields_options[] = $this->getFieldOptionsOrderState(); $this->fields_options[] = $this->displayConfigurationSettings(); } From 6cec2d9339936452586a632f2fbfb08eab1b1be6 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 28 Oct 2024 09:12:55 +0200 Subject: [PATCH 3/6] [SL-264] wrong annotation variable name --- saferpayofficial.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 13b77747..69ad1c75 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -179,7 +179,7 @@ public function hookActionObjectOrderPaymentAddAfter($params) public function hookPaymentOptions($params) { - /** @var Invertus\SaferPay\Service\SaferPayCartService $assertService */ + /** @var Invertus\SaferPay\Service\SaferPayCartService $cartService */ $cartService = $this->getService(\Invertus\SaferPay\Service\SaferPayCartService::class); if (!$cartService->isCurrencyAvailable($params['cart'])) { return []; From 252590f416ad5646bbd9f461fb1db5071984be39 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 28 Oct 2024 12:22:42 +0200 Subject: [PATCH 4/6] [SL-264] fixed iframe redirect --- controllers/front/successIFrame.php | 9 ++++++++- views/js/front/saferpay_iframe_16.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 views/js/front/saferpay_iframe_16.js diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index f1dc96f9..22d8e591 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -126,9 +126,16 @@ public function initContent() $this->setTemplate(SaferPayConfig::SAFERPAY_TEMPLATE_LOCATION . '/front/loading.tpl'); return; } + + $jsUrl = "{$this->module->getPathUri()}views/js/front/saferpay_iframe_16.js"; + + if (SaferPayConfig::isVersion17()) { + $jsUrl = "{$this->module->getPathUri()}views/js/front/saferpay_iframe.js"; + } + $this->context->smarty->assign([ 'cssUrl' => "{$this->module->getPathUri()}views/css/front/loading.css", - 'jsUrl' => "{$this->module->getPathUri()}views/js/front/saferpay_iframe.js", + 'jsUrl' => $jsUrl, 'redirectUrl' => $orderLink, ]); $this->setTemplate('loading_16.tpl'); diff --git a/views/js/front/saferpay_iframe_16.js b/views/js/front/saferpay_iframe_16.js new file mode 100644 index 00000000..566b5707 --- /dev/null +++ b/views/js/front/saferpay_iframe_16.js @@ -0,0 +1,28 @@ +/** + *NOTICE OF LICENSE + * + *This source file is subject to the Open Software License (OSL 3.0) + *that is bundled with this package in the file LICENSE.txt. + *It is also available through the world-wide-web at this URL: + *http://opensource.org/licenses/osl-3.0.php + *If you did not receive a copy of the license and are unable to + *obtain it through the world-wide-web, please send an email + *to license@prestashop.com so we can send you a copy immediately. + * + *DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + *versions in the future. If you wish to customize PrestaShop for your + *needs please refer to http://www.prestashop.com for more information. + * + *@author INVERTUS UAB www.invertus.eu + *@copyright SIX Payment Services + *@license SIX Payment Services + */ + +(function () { + redirectUrl = redirectUrl.replace(/&/g, "&"); + if (top.location !== window.location) { + top.location.href = redirectUrl; + } +})(); \ No newline at end of file From 7658893bb24e3600f31bf2df77ab88e6ac4682f7 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 28 Oct 2024 12:26:09 +0200 Subject: [PATCH 5/6] [SL-264] deleted code --- controllers/admin/AdminSaferPayOfficialSettingsController.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index f08966bd..0cf1b1b7 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -364,10 +364,6 @@ public function initOptions() ]; } - if (!SaferPayConfig::isVersion17()) { - unset($this->fields_options['payment_behavior']['fields'][SaferPayConfig::CREDIT_CARD_SAVE]); - } - $this->fields_options[] = $this->getFieldOptionsOrderState(); $this->fields_options[] = $this->displayConfigurationSettings(); } From 2ed85c6d7f8b11f04c0f94d840ed2b291d3f1850 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 28 Oct 2024 12:27:07 +0200 Subject: [PATCH 6/6] [SL-264] added comment --- views/js/front/saferpay_iframe_16.js | 1 + 1 file changed, 1 insertion(+) diff --git a/views/js/front/saferpay_iframe_16.js b/views/js/front/saferpay_iframe_16.js index 566b5707..a555a0d1 100644 --- a/views/js/front/saferpay_iframe_16.js +++ b/views/js/front/saferpay_iframe_16.js @@ -21,6 +21,7 @@ */ (function () { + // NOTE: Replacing because javascript gives "&" instead of "&" in the URL redirectUrl = redirectUrl.replace(/&/g, "&"); if (top.location !== window.location) { top.location.href = redirectUrl;