From fff2742e3bc350863b2a25d9861fdee0be87ee58 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 11:18:18 +0300 Subject: [PATCH 01/19] fi --- saferpayofficial.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/saferpayofficial.php b/saferpayofficial.php index ae2d77b1..cf7b5ed8 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -369,6 +369,18 @@ public function hookActionFrontControllerSetMedia() $this->context->controller->addJs(Configuration::get($fieldsLibrary . $configSuffix)); } + break; + case \Invertus\SaferPay\Config\SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); + } else { + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/opc/thecheckout/saferpay_checkout_16.css"); + $this->context->controller->addJS("{$this->getPathUri()}views/js/front/opc/thecheckout/saferpay_saved_card_16.js"); + $fieldsLibrary = \Invertus\SaferPay\Config\SaferPayConfig::FIELDS_LIBRARY; + $configSuffix = \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix(); + $this->context->controller->addJs(Configuration::get($fieldsLibrary . $configSuffix)); + } + break; } From 092ff2d90815b59880204c1d3504ecbab097beca Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 10:58:25 +0300 Subject: [PATCH 02/19] added compatibility opcps --- src/Config/SaferPayConfig.php | 2 +- .../Loader/PaymentFormAssetLoader.php | 18 +++++- .../opc/onepagecheckoutps/hosted_fields.js | 59 +++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 views/js/front/opc/onepagecheckoutps/hosted_fields.js diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 546ef3d4..2e02a8fe 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -279,7 +279,7 @@ class SaferPayConfig const SUPER_CHECKOUT_MODULE = 'supercheckout'; const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; - + const ONE_PAGE_CHECKOUT_FRONT_CONTROLLER = 'OrderController' || 'OrderControllerCore'; const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE, diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 4eeceb44..1d1d5dd3 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -84,7 +84,23 @@ public function register($controller) private function registerOnePageCheckoutAssets($controller) { - // TODO: will be implemented in other branches + if (get_class($controller) != SaferPayConfig::ONE_PAGE_CHECKOUT_FRONT_CONTROLLER) { + return; + } + + $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); + + if (method_exists($controller, 'registerJavascript')) { + $controller->registerJavascript( + 'saved_card_hosted_fields_opc', + "modules/saferpayofficial/views/js/front/opc/onepagecheckoutps/hosted_fields.js" + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/opc/onepagecheckoutps/hosted_fields.js', + false + ); + } } private function registerTheCheckoutAssets($controller) diff --git a/views/js/front/opc/onepagecheckoutps/hosted_fields.js b/views/js/front/opc/onepagecheckoutps/hosted_fields.js new file mode 100644 index 00000000..2b8162f7 --- /dev/null +++ b/views/js/front/opc/onepagecheckoutps/hosted_fields.js @@ -0,0 +1,59 @@ +/** + *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 + */ + +$(document).ready(function () { + $('body').on('change', "input[name^='saved_card_']", function () { + var $selectedCard = $(this); + var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); + $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); + }); +}); + +$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { + event.preventDefault(); + + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); + var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + + //NOTE: not saved card chosen, continuing with normal procedures. + if (selectedCard <= 0) { + event.target.submit(); + + return; + } + + $.ajax(saferpay_official_ajax_url, { + method: 'POST', + data: { + action: 'submitHostedFields', + paymentMethod: selectedCardMethod, + selectedCard: selectedCard, + isBusinessLicence: 1, + ajax: 1 + }, + success: function (response) { + var data = jQuery.parseJSON(response); + + window.location = data.url; + }, + }); +}); \ No newline at end of file From 38db797a33052d95946d2ca3750df75b323a9275 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:41:02 +0300 Subject: [PATCH 03/19] compatibility --- src/Config/SaferPayConfig.php | 1 + .../Loader/PaymentFormAssetLoader.php | 18 +++++- views/css/front/saferpay_checkout.css | 13 ++++ .../front/opc/supercheckout/hosted_fields.js | 59 +++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 views/js/front/opc/supercheckout/hosted_fields.js diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 2e02a8fe..586eabaf 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -280,6 +280,7 @@ class SaferPayConfig const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; const ONE_PAGE_CHECKOUT_FRONT_CONTROLLER = 'OrderController' || 'OrderControllerCore'; + const SUPER_CHECKOUT_FRONT_CONTROLLER = 'SupercheckoutSupercheckoutModuleFrontController'; const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE, diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 1d1d5dd3..730722da 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -126,7 +126,23 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - // TODO: will be implemented in other branches + if (get_class($controller) !== SaferPayConfig::SUPER_CHECKOUT_FRONT_CONTROLLER) { + return; + } + + $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); + + if (method_exists($controller, 'registerJavascript')) { + $controller->registerJavascript( + 'saved_card_hosted_fields_opc', + "modules/saferpayofficial/views/js/front/opc/supercheckout/hosted_fields.js" + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/opc/supercheckout/hosted_fields.js', + false + ); + } } private function registerDefaultCheckoutAssets($controller) diff --git a/views/css/front/saferpay_checkout.css b/views/css/front/saferpay_checkout.css index f98495b3..a100ae4c 100755 --- a/views/css/front/saferpay_checkout.css +++ b/views/css/front/saferpay_checkout.css @@ -34,3 +34,16 @@ .payment-logo { max-width: 40px; } + +input[type="radio"][name^="saved_card_"] { + opacity: 1 !important; + width: 15px !important; + position: relative !important; + vertical-align: middle !important; + margin: 0 !important; +} +.saved_credit_cards span { + padding-left: 3px !important; + vertical-align: middle !important; + margin: 0 !important; +} diff --git a/views/js/front/opc/supercheckout/hosted_fields.js b/views/js/front/opc/supercheckout/hosted_fields.js new file mode 100644 index 00000000..2b8162f7 --- /dev/null +++ b/views/js/front/opc/supercheckout/hosted_fields.js @@ -0,0 +1,59 @@ +/** + *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 + */ + +$(document).ready(function () { + $('body').on('change', "input[name^='saved_card_']", function () { + var $selectedCard = $(this); + var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); + $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); + }); +}); + +$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { + event.preventDefault(); + + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); + var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + + //NOTE: not saved card chosen, continuing with normal procedures. + if (selectedCard <= 0) { + event.target.submit(); + + return; + } + + $.ajax(saferpay_official_ajax_url, { + method: 'POST', + data: { + action: 'submitHostedFields', + paymentMethod: selectedCardMethod, + selectedCard: selectedCard, + isBusinessLicence: 1, + ajax: 1 + }, + success: function (response) { + var data = jQuery.parseJSON(response); + + window.location = data.url; + }, + }); +}); \ No newline at end of file From e3bbf9cb76ddb76612aac4559d2b21154577f1d1 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:45:56 +0300 Subject: [PATCH 04/19] revert --- views/css/front/saferpay_checkout.css | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/views/css/front/saferpay_checkout.css b/views/css/front/saferpay_checkout.css index a100ae4c..f98495b3 100755 --- a/views/css/front/saferpay_checkout.css +++ b/views/css/front/saferpay_checkout.css @@ -34,16 +34,3 @@ .payment-logo { max-width: 40px; } - -input[type="radio"][name^="saved_card_"] { - opacity: 1 !important; - width: 15px !important; - position: relative !important; - vertical-align: middle !important; - margin: 0 !important; -} -.saved_credit_cards span { - padding-left: 3px !important; - vertical-align: middle !important; - margin: 0 !important; -} From e310a39a495cab575c7a237025054cd9d0a062c6 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:46:31 +0300 Subject: [PATCH 05/19] revert --- .../front/opc/supercheckout/hosted_fields.js | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 views/js/front/opc/supercheckout/hosted_fields.js diff --git a/views/js/front/opc/supercheckout/hosted_fields.js b/views/js/front/opc/supercheckout/hosted_fields.js deleted file mode 100644 index 2b8162f7..00000000 --- a/views/js/front/opc/supercheckout/hosted_fields.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - *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 - */ - -$(document).ready(function () { - $('body').on('change', "input[name^='saved_card_']", function () { - var $selectedCard = $(this); - var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); - $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); - }); -}); - -$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { - event.preventDefault(); - - var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); - - //NOTE: not saved card chosen, continuing with normal procedures. - if (selectedCard <= 0) { - event.target.submit(); - - return; - } - - $.ajax(saferpay_official_ajax_url, { - method: 'POST', - data: { - action: 'submitHostedFields', - paymentMethod: selectedCardMethod, - selectedCard: selectedCard, - isBusinessLicence: 1, - ajax: 1 - }, - success: function (response) { - var data = jQuery.parseJSON(response); - - window.location = data.url; - }, - }); -}); \ No newline at end of file From f5b367a42f44625857a733e52ad042835b95d015 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:47:36 +0300 Subject: [PATCH 06/19] revert --- .../Loader/PaymentFormAssetLoader.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 730722da..1d1d5dd3 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -126,23 +126,7 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - if (get_class($controller) !== SaferPayConfig::SUPER_CHECKOUT_FRONT_CONTROLLER) { - return; - } - - $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); - - if (method_exists($controller, 'registerJavascript')) { - $controller->registerJavascript( - 'saved_card_hosted_fields_opc', - "modules/saferpayofficial/views/js/front/opc/supercheckout/hosted_fields.js" - ); - } else { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/opc/supercheckout/hosted_fields.js', - false - ); - } + // TODO: will be implemented in other branches } private function registerDefaultCheckoutAssets($controller) From 857ba8289c691580029e4761286afe03ce171ffe Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:50:00 +0300 Subject: [PATCH 07/19] revert --- src/Config/SaferPayConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 586eabaf..2540af8f 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -280,7 +280,7 @@ class SaferPayConfig const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; const ONE_PAGE_CHECKOUT_FRONT_CONTROLLER = 'OrderController' || 'OrderControllerCore'; - const SUPER_CHECKOUT_FRONT_CONTROLLER = 'SupercheckoutSupercheckoutModuleFrontController'; + const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE, From 0b7ffd7be456b0a9c13addb31f2723f58849dd89 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:56:47 +0300 Subject: [PATCH 08/19] Revert "revert" This reverts commit 857ba8289c691580029e4761286afe03ce171ffe. --- src/Config/SaferPayConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 2540af8f..586eabaf 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -280,7 +280,7 @@ class SaferPayConfig const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; const ONE_PAGE_CHECKOUT_FRONT_CONTROLLER = 'OrderController' || 'OrderControllerCore'; - + const SUPER_CHECKOUT_FRONT_CONTROLLER = 'SupercheckoutSupercheckoutModuleFrontController'; const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE, From 71bc3c1ff89d5a35b73a3b3b41e6ea1decc1cf86 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:56:52 +0300 Subject: [PATCH 09/19] Revert "revert" This reverts commit f5b367a42f44625857a733e52ad042835b95d015. --- .../Loader/PaymentFormAssetLoader.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 1d1d5dd3..730722da 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -126,7 +126,23 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - // TODO: will be implemented in other branches + if (get_class($controller) !== SaferPayConfig::SUPER_CHECKOUT_FRONT_CONTROLLER) { + return; + } + + $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); + + if (method_exists($controller, 'registerJavascript')) { + $controller->registerJavascript( + 'saved_card_hosted_fields_opc', + "modules/saferpayofficial/views/js/front/opc/supercheckout/hosted_fields.js" + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/opc/supercheckout/hosted_fields.js', + false + ); + } } private function registerDefaultCheckoutAssets($controller) From 840131998ae1354306d13ef01b5320476bce33e1 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:56:54 +0300 Subject: [PATCH 10/19] Revert "revert" This reverts commit e310a39a495cab575c7a237025054cd9d0a062c6. --- .../front/opc/supercheckout/hosted_fields.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 views/js/front/opc/supercheckout/hosted_fields.js diff --git a/views/js/front/opc/supercheckout/hosted_fields.js b/views/js/front/opc/supercheckout/hosted_fields.js new file mode 100644 index 00000000..2b8162f7 --- /dev/null +++ b/views/js/front/opc/supercheckout/hosted_fields.js @@ -0,0 +1,59 @@ +/** + *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 + */ + +$(document).ready(function () { + $('body').on('change', "input[name^='saved_card_']", function () { + var $selectedCard = $(this); + var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); + $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); + }); +}); + +$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { + event.preventDefault(); + + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); + var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + + //NOTE: not saved card chosen, continuing with normal procedures. + if (selectedCard <= 0) { + event.target.submit(); + + return; + } + + $.ajax(saferpay_official_ajax_url, { + method: 'POST', + data: { + action: 'submitHostedFields', + paymentMethod: selectedCardMethod, + selectedCard: selectedCard, + isBusinessLicence: 1, + ajax: 1 + }, + success: function (response) { + var data = jQuery.parseJSON(response); + + window.location = data.url; + }, + }); +}); \ No newline at end of file From 65cec16654bc9abe385ed7c50e0fec84e9d10293 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 12:56:55 +0300 Subject: [PATCH 11/19] Revert "revert" This reverts commit e3bbf9cb76ddb76612aac4559d2b21154577f1d1. --- views/css/front/saferpay_checkout.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/views/css/front/saferpay_checkout.css b/views/css/front/saferpay_checkout.css index f98495b3..a100ae4c 100755 --- a/views/css/front/saferpay_checkout.css +++ b/views/css/front/saferpay_checkout.css @@ -34,3 +34,16 @@ .payment-logo { max-width: 40px; } + +input[type="radio"][name^="saved_card_"] { + opacity: 1 !important; + width: 15px !important; + position: relative !important; + vertical-align: middle !important; + margin: 0 !important; +} +.saved_credit_cards span { + padding-left: 3px !important; + vertical-align: middle !important; + margin: 0 !important; +} From dd2a27758b684b95a17524eb7de7c0c5379b4ca4 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 18 Oct 2024 15:44:28 +0300 Subject: [PATCH 12/19] fix --- src/Config/SaferPayConfig.php | 2 -- src/Presentation/Loader/PaymentFormAssetLoader.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 586eabaf..0a139e14 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -277,9 +277,7 @@ class SaferPayConfig const ONE_PAGE_CHECKOUT_MODULE = 'onepagecheckoutps'; const THE_CHECKOUT_MODULE = 'thecheckout'; const SUPER_CHECKOUT_MODULE = 'supercheckout'; - const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; - const ONE_PAGE_CHECKOUT_FRONT_CONTROLLER = 'OrderController' || 'OrderControllerCore'; const SUPER_CHECKOUT_FRONT_CONTROLLER = 'SupercheckoutSupercheckoutModuleFrontController'; const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 730722da..0e82fa6e 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -84,7 +84,7 @@ public function register($controller) private function registerOnePageCheckoutAssets($controller) { - if (get_class($controller) != SaferPayConfig::ONE_PAGE_CHECKOUT_FRONT_CONTROLLER) { + if (!$controller instanceof \OrderControllerCore) { return; } From 79911277233e690c753bfc4f055d23df2c80ffc7 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 18 Oct 2024 15:56:18 +0300 Subject: [PATCH 13/19] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 0e82fa6e..3f2276b7 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -26,6 +26,7 @@ use Configuration; use Invertus\SaferPay\Adapter\LegacyContext; use Invertus\SaferPay\Config\SaferPayConfig; +use Invertus\SaferPay\DTO\Request\Order; use Invertus\SaferPay\Enum\ControllerName; use Invertus\SaferPay\Enum\PaymentType; use Invertus\SaferPay\Factory\ModuleFactory; @@ -126,7 +127,7 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - if (get_class($controller) !== SaferPayConfig::SUPER_CHECKOUT_FRONT_CONTROLLER) { + if (!$controller instanceof \SupercheckoutSupercheckoutModuleFrontController) { return; } From 3ad9df9e035c96f81e728b720d34c647b2fa541c Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 18 Oct 2024 15:58:06 +0300 Subject: [PATCH 14/19] removed config --- src/Config/SaferPayConfig.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 0a139e14..e761bbb9 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -278,7 +278,6 @@ class SaferPayConfig const THE_CHECKOUT_MODULE = 'thecheckout'; const SUPER_CHECKOUT_MODULE = 'supercheckout'; const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; - const SUPER_CHECKOUT_FRONT_CONTROLLER = 'SupercheckoutSupercheckoutModuleFrontController'; const OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE, From 8fca55637056dcb70f86f03df9f4842df0e50ffc Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sun, 20 Oct 2024 11:13:34 +0300 Subject: [PATCH 15/19] update sql --- src/Install/Installer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Install/Installer.php b/src/Install/Installer.php index a6cdacca..6e09c2f2 100755 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -300,17 +300,17 @@ private function installSaferPayLog() { return Db::getInstance()->execute( 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . pSQL(\SaferPayLog::$definition['table']) . '( - `id_saferpay_log` INTEGER(10) NOT NULL AUTO_INCREMENT, + `id_saferpay_log` INTEGER(10) unsigned NOT NULL AUTO_INCREMENT, `id_log` INT(10) NOT NULL, `id_shop` INT(10) NOT NULL DEFAULT ' . (int) Configuration::get('PS_SHOP_DEFAULT') . ', `message` TEXT DEFAULT NULL, `request` MEDIUMTEXT DEFAULT NULL, `response` MEDIUMTEXT DEFAULT NULL, `context` TEXT DEFAULT NULL, - `date_add` DATETIME NOT NULL, + `date_add` DATETIME NOT NULL CURRENT_TIMESTAMP, PRIMARY KEY(`id_saferpay_log`, `id_log`, `id_shop`), INDEX(`id_log`) - ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci' + ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;' ); } From 72a944c60716cd0d4aff538c174721410471e8b4 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sun, 20 Oct 2024 11:39:24 +0300 Subject: [PATCH 16/19] Fixed SQL --- src/Install/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 6e09c2f2..f198ca4b 100755 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -307,7 +307,7 @@ private function installSaferPayLog() `request` MEDIUMTEXT DEFAULT NULL, `response` MEDIUMTEXT DEFAULT NULL, `context` TEXT DEFAULT NULL, - `date_add` DATETIME NOT NULL CURRENT_TIMESTAMP, + `date_add` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(`id_saferpay_log`, `id_log`, `id_shop`), INDEX(`id_log`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;' From fad0c018300771757ac8425e7c7ab7a0484f9408 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 21 Oct 2024 19:09:26 +0300 Subject: [PATCH 17/19] added more redirect payment to prevent double statuses --- src/Config/SaferPayConfig.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 89fc5845..0490cfad 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -304,7 +304,9 @@ public static function isRedirectPayment($paymentMethod) self::PAYMENT_APPLEPAY, self::PAYMENT_GOOGLEPAY, self::PAYMENT_TWINT, - self::PAYMENT_POSTFINANCE_PAY + self::PAYMENT_POSTFINANCE_PAY, + self::PAYMENT_DIRECTDEBIT, + self::PAYMENT_SOFORT ]; return in_array($paymentMethod, $paymentsAlwaysRedirect); From 3ce7e633256574a64bbc1fe322a4266dea799554 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 22 Oct 2024 09:37:12 +0300 Subject: [PATCH 18/19] update --- .../AdminSaferPayOfficialSettingsController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 794cb4b4..76a449d7 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -56,12 +56,24 @@ public function postProcess() { parent::postProcess(); - $isCreditCardSaveEnabled = Configuration::get(SaferPayConfig::CREDIT_CARD_SAVE); + /** @var \Invertus\SaferPay\Adapter\Configuration $configuration */ + $configuration = $this->module->getService(\Invertus\SaferPay\Adapter\Configuration::class); + + $isCreditCardSaveEnabled = $configuration->get(SaferPayConfig::CREDIT_CARD_SAVE); + if (!$isCreditCardSaveEnabled) { /** @var SaferPaySavedCreditCardRepository $cardRepo */ $cardRepo = $this->module->getService(SaferPaySavedCreditCardRepository::class); $cardRepo->deleteAllSavedCreditCards(); } + + $haveFieldToken = $configuration->get(SaferPayConfig::FIELDS_ACCESS_TOKEN . SaferPayConfig::getConfigSuffix()); + $haveBusinessLicense = $configuration->get(SaferPayConfig::BUSINESS_LICENSE . SaferPayConfig::getConfigSuffix()); + + if (!$haveFieldToken && $haveBusinessLicense) { + $configuration->set(SaferPayConfig::BUSINESS_LICENSE . SaferPayConfig::getConfigSuffix(), 0); + $this->errors[] = $this->module->l('Field Access Token is required to use business license'); + } } public function initOptions() From a53468a68b8a6db66ad2bd2937aff5ba14922500 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 22 Oct 2024 10:35:02 +0300 Subject: [PATCH 19/19] fixed google apple status --- controllers/front/return.php | 4 ++++ src/DTO/Response/PaymentMeans.php | 20 ++++++++++++++++++- .../Response/ResponseObjectCreator.php | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/controllers/front/return.php b/controllers/front/return.php index cebbb441..27fd10b9 100755 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -87,6 +87,10 @@ public function postProcess() $orderPayment = $assertResponseBody->getPaymentMeans()->getBrand()->getPaymentMethod(); + if (!empty($assertResponseBody->getPaymentMeans()->getWallet())) { + $orderPayment = $assertResponseBody->getPaymentMeans()->getWallet(); + } + /** @var SaferPayFieldRepository $saferPayFieldRepository */ $saferPayFieldRepository = $this->module->getService(SaferPayFieldRepository::class); diff --git a/src/DTO/Response/PaymentMeans.php b/src/DTO/Response/PaymentMeans.php index c80990e7..21bdc750 100755 --- a/src/DTO/Response/PaymentMeans.php +++ b/src/DTO/Response/PaymentMeans.php @@ -43,6 +43,10 @@ class PaymentMeans * @var Card */ private $card; + /** + * @var string + */ + private $wallet; /** * PaymentMeans constructor. @@ -50,11 +54,12 @@ class PaymentMeans * @param string $displayText * @param Card|null $card */ - public function __construct(Brand $brand = null, $displayText = null, Card $card = null) + public function __construct(Brand $brand = null, $displayText = null, Card $card = null, $wallet = null) { $this->brand = $brand; $this->displayText = $displayText; $this->card = $card; + $this->wallet = $wallet; } /** @@ -97,6 +102,14 @@ public function getCard() return $this->card; } + /** + * @return string + */ + public function getWallet() + { + return $this->wallet; + } + /** * @param Card $card */ @@ -104,4 +117,9 @@ public function setCard($card) { $this->card = $card; } + + public function setWallet($wallet) + { + $this->wallet = $wallet; + } } diff --git a/src/Service/Response/ResponseObjectCreator.php b/src/Service/Response/ResponseObjectCreator.php index 6db2cd0e..38c4b882 100755 --- a/src/Service/Response/ResponseObjectCreator.php +++ b/src/Service/Response/ResponseObjectCreator.php @@ -89,6 +89,9 @@ protected function createPaymentMeans($paymentMeans) } $paymentMeansObj->setBrand($brandObj); $paymentMeansObj->setDisplayText($paymentMeans->DisplayText); + if (isset($paymentMeans->Wallet)) { + $paymentMeansObj->setWallet($paymentMeans->Wallet); + } return $paymentMeansObj; }