From f2fc6c88cc8d3d1ea5ceb57ab6454b4f8db0ea3e Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 9 Oct 2024 10:23:56 +0300 Subject: [PATCH 01/67] added action --- .../ValidateOpcModuleCompatibilityAction.php | 20 +++++++++++++++++++ src/Config/SaferPayConfig.php | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 src/Action/ValidateOpcModuleCompatibilityAction.php diff --git a/src/Action/ValidateOpcModuleCompatibilityAction.php b/src/Action/ValidateOpcModuleCompatibilityAction.php new file mode 100644 index 00000000..8238080a --- /dev/null +++ b/src/Action/ValidateOpcModuleCompatibilityAction.php @@ -0,0 +1,20 @@ + Date: Wed, 9 Oct 2024 10:37:37 +0300 Subject: [PATCH 02/67] added css to image sizes --- saferpayofficial.php | 7 +++++++ views/css/front/saferpay_opc.css | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 views/css/front/saferpay_opc.css diff --git a/saferpayofficial.php b/saferpayofficial.php index 32ab76de..45f158ab 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -347,8 +347,15 @@ public function hookActionFrontControllerSetMedia() /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); + /** @var \Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction $opcValidator */ + $opcValidator = $this->getService(\Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction::class); + $paymentFormAssetsLoader->register($this->context->controller); + if ($opcValidator->run()) { + $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_opc.css'); + } + if ($this->context->controller instanceof OrderController) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $this->context->controller->registerJavascript( diff --git a/views/css/front/saferpay_opc.css b/views/css/front/saferpay_opc.css new file mode 100644 index 00000000..c2b71608 --- /dev/null +++ b/views/css/front/saferpay_opc.css @@ -0,0 +1,3 @@ +.payment-logo { + max-width: 40px; +} \ No newline at end of file From 76fb165f3ddd84373167ec81b427103e642f8b24 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 9 Oct 2024 14:41:00 +0300 Subject: [PATCH 03/67] wip --- saferpayofficial.php | 18 ++++ .../Loader/PaymentFormAssetLoader.php | 42 ++++++++++ .../front/hosted-templates/hosted_fields.js | 84 +++++++++++++------ 3 files changed, 118 insertions(+), 26 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 45f158ab..79fb8fd5 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -354,6 +354,24 @@ public function hookActionFrontControllerSetMedia() if ($opcValidator->run()) { $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_opc.css'); + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $this->context->controller->registerJavascript( + 'saved-card', + 'modules/' . $this->name . '/views/js/front/saferpay_saved_card.js' + ); + + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); + } else { + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); + $this->context->controller->addJS("{$this->getPathUri()}views/js/front/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)); + } + + /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ + $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); + $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); } if ($this->context->controller instanceof OrderController) { diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 84f6f12c..13eacdb3 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -23,6 +23,7 @@ namespace Invertus\SaferPay\Presentation\Loader; +use Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction; use Invertus\SaferPay\Adapter\LegacyContext; use Invertus\SaferPay\Enum\ControllerName; use Invertus\SaferPay\Enum\PaymentType; @@ -50,6 +51,47 @@ public function __construct(ModuleFactory $module, LegacyContext $context) public function register($controller) { + /** @var ValidateOpcModuleCompatibilityAction $opcValidator */ + $opcValidator = $this->module->getService(ValidateOpcModuleCompatibilityAction::class); + + if ($opcValidator->run()) { + Media::addJsDef([ + 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), + 'saferpay_payment_types' => [ + 'hosted_iframe' => PaymentType::HOSTED_IFRAME, + 'iframe' => PaymentType::IFRAME, + 'basic' => PaymentType::BASIC, + ], + 'saferpay_is_opc' => true, + ]); + + if (method_exists($controller, 'registerJavascript')) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + ); + } else { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + ); + } + } else { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + false + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + false + ); + } + } + } + if (!$controller instanceof OrderControllerCore) { return; } diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index 96f254b8..d0848cba 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -22,39 +22,71 @@ $(document).ready(function () { var savedCardMethod = $('input[name="saved_card_method"]'); + var selectedCard = null; - if (!savedCardMethod.length) { + $(document).on('change', 'input[name^="saved_card_"]', function() { + if (saferpay_is_opc) { + selectedCard = getCheckedCardValue(); + } + }); + + if (!savedCardMethod.length && !saferpay_is_opc) { return; } - $('[id="payment-form"]').on('submit', function (event) { - event.preventDefault(); + $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { + handleSubmit(e, selectedCard); + }); +}); + +window.onload = function () { + if ($('input[name^="saved_card_"]').length > 0) { + console.log(true); + } +} - var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); +function handleSubmit(event, selectedCardOpc) { + event.preventDefault(); - var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - //NOTE: not saved card chosen, continuing with normal procedures. - if (selectedCard <= 0) { - event.target.submit(); + var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); - return; - } + if (saferpay_is_opc) { + selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + selectedCard = selectedCardOpc; + } - $.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; - }, - }); + //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; + }, + }); +} + +function getCheckedCardValue() { + var checkedValue = null; + $('input[name^="saved_card_"]:checked').each(function() { + if ($(this).is(':visible')) { + checkedValue = $(this).val(); + } }); -}); \ No newline at end of file + return checkedValue; +} \ No newline at end of file From fd501120477b015c17ee26bb54a8347129ae083b Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 9 Oct 2024 17:50:14 +0300 Subject: [PATCH 04/67] wip --- .../front/hosted-templates/hosted_fields.js | 52 +++++++++++++++---- views/js/front/saferpay_saved_card.js | 33 +++++++++--- 2 files changed, 66 insertions(+), 19 deletions(-) diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index d0848cba..cace2d2f 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -20,9 +20,10 @@ *@license SIX Payment Services */ +let selectedCard = null; + $(document).ready(function () { var savedCardMethod = $('input[name="saved_card_method"]'); - var selectedCard = null; $(document).on('change', 'input[name^="saved_card_"]', function() { if (saferpay_is_opc) { @@ -34,22 +35,22 @@ $(document).ready(function () { return; } - $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { - handleSubmit(e, selectedCard); - }); -}); - -window.onload = function () { - if ($('input[name^="saved_card_"]').length > 0) { - console.log(true); + if (saferpay_is_opc) { + $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { + handleOpcSubmit(e); + }); + } else { + $('[id="payment-form"]').on('submit', function (e) { + handleSubmit(e); + }); } -} + +}); function handleSubmit(event, selectedCardOpc) { event.preventDefault(); var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); if (saferpay_is_opc) { @@ -89,4 +90,33 @@ function getCheckedCardValue() { } }); return checkedValue; +} + +function handleOpcSubmit(event) { + event.preventDefault(); + + var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + + if (selectedCard <= 0) { + form[0].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 diff --git a/views/js/front/saferpay_saved_card.js b/views/js/front/saferpay_saved_card.js index f4a29055..ee4a1baa 100755 --- a/views/js/front/saferpay_saved_card.js +++ b/views/js/front/saferpay_saved_card.js @@ -20,12 +20,29 @@ *@license SIX Payment Services */ +// $(document).ready(function () { +// var $savedCards = $("input[name^='saved_card_']"); +// $savedCards.on('change', function () { +// var $selectedCard = $(this); +// var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); +// $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); +// }); +// } +// ); + $(document).ready(function () { - var $savedCards = $("input[name^='saved_card_']"); - $savedCards.on('change', function () { - var $selectedCard = $(this); - var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); - $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); - }); - } -); \ No newline at end of file + $(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); + }) +}); + +function getCheckedCardValue() { + var checkedValue = null; + $('input[name^="saved_card_"]:checked').each(function() { + if ($(this).is(':visible')) { + checkedValue = $(this).val(); + } + }); + return checkedValue; +} \ No newline at end of file From 4b7b538e8a377bcc3e15b3407a3100deabbc5096 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 9 Oct 2024 21:39:16 +0300 Subject: [PATCH 05/67] structurization --- .../ValidateOpcModuleCompatibilityAction.php | 16 +++ src/Config/SaferPayConfig.php | 5 + .../Loader/PaymentFormAssetLoader.php | 125 ++++++++++++++---- views/js/front/saferpay_saved_card.js | 12 +- 4 files changed, 131 insertions(+), 27 deletions(-) diff --git a/src/Action/ValidateOpcModuleCompatibilityAction.php b/src/Action/ValidateOpcModuleCompatibilityAction.php index 8238080a..7935b864 100644 --- a/src/Action/ValidateOpcModuleCompatibilityAction.php +++ b/src/Action/ValidateOpcModuleCompatibilityAction.php @@ -17,4 +17,20 @@ public function run() return false; } + + /** + * Get only first enabled OPC module + * + * @return string + */ + public function getEnabledOpcModule() + { + foreach (SaferPayConfig::OPC_MODULE_LIST as $opcModule) { + if (Module::isEnabled($opcModule)) { + return $opcModule; + } + } + + return ''; + } } \ No newline at end of file diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 5d25cd65..89d5f0f5 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -273,6 +273,11 @@ class SaferPayConfig const LOG_SEVERITY_LEVEL_ERROR = 3; const LOG_SEVERITY_LEVEL_MAJOR = 4; + + const ONE_PAGE_CHECKOUT_MODULE = 'onepagecheckoutps'; + const THE_CHECKOUT_MODULE = 'thecheckout'; + const SUPER_CHECKOUT_MODULE = 'supercheckout'; + const OPC_MODULE_LIST = [ 'onepagecheckoutps', 'thecheckout', diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 13eacdb3..7766e1d1 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -25,6 +25,7 @@ use Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction; use Invertus\SaferPay\Adapter\LegacyContext; +use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Enum\ControllerName; use Invertus\SaferPay\Enum\PaymentType; use Invertus\SaferPay\Factory\ModuleFactory; @@ -62,33 +63,20 @@ public function register($controller) 'iframe' => PaymentType::IFRAME, 'basic' => PaymentType::BASIC, ], - 'saferpay_is_opc' => true, + 'saferpay_is_opc' => $opcValidator->run(), ]); - if (method_exists($controller, 'registerJavascript')) { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" - ); - } else { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" - ); - } - } else { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', - false - ); - } else { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', - false - ); - } + $opcModule = $opcValidator->getEnabledOpcModule(); + switch ($opcModule) { + case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: + $this->registerOnePageCheckoutAssets($controller); + break; + case SaferPayConfig::THE_CHECKOUT_MODULE: + $this->registerTheCheckoutAssets($controller); + break; + case SaferPayConfig::SUPER_CHECKOUT_MODULE: + $this->registerSuperCheckoutAssets($controller); + break; } } @@ -131,4 +119,91 @@ public function register($controller) } } } + + private function registerOnePageCheckoutAssets($controller) + { + if (method_exists($controller, 'registerJavascript')) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + ); + } else { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + ); + } + } else { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + false + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + false + ); + } + } + } + + private function registerTheCheckoutAssets($controller) + { + if (method_exists($controller, 'registerJavascript')) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + ); + } else { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + ); + } + } else { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + false + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + false + ); + } + } + } + + private function registerSuperCheckoutAssets($controller) + { + if (method_exists($controller, 'registerJavascript')) { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + ); + } else { + $controller->registerJavascript( + 'saved_card_hosted_fields', + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + ); + } + } else { + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + false + ); + } else { + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + false + ); + } + } + } } diff --git a/views/js/front/saferpay_saved_card.js b/views/js/front/saferpay_saved_card.js index ee4a1baa..5eaea7a5 100755 --- a/views/js/front/saferpay_saved_card.js +++ b/views/js/front/saferpay_saved_card.js @@ -29,11 +29,19 @@ // }); // } // ); - +let formSubmitted = false; $(document).ready(function () { + $("#confirm_order").on('click', function () { + formSubmitted = true; + }); + $(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); + + if(!formSubmitted) { + $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); + } }) }); From dc6a2757417235fbbb33db1b5b04f3af4ff76407 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 09:00:51 +0300 Subject: [PATCH 06/67] added structure --- saferpayofficial.php | 32 +++-- .../Loader/PaymentFormAssetLoader.php | 60 +-------- .../{saferpay_opc.css => saferpay_tch.css} | 0 .../opc/thecheckout/hosted_fields_16_tch.js | 0 .../opc/thecheckout/hosted_fields_tch.js | 122 ++++++++++++++++++ .../thecheckout/saferpay_saved_card_16_tch.js | 0 .../thecheckout/saferpay_saved_card_tch.js | 47 +++++++ views/js/front/saferpay_saved_card.js | 41 ++---- 8 files changed, 202 insertions(+), 100 deletions(-) rename views/css/front/{saferpay_opc.css => saferpay_tch.css} (100%) create mode 100644 views/js/front/opc/thecheckout/hosted_fields_16_tch.js create mode 100644 views/js/front/opc/thecheckout/hosted_fields_tch.js create mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js create mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_tch.js diff --git a/saferpayofficial.php b/saferpayofficial.php index 79fb8fd5..660c3035 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -353,20 +353,26 @@ public function hookActionFrontControllerSetMedia() $paymentFormAssetsLoader->register($this->context->controller); if ($opcValidator->run()) { - $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_opc.css'); - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $this->context->controller->registerJavascript( - 'saved-card', - 'modules/' . $this->name . '/views/js/front/saferpay_saved_card.js' - ); - $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); - } else { - $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); - $this->context->controller->addJS("{$this->getPathUri()}views/js/front/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)); + switch ($opcValidator->getEnabledOpcModule()) { + case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: + $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_tch.css'); + + if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { + $this->context->controller->registerJavascript( + 'saved-card', + 'modules/' . $this->name . '/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js' + ); + + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); + } else { + $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); + $this->context->controller->addJS("{$this->getPathUri()}views/js/front/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; } /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 7766e1d1..033ea5e4 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -122,31 +122,7 @@ public function register($controller) private function registerOnePageCheckoutAssets($controller) { - if (method_exists($controller, 'registerJavascript')) { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" - ); - } else { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" - ); - } - } else { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', - false - ); - } else { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', - false - ); - } - } + // } private function registerTheCheckoutAssets($controller) @@ -155,23 +131,23 @@ private function registerTheCheckoutAssets($controller) if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_tch.js" ); } else { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16_tch.js" ); } } else { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields_tch.js', false ); } else { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16_tch.js', false ); } @@ -180,30 +156,6 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - if (method_exists($controller, 'registerJavascript')) { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" - ); - } else { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" - ); - } - } else { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', - false - ); - } else { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', - false - ); - } - } + // } } diff --git a/views/css/front/saferpay_opc.css b/views/css/front/saferpay_tch.css similarity index 100% rename from views/css/front/saferpay_opc.css rename to views/css/front/saferpay_tch.css diff --git a/views/js/front/opc/thecheckout/hosted_fields_16_tch.js b/views/js/front/opc/thecheckout/hosted_fields_16_tch.js new file mode 100644 index 00000000..e69de29b diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js new file mode 100644 index 00000000..cace2d2f --- /dev/null +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -0,0 +1,122 @@ +/** + *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 + */ + +let selectedCard = null; + +$(document).ready(function () { + var savedCardMethod = $('input[name="saved_card_method"]'); + + $(document).on('change', 'input[name^="saved_card_"]', function() { + if (saferpay_is_opc) { + selectedCard = getCheckedCardValue(); + } + }); + + if (!savedCardMethod.length && !saferpay_is_opc) { + return; + } + + if (saferpay_is_opc) { + $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { + handleOpcSubmit(e); + }); + } else { + $('[id="payment-form"]').on('submit', function (e) { + handleSubmit(e); + }); + } + +}); + +function handleSubmit(event, selectedCardOpc) { + event.preventDefault(); + + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); + var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + + if (saferpay_is_opc) { + selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + selectedCard = selectedCardOpc; + } + + //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; + }, + }); +} + +function getCheckedCardValue() { + var checkedValue = null; + $('input[name^="saved_card_"]:checked').each(function() { + if ($(this).is(':visible')) { + checkedValue = $(this).val(); + } + }); + return checkedValue; +} + +function handleOpcSubmit(event) { + event.preventDefault(); + + var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + + if (selectedCard <= 0) { + form[0].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 diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js new file mode 100644 index 00000000..e69de29b diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js new file mode 100644 index 00000000..500b6d49 --- /dev/null +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js @@ -0,0 +1,47 @@ +/** + *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 + */ + +let formSubmitted = false; +$(document).ready(function () { + $("#confirm_order").on('click', function () { + formSubmitted = true; + }); + + $(document).on('change', 'input[name^="saved_card_"]', function () { + + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + + if(!formSubmitted) { + $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); + } + }) +}); + +function getCheckedCardValue() { + var checkedValue = null; + $('input[name^="saved_card_"]:checked').each(function() { + if ($(this).is(':visible')) { + checkedValue = $(this).val(); + } + }); + return checkedValue; +} \ No newline at end of file diff --git a/views/js/front/saferpay_saved_card.js b/views/js/front/saferpay_saved_card.js index 5eaea7a5..f4a29055 100755 --- a/views/js/front/saferpay_saved_card.js +++ b/views/js/front/saferpay_saved_card.js @@ -20,37 +20,12 @@ *@license SIX Payment Services */ -// $(document).ready(function () { -// var $savedCards = $("input[name^='saved_card_']"); -// $savedCards.on('change', function () { -// var $selectedCard = $(this); -// var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); -// $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); -// }); -// } -// ); -let formSubmitted = false; $(document).ready(function () { - $("#confirm_order").on('click', function () { - formSubmitted = true; - }); - - $(document).on('change', 'input[name^="saved_card_"]', function () { - - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - - if(!formSubmitted) { - $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); - } - }) -}); - -function getCheckedCardValue() { - var checkedValue = null; - $('input[name^="saved_card_"]:checked').each(function() { - if ($(this).is(':visible')) { - checkedValue = $(this).val(); - } - }); - return checkedValue; -} \ No newline at end of file + var $savedCards = $("input[name^='saved_card_']"); + $savedCards.on('change', function () { + var $selectedCard = $(this); + var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val(); + $("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val()); + }); + } +); \ No newline at end of file From 75b9fe485525a2156b1c3af4cfa845420c0d6311 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 10:03:14 +0300 Subject: [PATCH 07/67] thecheckout compatibility --- .../opc/thecheckout/hosted_fields_tch.js | 49 ++----------------- .../thecheckout/saferpay_saved_card_tch.js | 2 +- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index cace2d2f..383b2d02 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -35,53 +35,12 @@ $(document).ready(function () { return; } - if (saferpay_is_opc) { - $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { - handleOpcSubmit(e); - }); - } else { - $('[id="payment-form"]').on('submit', function (e) { - handleSubmit(e); - }); - } + $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { + handleOpcSubmit(e); + }); }); -function handleSubmit(event, selectedCardOpc) { - event.preventDefault(); - - var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); - - if (saferpay_is_opc) { - selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - selectedCard = selectedCardOpc; - } - - //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; - }, - }); -} - function getCheckedCardValue() { var checkedValue = null; $('input[name^="saved_card_"]:checked').each(function() { @@ -94,6 +53,8 @@ function getCheckedCardValue() { function handleOpcSubmit(event) { event.preventDefault(); + event.stopPropagation() + event.stopImmediatePropagation() var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js index 500b6d49..4aef5188 100644 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js @@ -29,7 +29,7 @@ $(document).ready(function () { $(document).on('change', 'input[name^="saved_card_"]', function () { var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - + console.log('tried to change') if(!formSubmitted) { $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); } From 8c580c49adaf2ed65c787b04ffbfae9436dbdf75 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 10:04:16 +0300 Subject: [PATCH 08/67] cleanup --- .../front/opc/thecheckout/saferpay_saved_card_tch.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js index 4aef5188..24d35af6 100644 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js @@ -20,19 +20,10 @@ *@license SIX Payment Services */ -let formSubmitted = false; $(document).ready(function () { - $("#confirm_order").on('click', function () { - formSubmitted = true; - }); - $(document).on('change', 'input[name^="saved_card_"]', function () { - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - console.log('tried to change') - if(!formSubmitted) { - $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); - } + $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); }) }); From e538a2b371661be0c867c48dcd0e3305c6fb8ff5 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 13:32:11 +0300 Subject: [PATCH 09/67] fix --- views/js/front/opc/thecheckout/hosted_fields_tch.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index 383b2d02..80209851 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -53,14 +53,15 @@ function getCheckedCardValue() { function handleOpcSubmit(event) { event.preventDefault(); - event.stopPropagation() - event.stopImmediatePropagation() var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + var hiddenInput = form.find("input[name='selectCreditCard_" + selectedCardMethod + "']"); + hiddenInput.val(selectedCard); if (selectedCard <= 0) { - form[0].submit(); + // form[0].submit(); + event.target.submit(); return; } From f84a99c28b0928d9c23dc0edb35ada2c22065b73 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 16:58:58 +0300 Subject: [PATCH 10/67] fix --- views/js/front/hosted-templates/hosted_fields.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index b7cc6af2..e571e6de 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -64,12 +64,7 @@ $(document).ready(function () { window.location = data.url; }, }); - } else { - $('[id="payment-form"]').on('submit', function (e) { - handleSubmit(e); - }); - } - + }); }); function handleSubmit(event, selectedCardOpc) { From 0cfc5ef1e7854cc9ccd6dc150370acfe215b1324 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 17:22:13 +0300 Subject: [PATCH 11/67] fix --- .../front/hosted-templates/hosted_fields.js | 30 ------------------- .../opc/thecheckout/hosted_fields_tch.js | 6 ++-- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index e571e6de..60d25b0a 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -39,7 +39,6 @@ $(document).ready(function () { 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. @@ -110,33 +109,4 @@ function getCheckedCardValue() { } }); return checkedValue; -} - -function handleOpcSubmit(event) { - event.preventDefault(); - - var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); - - if (selectedCard <= 0) { - form[0].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 diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index 80209851..5e67aa9e 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -35,7 +35,7 @@ $(document).ready(function () { return; } - $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { + $('body').on('submit', 'form.payment-form', function (e) { handleOpcSubmit(e); }); @@ -53,14 +53,16 @@ function getCheckedCardValue() { function handleOpcSubmit(event) { event.preventDefault(); + event.stopImmediatePropagation(); var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + var selectedCard = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + var hiddenInput = form.find("input[name='selectCreditCard_" + selectedCardMethod + "']"); hiddenInput.val(selectedCard); if (selectedCard <= 0) { - // form[0].submit(); event.target.submit(); return; From 81577a57aed67802c742d88aabf6f8cafffd3de8 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 17:23:45 +0300 Subject: [PATCH 12/67] revert --- .../front/hosted-templates/hosted_fields.js | 55 +------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index 60d25b0a..6bf1f957 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -20,17 +20,9 @@ *@license SIX Payment Services */ -let selectedCard = null; - $(document).ready(function () { var savedCardMethod = $('input[name="saved_card_method"]'); - $(document).on('change', 'input[name^="saved_card_"]', function() { - if (saferpay_is_opc) { - selectedCard = getCheckedCardValue(); - } - }); - if (!savedCardMethod.length && !saferpay_is_opc) { return; } @@ -64,49 +56,4 @@ $(document).ready(function () { }, }); }); -}); - -function handleSubmit(event, selectedCardOpc) { - event.preventDefault(); - - var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); - - if (saferpay_is_opc) { - selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - selectedCard = selectedCardOpc; - } - - //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; - }, - }); -} - -function getCheckedCardValue() { - var checkedValue = null; - $('input[name^="saved_card_"]:checked').each(function() { - if ($(this).is(':visible')) { - checkedValue = $(this).val(); - } - }); - return checkedValue; -} \ No newline at end of file +}); \ No newline at end of file From 2aa3a908f4701fe0579ff39eab606d92470d8a3d Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 17:24:20 +0300 Subject: [PATCH 13/67] revert --- views/js/front/hosted-templates/hosted_fields.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index 6bf1f957..e49d7019 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -23,7 +23,7 @@ $(document).ready(function () { var savedCardMethod = $('input[name="saved_card_method"]'); - if (!savedCardMethod.length && !saferpay_is_opc) { + if (!savedCardMethod.length) { return; } @@ -31,6 +31,7 @@ $(document).ready(function () { 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. From 9d09e529a62ecac22db87ac88456c289f48ca6ca Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 17:39:58 +0300 Subject: [PATCH 14/67] full compatibility --- .../opc/thecheckout/hosted_fields_tch.js | 32 +++++-------------- .../thecheckout/saferpay_saved_card_tch.js | 1 + 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index 5e67aa9e..f46cf2d9 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -23,13 +23,7 @@ let selectedCard = null; $(document).ready(function () { - var savedCardMethod = $('input[name="saved_card_method"]'); - - $(document).on('change', 'input[name^="saved_card_"]', function() { - if (saferpay_is_opc) { - selectedCard = getCheckedCardValue(); - } - }); + let savedCardMethod = $('input[name="saved_card_method"]'); if (!savedCardMethod.length && !saferpay_is_opc) { return; @@ -41,28 +35,18 @@ $(document).ready(function () { }); -function getCheckedCardValue() { - var checkedValue = null; - $('input[name^="saved_card_"]:checked').each(function() { - if ($(this).is(':visible')) { - checkedValue = $(this).val(); - } - }); - return checkedValue; -} - function handleOpcSubmit(event) { event.preventDefault(); - event.stopImmediatePropagation(); - var selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - var selectedCard = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); - var form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + let currentCard = parseInt(sessionStorage.getItem('selectedCard')); + let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + let selectedCard = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); + let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); + let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); - var hiddenInput = form.find("input[name='selectCreditCard_" + selectedCardMethod + "']"); - hiddenInput.val(selectedCard); + hiddenInput.val(currentCard); - if (selectedCard <= 0) { + if (parseInt(hiddenInput.val()) <= 0) { event.target.submit(); return; diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js index 24d35af6..501fbac7 100644 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js @@ -24,6 +24,7 @@ $(document).ready(function () { $(document).on('change', 'input[name^="saved_card_"]', function () { var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); + sessionStorage.setItem('selectedCard', getCheckedCardValue()); }) }); From 616e150b3f6c1e3215c58c7fdf5811f363e2d2c8 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 18:04:23 +0300 Subject: [PATCH 15/67] fix js --- .../opc/thecheckout/hosted_fields_tch.js | 23 +++++++++++++++---- .../thecheckout/saferpay_saved_card_tch.js | 15 +----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index f46cf2d9..7cd6d5a4 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -22,6 +22,12 @@ let selectedCard = null; +$(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + updateCheckedCardValue(); + $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); +}) + $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); @@ -38,15 +44,14 @@ $(document).ready(function () { function handleOpcSubmit(event) { event.preventDefault(); - let currentCard = parseInt(sessionStorage.getItem('selectedCard')); let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - let selectedCard = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); - hiddenInput.val(currentCard); + hiddenInput.val(selectedCard); - if (parseInt(hiddenInput.val()) <= 0) { + // NOTE: not saved card chosen, continuing with normal procedures. + if (parseInt(selectedCard) <= 0) { event.target.submit(); return; @@ -57,7 +62,7 @@ function handleOpcSubmit(event) { data: { action: 'submitHostedFields', paymentMethod: selectedCardMethod, - selectedCard: selectedCard, + selectedCard: parseInt(selectedCard), isBusinessLicence: 1, ajax: 1 }, @@ -67,4 +72,12 @@ function handleOpcSubmit(event) { window.location = data.url; }, }); +} + +function updateCheckedCardValue() { + $('input[name^="saved_card_"]:checked').each(function() { + if ($(this).is(':visible')) { + selectedCard = $(this).val(); + } + }); } \ No newline at end of file diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js index 501fbac7..9302bf6b 100644 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js @@ -21,19 +21,6 @@ */ $(document).ready(function () { - $(document).on('change', 'input[name^="saved_card_"]', function () { - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - $("input[name='selectedCreditCard_" + method + "']").val(getCheckedCardValue()); - sessionStorage.setItem('selectedCard', getCheckedCardValue()); - }) + }); -function getCheckedCardValue() { - var checkedValue = null; - $('input[name^="saved_card_"]:checked').each(function() { - if ($(this).is(':visible')) { - checkedValue = $(this).val(); - } - }); - return checkedValue; -} \ No newline at end of file From 1d643dc8538e1847c5eda43ea1bdf0835fbef466 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 10 Oct 2024 18:08:29 +0300 Subject: [PATCH 16/67] fix --- views/js/front/opc/thecheckout/hosted_fields_tch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index 7cd6d5a4..f51faf8d 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -35,13 +35,13 @@ $(document).ready(function () { return; } - $('body').on('submit', 'form.payment-form', function (e) { - handleOpcSubmit(e); + $('body').on('submit', 'form.payment-form', function (event) { + handleSubmit(event); }); }); -function handleOpcSubmit(event) { +function handleSubmit(event) { event.preventDefault(); let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); From 759761d91ec9c1b59a01fd81b2d7255bebd0e550 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 09:23:22 +0300 Subject: [PATCH 17/67] fix --- saferpayofficial.php | 6 +----- views/js/front/opc/thecheckout/hosted_fields_tch.js | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 660c3035..9d7a2ce5 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -359,11 +359,6 @@ public function hookActionFrontControllerSetMedia() $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_tch.css'); if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $this->context->controller->registerJavascript( - 'saved-card', - 'modules/' . $this->name . '/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js' - ); - $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); } else { $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); @@ -372,6 +367,7 @@ public function hookActionFrontControllerSetMedia() $configSuffix = \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix(); $this->context->controller->addJs(Configuration::get($fieldsLibrary . $configSuffix)); } + break; } diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields_tch.js index f51faf8d..c4b94c14 100644 --- a/views/js/front/opc/thecheckout/hosted_fields_tch.js +++ b/views/js/front/opc/thecheckout/hosted_fields_tch.js @@ -51,7 +51,7 @@ function handleSubmit(event) { hiddenInput.val(selectedCard); // NOTE: not saved card chosen, continuing with normal procedures. - if (parseInt(selectedCard) <= 0) { + if (parseInt(selectedCard) <= 0 || selectedCard === null || selectedCard === undefined) { event.target.submit(); return; From 23f292d5323395da3751f714c20204d222bea60c Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 09:35:46 +0300 Subject: [PATCH 18/67] removed JS --- .../thecheckout/saferpay_saved_card_tch.js | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_tch.js diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js deleted file mode 100644 index 9302bf6b..00000000 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_tch.js +++ /dev/null @@ -1,26 +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 () { - -}); - From 85da886ef00900ff48efec5d201075c8476963c9 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 09:51:00 +0300 Subject: [PATCH 19/67] load only in checkout --- src/Config/SaferPayConfig.php | 2 ++ src/Presentation/Loader/PaymentFormAssetLoader.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 89d5f0f5..5b2788e4 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -278,6 +278,8 @@ class SaferPayConfig const THE_CHECKOUT_MODULE = 'thecheckout'; const SUPER_CHECKOUT_MODULE = 'supercheckout'; + const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; + const OPC_MODULE_LIST = [ 'onepagecheckoutps', 'thecheckout', diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 033ea5e4..33e50415 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -54,8 +54,9 @@ public function register($controller) { /** @var ValidateOpcModuleCompatibilityAction $opcValidator */ $opcValidator = $this->module->getService(ValidateOpcModuleCompatibilityAction::class); + $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; - if ($opcValidator->run()) { + if ($opcValidator->run() && $inOpcCheckout) { Media::addJsDef([ 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), 'saferpay_payment_types' => [ From d507b9beca0563739fbb6f4d0c538f130127ead9 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 10:43:12 +0300 Subject: [PATCH 20/67] css n js --- saferpayofficial.php | 4 +- .../Loader/PaymentFormAssetLoader.php | 8 +- .../opc/thecheckout/saferpay_checkout_16.css | 32 ++++++++ .../{ => opc/thecheckout}/saferpay_tch.css | 0 ...{hosted_fields_tch.js => hosted_fields.js} | 0 .../front/opc/thecheckout/hosted_fields_16.js | 75 +++++++++++++++++++ .../opc/thecheckout/hosted_fields_16_tch.js | 0 .../opc/thecheckout/saferpay_saved_card_16.js | 31 ++++++++ .../thecheckout/saferpay_saved_card_16_tch.js | 0 9 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 views/css/front/opc/thecheckout/saferpay_checkout_16.css rename views/css/front/{ => opc/thecheckout}/saferpay_tch.css (100%) rename views/js/front/opc/thecheckout/{hosted_fields_tch.js => hosted_fields.js} (100%) create mode 100644 views/js/front/opc/thecheckout/hosted_fields_16.js delete mode 100644 views/js/front/opc/thecheckout/hosted_fields_16_tch.js create mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_16.js delete mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js diff --git a/saferpayofficial.php b/saferpayofficial.php index 9d7a2ce5..c5681ea8 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -361,8 +361,8 @@ public function hookActionFrontControllerSetMedia() 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/saferpay_checkout_16.css"); - $this->context->controller->addJS("{$this->getPathUri()}views/js/front/saferpay_saved_card_16.js"); + $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)); diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 33e50415..8a8640fc 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -132,23 +132,23 @@ private function registerTheCheckoutAssets($controller) if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_tch.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields.js" ); } else { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16_tch.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16.js" ); } } else { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields_tch.js', + $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields.js', false ); } else { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16_tch.js', + $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16.js', false ); } diff --git a/views/css/front/opc/thecheckout/saferpay_checkout_16.css b/views/css/front/opc/thecheckout/saferpay_checkout_16.css new file mode 100644 index 00000000..34975f75 --- /dev/null +++ b/views/css/front/opc/thecheckout/saferpay_checkout_16.css @@ -0,0 +1,32 @@ +/** + *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 + */ +.payment_module a.saferpay_method { + padding-left: 10px; +} + +.saved_credit_cards { + padding-bottom: 10px; +} + +.saferpay_method img { + height: 24px; +} diff --git a/views/css/front/saferpay_tch.css b/views/css/front/opc/thecheckout/saferpay_tch.css similarity index 100% rename from views/css/front/saferpay_tch.css rename to views/css/front/opc/thecheckout/saferpay_tch.css diff --git a/views/js/front/opc/thecheckout/hosted_fields_tch.js b/views/js/front/opc/thecheckout/hosted_fields.js similarity index 100% rename from views/js/front/opc/thecheckout/hosted_fields_tch.js rename to views/js/front/opc/thecheckout/hosted_fields.js diff --git a/views/js/front/opc/thecheckout/hosted_fields_16.js b/views/js/front/opc/thecheckout/hosted_fields_16.js new file mode 100644 index 00000000..1c47b06d --- /dev/null +++ b/views/js/front/opc/thecheckout/hosted_fields_16.js @@ -0,0 +1,75 @@ +/** + *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 () { + var savedCardMethod = $('input[name="saved_card_method"]'); + + if (!savedCardMethod.length) { + return; + } + + $('[id="payment-form"]').on('submit', function (event) { + event.preventDefault(); + + var paymentType = $(this).find("[name=saferpayPaymentType]").val(); + + //NOTE: if it's not a hosted iframe then we don't need to submitHostedFields. + if (paymentType !== saferpay_payment_types.hosted_iframe) { + event.target.submit(); + + return; + } + + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); + + var selectedCard = 0; + + $(this).find("[name=saved_card_" + selectedCardMethod + "]").each(function () { + if ($(this).is(':checked')) { + selectedCard = $(this).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 diff --git a/views/js/front/opc/thecheckout/hosted_fields_16_tch.js b/views/js/front/opc/thecheckout/hosted_fields_16_tch.js deleted file mode 100644 index e69de29b..00000000 diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_16.js b/views/js/front/opc/thecheckout/saferpay_saved_card_16.js new file mode 100644 index 00000000..184c35eb --- /dev/null +++ b/views/js/front/opc/thecheckout/saferpay_saved_card_16.js @@ -0,0 +1,31 @@ +/** + *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 () { + $('.saferpay_method.js_credit_card').on('click', function () { + event.preventDefault(); + var method = $(this).attr('data-saferpay-method'); + $('.saferpay_additional_info').hide(); + var $additionalInfo = $('.saferpay_additional_info.' + method); + $additionalInfo.show(); + }) +}); \ No newline at end of file diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js b/views/js/front/opc/thecheckout/saferpay_saved_card_16_tch.js deleted file mode 100644 index e69de29b..00000000 From 9875c3a406531fc1bf55b659e7f1c4090a88ba55 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:48:44 +0300 Subject: [PATCH 21/67] fixed bug --- views/js/front/opc/thecheckout/hosted_fields.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index c4b94c14..1cdbd612 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -48,6 +48,10 @@ function handleSubmit(event) { let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); + if (selectedCard === null) { + selectedCard = hiddenInput.val(); + } + hiddenInput.val(selectedCard); // NOTE: not saved card chosen, continuing with normal procedures. From 00b6fb0bc6166f2cddd8f514d19fa9fb1ed8bb70 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:50:20 +0300 Subject: [PATCH 22/67] reusability --- src/Config/SaferPayConfig.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 5b2788e4..877a3370 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -281,9 +281,9 @@ class SaferPayConfig const THE_CHECKOUT_FRONT_CONTROLLER = 'TheCheckoutModuleFrontController'; const OPC_MODULE_LIST = [ - 'onepagecheckoutps', - 'thecheckout', - 'supercheckout', + self::ONE_PAGE_CHECKOUT_MODULE, + self::THE_CHECKOUT_MODULE, + self::SUPER_CHECKOUT_MODULE, ]; public static function supportsOrderCapture($paymentMethod) From 7cb7d7e163d468f6966a13a70415b1031f4e99da Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:50:51 +0300 Subject: [PATCH 23/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 8a8640fc..214a60ab 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -54,6 +54,7 @@ public function register($controller) { /** @var ValidateOpcModuleCompatibilityAction $opcValidator */ $opcValidator = $this->module->getService(ValidateOpcModuleCompatibilityAction::class); + $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; if ($opcValidator->run() && $inOpcCheckout) { From 9d91a0b22f2f10d2f764304390e9ceb1f85c0b1a Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:51:13 +0300 Subject: [PATCH 24/67] fix --- views/js/front/opc/thecheckout/hosted_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index 1cdbd612..4fa8c1c7 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -31,7 +31,7 @@ $(document).on('change', 'input[name^="saved_card_"]', function () { $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); - if (!savedCardMethod.length && !saferpay_is_opc) { + if (!savedCardMethod.length) { return; } From baa923bb673cead834201c3c5a58931f9b8fdf52 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:52:54 +0300 Subject: [PATCH 25/67] fix --- views/js/front/opc/thecheckout/hosted_fields.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index 4fa8c1c7..ea230573 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -48,6 +48,11 @@ function handleSubmit(event) { let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); + /** + * NOTE: + * when user just press payment method + * but not touched what to do with card + */ if (selectedCard === null) { selectedCard = hiddenInput.val(); } From b18be4493f68ac1809f9ecd5f92f28898142dd2c Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 11 Oct 2024 13:54:01 +0300 Subject: [PATCH 26/67] comment --- views/js/front/opc/thecheckout/hosted_fields.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index ea230573..ea2a349d 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -48,7 +48,7 @@ function handleSubmit(event) { let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); - /** + /* * NOTE: * when user just press payment method * but not touched what to do with card @@ -59,7 +59,10 @@ function handleSubmit(event) { hiddenInput.val(selectedCard); - // NOTE: not saved card chosen, continuing with normal procedures. + /* + * NOTE: + * not saved card chosen, continuing with normal procedures. + */ if (parseInt(selectedCard) <= 0 || selectedCard === null || selectedCard === undefined) { event.target.submit(); From 582da6fab356d072dd677be1a6e574f28d5c19a9 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sun, 13 Oct 2024 10:40:00 +0300 Subject: [PATCH 27/67] license --- .../ValidateOpcModuleCompatibilityAction.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Action/ValidateOpcModuleCompatibilityAction.php b/src/Action/ValidateOpcModuleCompatibilityAction.php index 7935b864..6e44d6bf 100644 --- a/src/Action/ValidateOpcModuleCompatibilityAction.php +++ b/src/Action/ValidateOpcModuleCompatibilityAction.php @@ -1,4 +1,25 @@ + *@copyright SIX Payment Services + *@license SIX Payment Services + */ namespace Invertus\SaferPay\Action; From ed9256c8f145570fdb8e95469bb54d8b0874999b Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sun, 13 Oct 2024 10:53:51 +0300 Subject: [PATCH 28/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 214a60ab..382c599b 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -43,21 +43,21 @@ class PaymentFormAssetLoader private $module; /** @var LegacyContext */ private $context; + /** @var ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility */ + private $validateOpcModuleCompatibility; - public function __construct(ModuleFactory $module, LegacyContext $context) + public function __construct(ModuleFactory $module, LegacyContext $context, ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility) { $this->module = $module->getModule(); $this->context = $context; + $this->validateOpcModuleCompatibility = $validateOpcModuleCompatibility; } public function register($controller) { - /** @var ValidateOpcModuleCompatibilityAction $opcValidator */ - $opcValidator = $this->module->getService(ValidateOpcModuleCompatibilityAction::class); - $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; - if ($opcValidator->run() && $inOpcCheckout) { + if ($this->validateOpcModuleCompatibility->run() && $inOpcCheckout) { Media::addJsDef([ 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), 'saferpay_payment_types' => [ From 59cc882084bb999b54c0a8c35457a9a88c9eeed1 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Sun, 13 Oct 2024 11:49:43 +0300 Subject: [PATCH 29/67] fix --- .../Loader/PaymentFormAssetLoader.php | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 382c599b..d1cac229 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -57,18 +57,18 @@ public function register($controller) { $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; + Media::addJsDef([ + 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), + 'saferpay_payment_types' => [ + 'hosted_iframe' => PaymentType::HOSTED_IFRAME, + 'iframe' => PaymentType::IFRAME, + 'basic' => PaymentType::BASIC, + ], + ]); + if ($this->validateOpcModuleCompatibility->run() && $inOpcCheckout) { - Media::addJsDef([ - 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), - 'saferpay_payment_types' => [ - 'hosted_iframe' => PaymentType::HOSTED_IFRAME, - 'iframe' => PaymentType::IFRAME, - 'basic' => PaymentType::BASIC, - ], - 'saferpay_is_opc' => $opcValidator->run(), - ]); - $opcModule = $opcValidator->getEnabledOpcModule(); + $opcModule = $this->validateOpcModuleCompatibility->getEnabledOpcModule(); switch ($opcModule) { case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: $this->registerOnePageCheckoutAssets($controller); @@ -86,15 +86,6 @@ public function register($controller) return; } - Media::addJsDef([ - 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), - 'saferpay_payment_types' => [ - 'hosted_iframe' => PaymentType::HOSTED_IFRAME, - 'iframe' => PaymentType::IFRAME, - 'basic' => PaymentType::BASIC, - ], - ]); - if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( From d5b2d42e54624a93ede375b1c8aa4536fb8b05c4 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 09:16:54 +0300 Subject: [PATCH 30/67] fix --- saferpayofficial.php | 10 +++++---- .../ValidateOpcModuleCompatibilityAction.php | 21 ++++--------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index c5681ea8..1a8fd59a 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -347,14 +347,16 @@ public function hookActionFrontControllerSetMedia() /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); - /** @var \Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction $opcValidator */ - $opcValidator = $this->getService(\Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction::class); + /** @var \Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility */ + $validateOpcModuleCompatibility = $this->getService(\Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction::class); $paymentFormAssetsLoader->register($this->context->controller); - if ($opcValidator->run()) { + $opcModules = $validateOpcModuleCompatibility->run(); - switch ($opcValidator->getEnabledOpcModule()) { + if ($opcModules) { + + switch ($opcModules) { case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_tch.css'); diff --git a/src/Action/ValidateOpcModuleCompatibilityAction.php b/src/Action/ValidateOpcModuleCompatibilityAction.php index 6e44d6bf..a4f727e9 100644 --- a/src/Action/ValidateOpcModuleCompatibilityAction.php +++ b/src/Action/ValidateOpcModuleCompatibilityAction.php @@ -28,30 +28,17 @@ class ValidateOpcModuleCompatibilityAction { + /** + * @return false|string + */ public function run() { foreach (SaferPayConfig::OPC_MODULE_LIST as $opcModule){ if (Module::isInstalled($opcModule) && Module::isEnabled($opcModule)) { - return true; - } - } - - return false; - } - - /** - * Get only first enabled OPC module - * - * @return string - */ - public function getEnabledOpcModule() - { - foreach (SaferPayConfig::OPC_MODULE_LIST as $opcModule) { - if (Module::isEnabled($opcModule)) { return $opcModule; } } - return ''; + return false; } } \ No newline at end of file From ff26d2e48bc48e7101843436db5166c6fd86362a Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 09:18:11 +0300 Subject: [PATCH 31/67] fix --- views/js/front/opc/thecheckout/hosted_fields.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index ea2a349d..0b586cb7 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -22,12 +22,6 @@ let selectedCard = null; -$(document).on('change', 'input[name^="saved_card_"]', function () { - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - updateCheckedCardValue(); - $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); -}) - $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); @@ -41,6 +35,12 @@ $(document).ready(function () { }); +$(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + updateCheckedCardValue(); + $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); +}) + function handleSubmit(event) { event.preventDefault(); From 0425e663a74735a13833310fea4631462eee847f Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 09:19:08 +0300 Subject: [PATCH 32/67] fix var --- views/js/front/opc/thecheckout/hosted_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index 0b586cb7..2d6852c3 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -20,7 +20,7 @@ *@license SIX Payment Services */ -let selectedCard = null; +var selectedCard = null; $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); From c4eb3becf3398e1157ec2643ba1b6bf8b1c76d2a Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:10:31 +0300 Subject: [PATCH 33/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index d1cac229..4940ee23 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -66,9 +66,10 @@ public function register($controller) ], ]); - if ($this->validateOpcModuleCompatibility->run() && $inOpcCheckout) { + $opcModule = $this->validateOpcModuleCompatibility->run(); + + if ($opcModule && $inOpcCheckout) { - $opcModule = $this->validateOpcModuleCompatibility->getEnabledOpcModule(); switch ($opcModule) { case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: $this->registerOnePageCheckoutAssets($controller); From 9bd99a6d9397fa395c127612ff122fa7de4b3a2c Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:15:51 +0300 Subject: [PATCH 34/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 4940ee23..925ebd9e 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -55,8 +55,6 @@ public function __construct(ModuleFactory $module, LegacyContext $context, Valid public function register($controller) { - $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; - Media::addJsDef([ 'saferpay_official_ajax_url' => $this->context->getLink()->getModuleLink('saferpayofficial', ControllerName::AJAX), 'saferpay_payment_types' => [ @@ -66,6 +64,8 @@ public function register($controller) ], ]); + $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; + $opcModule = $this->validateOpcModuleCompatibility->run(); if ($opcModule && $inOpcCheckout) { From d8a70d05bbf4bb8abb36e03f3a6bbc3e2114754e Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:18:43 +0300 Subject: [PATCH 35/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 925ebd9e..6de5ce9d 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -68,7 +68,14 @@ public function register($controller) $opcModule = $this->validateOpcModuleCompatibility->run(); - if ($opcModule && $inOpcCheckout) { + if ( + !$controller instanceof OrderControllerCore + || !$inOpcCheckout + ) { + return; + } + + if ($inOpcCheckout) { switch ($opcModule) { case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: @@ -83,10 +90,6 @@ public function register($controller) } } - if (!$controller instanceof OrderControllerCore) { - return; - } - if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( From 7bb55570ee8d9464fb8a9500169eacce794de4fc Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:18:57 +0300 Subject: [PATCH 36/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 6de5ce9d..aec8751e 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -76,7 +76,6 @@ public function register($controller) } if ($inOpcCheckout) { - switch ($opcModule) { case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: $this->registerOnePageCheckoutAssets($controller); From 13292ae4fc848cea325ab5818b1d478051479001 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:46:13 +0300 Subject: [PATCH 37/67] fix --- .../Loader/PaymentFormAssetLoader.php | 6 +++++- .../js/front/opc/thecheckout/hosted_fields.js | 19 +++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index aec8751e..01d9fb8c 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -70,7 +70,7 @@ public function register($controller) if ( !$controller instanceof OrderControllerCore - || !$inOpcCheckout + && !$inOpcCheckout ) { return; } @@ -89,6 +89,10 @@ public function register($controller) } } + if (!$controller instanceof OrderControllerCore) { + return; + } + if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index 2d6852c3..ff9a90b4 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -22,24 +22,23 @@ var selectedCard = null; +$(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + updateCheckedCardValue(); + $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); +}); + $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); if (!savedCardMethod.length) { return; } - - $('body').on('submit', 'form.payment-form', function (event) { - handleSubmit(event); - }); - }); -$(document).on('change', 'input[name^="saved_card_"]', function () { - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - updateCheckedCardValue(); - $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); -}) +$('body').on('submit', 'form.payment-form', function (e) { + handleSubmit(e); +}); function handleSubmit(event) { event.preventDefault(); From 3683d20240a315490f09ff1280527e98f2ad469a Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:48:32 +0300 Subject: [PATCH 38/67] fix --- saferpayofficial.php | 1 - 1 file changed, 1 deletion(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 1a8fd59a..b3507e91 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -355,7 +355,6 @@ public function hookActionFrontControllerSetMedia() $opcModules = $validateOpcModuleCompatibility->run(); if ($opcModules) { - switch ($opcModules) { case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_tch.css'); From 1af6c97fb31bab18078180deb1f3f2a8a1661447 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:51:03 +0300 Subject: [PATCH 39/67] fix css --- saferpayofficial.php | 2 +- .../front/opc/thecheckout/{saferpay_tch.css => saferpay.css} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename views/css/front/opc/thecheckout/{saferpay_tch.css => saferpay.css} (100%) diff --git a/saferpayofficial.php b/saferpayofficial.php index b3507e91..ae2d77b1 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -357,7 +357,7 @@ public function hookActionFrontControllerSetMedia() if ($opcModules) { switch ($opcModules) { case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: - $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/saferpay_tch.css'); + $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/opc/thecheckout/saferpay.css'); if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); diff --git a/views/css/front/opc/thecheckout/saferpay_tch.css b/views/css/front/opc/thecheckout/saferpay.css similarity index 100% rename from views/css/front/opc/thecheckout/saferpay_tch.css rename to views/css/front/opc/thecheckout/saferpay.css From 264a526f3f5a0a86627589ec459c0e1d7012ca80 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 10:51:44 +0300 Subject: [PATCH 40/67] fix --- views/css/front/opc/thecheckout/saferpay.css | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/views/css/front/opc/thecheckout/saferpay.css b/views/css/front/opc/thecheckout/saferpay.css index c2b71608..4a0a9993 100644 --- a/views/css/front/opc/thecheckout/saferpay.css +++ b/views/css/front/opc/thecheckout/saferpay.css @@ -1,3 +1,25 @@ +/** + *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 + */ + .payment-logo { max-width: 40px; } \ No newline at end of file From fff2742e3bc350863b2a25d9861fdee0be87ee58 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 14 Oct 2024 11:18:18 +0300 Subject: [PATCH 41/67] 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 48bd536b5fad4c18b011b6342ed61bc67d2f20da Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 15 Oct 2024 12:25:31 +0300 Subject: [PATCH 42/67] fix --- saferpayofficial.php | 6 +- .../Loader/PaymentFormAssetLoader.php | 59 +++++++++---------- .../OpcModulesProvider.php} | 13 ++-- 3 files changed, 38 insertions(+), 40 deletions(-) rename src/{Action/ValidateOpcModuleCompatibilityAction.php => Provider/OpcModulesProvider.php} (80%) diff --git a/saferpayofficial.php b/saferpayofficial.php index ae2d77b1..c8f4c121 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -347,12 +347,12 @@ public function hookActionFrontControllerSetMedia() /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); - /** @var \Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility */ - $validateOpcModuleCompatibility = $this->getService(\Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction::class); + /** @var \Invertus\SaferPay\Provider\OpcModulesProvider $opcModulesProvider */ + $opcModulesProvider = $this->getService(\Invertus\SaferPay\Provider\OpcModulesProvider::class); $paymentFormAssetsLoader->register($this->context->controller); - $opcModules = $validateOpcModuleCompatibility->run(); + $opcModules = $opcModulesProvider->get(); if ($opcModules) { switch ($opcModules) { diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 01d9fb8c..4f6f0884 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -29,6 +29,7 @@ use Invertus\SaferPay\Enum\ControllerName; use Invertus\SaferPay\Enum\PaymentType; use Invertus\SaferPay\Factory\ModuleFactory; +use Invertus\SaferPay\Provider\OpcModulesProvider; use Media; use OrderControllerCore; use SaferPayOfficial; @@ -43,14 +44,14 @@ class PaymentFormAssetLoader private $module; /** @var LegacyContext */ private $context; - /** @var ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility */ - private $validateOpcModuleCompatibility; + /** @var OpcModulesProvider $opcModuleProvider */ + private $opcModulesProvider; - public function __construct(ModuleFactory $module, LegacyContext $context, ValidateOpcModuleCompatibilityAction $validateOpcModuleCompatibility) + public function __construct(ModuleFactory $module, LegacyContext $context, OpcModulesProvider $opcModulesProvider) { $this->module = $module->getModule(); $this->context = $context; - $this->validateOpcModuleCompatibility = $validateOpcModuleCompatibility; + $this->opcModulesProvider = $opcModulesProvider; } public function register($controller) @@ -66,14 +67,7 @@ public function register($controller) $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; - $opcModule = $this->validateOpcModuleCompatibility->run(); - - if ( - !$controller instanceof OrderControllerCore - && !$inOpcCheckout - ) { - return; - } + $opcModule = $this->opcModulesProvider->get(); if ($inOpcCheckout) { switch ($opcModule) { @@ -88,74 +82,79 @@ public function register($controller) break; } } + + $this->registerDefaultCheckoutAssets($controller); + } - if (!$controller instanceof OrderControllerCore) { - return; - } + private function registerOnePageCheckoutAssets($controller) + { + // + } + private function registerTheCheckoutAssets($controller) + { if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields.js" ); } else { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16.js" ); } } else { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', + $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields.js', false ); } else { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', + $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16.js', false ); } } } - private function registerOnePageCheckoutAssets($controller) + private function registerSuperCheckoutAssets($controller) { // } - private function registerTheCheckoutAssets($controller) + private function registerDefaultCheckoutAssets($controller) { + if (!$controller instanceof OrderControllerCore) { + return; + } + if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields.js" + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" ); } else { $controller->registerJavascript( 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16.js" + "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" ); } } else { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields.js', + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields.js', false ); } else { $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16.js', + $this->module->getPathUri() . 'views/js/front/hosted-templates/hosted_fields_16.js', false ); } } } - - private function registerSuperCheckoutAssets($controller) - { - // - } } diff --git a/src/Action/ValidateOpcModuleCompatibilityAction.php b/src/Provider/OpcModulesProvider.php similarity index 80% rename from src/Action/ValidateOpcModuleCompatibilityAction.php rename to src/Provider/OpcModulesProvider.php index a4f727e9..ab6e2b0c 100644 --- a/src/Action/ValidateOpcModuleCompatibilityAction.php +++ b/src/Provider/OpcModulesProvider.php @@ -21,24 +21,23 @@ *@license SIX Payment Services */ -namespace Invertus\SaferPay\Action; +namespace Invertus\SaferPay\Provider; use Invertus\SaferPay\Config\SaferPayConfig; -use Module; -class ValidateOpcModuleCompatibilityAction +class OpcModulesProvider { /** - * @return false|string + * @return string */ - public function run() + public function get() { foreach (SaferPayConfig::OPC_MODULE_LIST as $opcModule){ - if (Module::isInstalled($opcModule) && Module::isEnabled($opcModule)) { + if (\Module::isInstalled($opcModule) && \Module::isEnabled($opcModule)) { return $opcModule; } } - return false; + return ''; } } \ No newline at end of file From 096f5dce37343790ad626a5b5329970bf22774cf Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 15 Oct 2024 12:26:12 +0300 Subject: [PATCH 43/67] fix --- .../Loader/PaymentFormAssetLoader.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 4f6f0884..4348529e 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -69,18 +69,16 @@ public function register($controller) $opcModule = $this->opcModulesProvider->get(); - if ($inOpcCheckout) { - switch ($opcModule) { - case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: - $this->registerOnePageCheckoutAssets($controller); - break; - case SaferPayConfig::THE_CHECKOUT_MODULE: - $this->registerTheCheckoutAssets($controller); - break; - case SaferPayConfig::SUPER_CHECKOUT_MODULE: - $this->registerSuperCheckoutAssets($controller); - break; - } + switch ($opcModule) { + case SaferPayConfig::ONE_PAGE_CHECKOUT_MODULE: + $this->registerOnePageCheckoutAssets($controller); + break; + case SaferPayConfig::THE_CHECKOUT_MODULE: + $this->registerTheCheckoutAssets($controller); + break; + case SaferPayConfig::SUPER_CHECKOUT_MODULE: + $this->registerSuperCheckoutAssets($controller); + break; } $this->registerDefaultCheckoutAssets($controller); From f0a226052ce9361f610c1fc9d8fa7a26af05e355 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 15 Oct 2024 12:26:42 +0300 Subject: [PATCH 44/67] update --- src/Presentation/Loader/PaymentFormAssetLoader.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 4348529e..941b968c 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -65,8 +65,6 @@ public function register($controller) ], ]); - $inOpcCheckout = get_class($controller) === SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER; - $opcModule = $this->opcModulesProvider->get(); switch ($opcModule) { From 9449f0a2a88170da044f606b80da7c9a4344c1bc Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 15 Oct 2024 12:28:31 +0300 Subject: [PATCH 45/67] comments --- saferpayofficial.php | 38 +++++++++---------- .../Loader/PaymentFormAssetLoader.php | 4 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index c8f4c121..79fce9ef 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -354,29 +354,27 @@ public function hookActionFrontControllerSetMedia() $opcModules = $opcModulesProvider->get(); - if ($opcModules) { - switch ($opcModules) { - case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: - $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/opc/thecheckout/saferpay.css'); - - 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; - } + switch ($opcModules) { + case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: + $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/opc/thecheckout/saferpay.css'); - /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ - $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); - $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); + 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; } + /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ + $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); + $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); + if ($this->context->controller instanceof OrderController) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $this->context->controller->registerJavascript( diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 941b968c..9fa88234 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) { - // + // TODO: will be implemented in other branches } private function registerTheCheckoutAssets($controller) @@ -118,7 +118,7 @@ private function registerTheCheckoutAssets($controller) private function registerSuperCheckoutAssets($controller) { - // + // TODO: will be implemented in other branches } private function registerDefaultCheckoutAssets($controller) From 6a66534765b0381c0f402cc498235b7938a3e042 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Tue, 15 Oct 2024 12:35:25 +0300 Subject: [PATCH 46/67] fix --- saferpayofficial.php | 2 -- views/css/front/opc/thecheckout/saferpay.css | 25 --------------- .../opc/thecheckout/saferpay_checkout_16.css | 32 ------------------- views/css/front/saferpay_checkout.css | 8 +++++ 4 files changed, 8 insertions(+), 59 deletions(-) delete mode 100644 views/css/front/opc/thecheckout/saferpay.css delete mode 100644 views/css/front/opc/thecheckout/saferpay_checkout_16.css diff --git a/saferpayofficial.php b/saferpayofficial.php index 79fce9ef..27d5c9ad 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -356,8 +356,6 @@ public function hookActionFrontControllerSetMedia() switch ($opcModules) { case \Invertus\SaferPay\Config\SaferPayConfig::THE_CHECKOUT_MODULE: - $this->context->controller->addCSS($this->getPathUri() . 'views/css/front/opc/thecheckout/saferpay.css'); - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); } else { diff --git a/views/css/front/opc/thecheckout/saferpay.css b/views/css/front/opc/thecheckout/saferpay.css deleted file mode 100644 index 4a0a9993..00000000 --- a/views/css/front/opc/thecheckout/saferpay.css +++ /dev/null @@ -1,25 +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 - */ - -.payment-logo { - max-width: 40px; -} \ No newline at end of file diff --git a/views/css/front/opc/thecheckout/saferpay_checkout_16.css b/views/css/front/opc/thecheckout/saferpay_checkout_16.css deleted file mode 100644 index 34975f75..00000000 --- a/views/css/front/opc/thecheckout/saferpay_checkout_16.css +++ /dev/null @@ -1,32 +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 - */ -.payment_module a.saferpay_method { - padding-left: 10px; -} - -.saved_credit_cards { - padding-bottom: 10px; -} - -.saferpay_method img { - height: 24px; -} diff --git a/views/css/front/saferpay_checkout.css b/views/css/front/saferpay_checkout.css index 7a88f011..f98495b3 100755 --- a/views/css/front/saferpay_checkout.css +++ b/views/css/front/saferpay_checkout.css @@ -26,3 +26,11 @@ .payment-option img { height: 24px; } + +.payment-logo { + max-width: 40px; +} + +.payment-logo { + max-width: 40px; +} From 587280a86400a943e69a73fc8db77227c43803d1 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 09:37:56 +0300 Subject: [PATCH 47/67] unused use statement --- src/Presentation/Loader/PaymentFormAssetLoader.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 9fa88234..3a52d13d 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -23,7 +23,6 @@ namespace Invertus\SaferPay\Presentation\Loader; -use Invertus\SaferPay\Action\ValidateOpcModuleCompatibilityAction; use Invertus\SaferPay\Adapter\LegacyContext; use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Enum\ControllerName; From ab2a4b8da8989c736b9f9de51ce00706af2f9770 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 09:38:48 +0300 Subject: [PATCH 48/67] added if to work only in checkout --- src/Presentation/Loader/PaymentFormAssetLoader.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 3a52d13d..ea6b0ef2 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -88,6 +88,10 @@ private function registerOnePageCheckoutAssets($controller) private function registerTheCheckoutAssets($controller) { + if (get_class($controller) !== SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER) { + return; + } + if (method_exists($controller, 'registerJavascript')) { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { $controller->registerJavascript( From 0759cc43069219fc5ad75870d201b5feab58d8f8 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 09:41:45 +0300 Subject: [PATCH 49/67] updated js selector --- views/js/front/opc/thecheckout/hosted_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index ff9a90b4..5f93b756 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -36,7 +36,7 @@ $(document).ready(function () { } }); -$('body').on('submit', 'form.payment-form', function (e) { +$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { handleSubmit(e); }); From 3b997090dcb767e24301243f50ac44161b062186 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 16:02:29 +0300 Subject: [PATCH 50/67] fix --- saferpayofficial.php | 52 ++----------- .../Loader/PaymentFormAssetLoader.php | 59 +++++++++------ src/Provider/OpcModulesProvider.php | 4 + src/Validation/ValidateIsAssetsRequired.php | 56 ++++++++++++++ .../js/front/opc/thecheckout/hosted_fields.js | 12 +-- .../front/opc/thecheckout/hosted_fields_16.js | 75 ------------------- .../opc/thecheckout/saferpay_saved_card_16.js | 31 -------- 7 files changed, 109 insertions(+), 180 deletions(-) create mode 100644 src/Validation/ValidateIsAssetsRequired.php delete mode 100644 views/js/front/opc/thecheckout/hosted_fields_16.js delete mode 100644 views/js/front/opc/thecheckout/saferpay_saved_card_16.js diff --git a/saferpayofficial.php b/saferpayofficial.php index 27d5c9ad..13b77747 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -344,55 +344,19 @@ public function hookDisplayAdminOrder(array $params) public function hookActionFrontControllerSetMedia() { - /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ - $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); - - /** @var \Invertus\SaferPay\Provider\OpcModulesProvider $opcModulesProvider */ - $opcModulesProvider = $this->getService(\Invertus\SaferPay\Provider\OpcModulesProvider::class); - - $paymentFormAssetsLoader->register($this->context->controller); - - $opcModules = $opcModulesProvider->get(); - - switch ($opcModules) { - case \Invertus\SaferPay\Config\SaferPayConfig::THE_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)); - } + /** @var \Invertus\SaferPay\Validation\ValidateIsAssetsRequired $validateIsAssetsRequired */ + $validateIsAssetsRequired = $this->getService(\Invertus\SaferPay\Validation\ValidateIsAssetsRequired::class); - break; + if (!$validateIsAssetsRequired->run($this->context->controller)) { + return; } - /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ - $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); - $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); - - if ($this->context->controller instanceof OrderController) { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $this->context->controller->registerJavascript( - 'saved-card', - 'modules/' . $this->name . '/views/js/front/saferpay_saved_card.js' - ); + /** @var \Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader $paymentFormAssetsLoader */ + $paymentFormAssetsLoader = $this->getService(\Invertus\SaferPay\Presentation\Loader\PaymentFormAssetLoader::class); - $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout.css"); - } else { - $this->context->controller->addCSS("{$this->getPathUri()}views/css/front/saferpay_checkout_16.css"); - $this->context->controller->addJS("{$this->getPathUri()}views/js/front/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)); - } + $paymentFormAssetsLoader->register($this->context->controller); - /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ - $errorDisplayService = $this->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); - $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); - } + $paymentFormAssetsLoader->registerErrorBags(); } public function hookDisplayCustomerAccount() diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index ea6b0ef2..4eeceb44 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -23,6 +23,7 @@ namespace Invertus\SaferPay\Presentation\Loader; +use Configuration; use Invertus\SaferPay\Adapter\LegacyContext; use Invertus\SaferPay\Config\SaferPayConfig; use Invertus\SaferPay\Enum\ControllerName; @@ -76,9 +77,9 @@ public function register($controller) case SaferPayConfig::SUPER_CHECKOUT_MODULE: $this->registerSuperCheckoutAssets($controller); break; + default: + $this->registerDefaultCheckoutAssets($controller); } - - $this->registerDefaultCheckoutAssets($controller); } private function registerOnePageCheckoutAssets($controller) @@ -92,30 +93,18 @@ private function registerTheCheckoutAssets($controller) return; } + $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); + if (method_exists($controller, 'registerJavascript')) { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields.js" - ); - } else { - $controller->registerJavascript( - 'saved_card_hosted_fields', - "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields_16.js" - ); - } + $controller->registerJavascript( + 'saved_card_hosted_fields_opc', + "modules/saferpayofficial/views/js/front/opc/thecheckout/hosted_fields.js" + ); } else { - if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields.js', - false - ); - } else { - $controller->addJs( - $this->module->getPathUri() . 'views/js/front/hosted-templates/opc/thecheckout/hosted_fields_16.js', - false - ); - } + $controller->addJs( + $this->module->getPathUri() . 'views/js/front/opc/thecheckout/hosted_fields.js', + false + ); } } @@ -136,11 +125,25 @@ private function registerDefaultCheckoutAssets($controller) 'saved_card_hosted_fields', "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields.js" ); + + $controller->registerJavascript( + 'saved-card', + 'modules/' . $this->module->name . '/views/js/front/saferpay_saved_card.js' + ); + + $controller->registerStylesheet("", + "{$this->module->getPathUri()}views/css/front/saferpay_checkout.css"); } else { $controller->registerJavascript( 'saved_card_hosted_fields', "modules/saferpayofficial/views/js/front/hosted-templates/hosted_fields_16.js" ); + + $controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout_16.css"); + $controller->addJS("{$this->module->getPathUri()}views/js/front/saferpay_saved_card_16.js"); + $fieldsLibrary = \Invertus\SaferPay\Config\SaferPayConfig::FIELDS_LIBRARY; + $configSuffix = \Invertus\SaferPay\Config\SaferPayConfig::getConfigSuffix(); + $controller->addJs(Configuration::get($fieldsLibrary . $configSuffix)); } } else { if (\Invertus\SaferPay\Config\SaferPayConfig::isVersion17()) { @@ -156,4 +159,12 @@ private function registerDefaultCheckoutAssets($controller) } } } + + public function registerErrorBags() + { + /** @var \Invertus\SaferPay\Service\SaferPayErrorDisplayService $errorDisplayService */ + $errorDisplayService = $this->module->getService(\Invertus\SaferPay\Service\SaferPayErrorDisplayService::class); + + $errorDisplayService->showCookieError('saferpay_payment_canceled_error'); + } } diff --git a/src/Provider/OpcModulesProvider.php b/src/Provider/OpcModulesProvider.php index ab6e2b0c..9740cbe6 100644 --- a/src/Provider/OpcModulesProvider.php +++ b/src/Provider/OpcModulesProvider.php @@ -25,6 +25,10 @@ use Invertus\SaferPay\Config\SaferPayConfig; +if (!defined('_PS_VERSION_')) { + exit; +} + class OpcModulesProvider { /** diff --git a/src/Validation/ValidateIsAssetsRequired.php b/src/Validation/ValidateIsAssetsRequired.php new file mode 100644 index 00000000..d62beff5 --- /dev/null +++ b/src/Validation/ValidateIsAssetsRequired.php @@ -0,0 +1,56 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ + +namespace Invertus\SaferPay\Validation; + +use Invertus\SaferPay\Provider\OpcModulesProvider; +use FrontController; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ValidateIsAssetsRequired +{ + private $opcModulesProvider; + + public function __construct(OpcModulesProvider $opcModulesProvider) + { + $this->opcModulesProvider = $opcModulesProvider; + } + + /** + * It returns true if it's an OPC controller or an OrderController with products in the cart. Otherwise, it returns false. + */ + public function run(FrontController $controller) + { + $isOrderController = $controller instanceof \OrderControllerCore + || $controller instanceof \ModuleFrontController && isset($controller->php_self) && $controller->php_self === 'order'; + + if (!empty($this->opcModulesProvider->get($controller))) { + return $isOrderController && !empty(\Context::getContext()->cart->getProducts()); + } + + return true; + } +} \ No newline at end of file diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index 5f93b756..e1e52fc2 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -22,12 +22,6 @@ var selectedCard = null; -$(document).on('change', 'input[name^="saved_card_"]', function () { - var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); - updateCheckedCardValue(); - $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); -}); - $(document).ready(function () { let savedCardMethod = $('input[name="saved_card_method"]'); @@ -36,6 +30,12 @@ $(document).ready(function () { } }); +$(document).on('change', 'input[name^="saved_card_"]', function () { + var method = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + updateCheckedCardValue(); + $("input[name='selectedCreditCard_" + method + "']").val(selectedCard); +}); + $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { handleSubmit(e); }); diff --git a/views/js/front/opc/thecheckout/hosted_fields_16.js b/views/js/front/opc/thecheckout/hosted_fields_16.js deleted file mode 100644 index 1c47b06d..00000000 --- a/views/js/front/opc/thecheckout/hosted_fields_16.js +++ /dev/null @@ -1,75 +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 () { - var savedCardMethod = $('input[name="saved_card_method"]'); - - if (!savedCardMethod.length) { - return; - } - - $('[id="payment-form"]').on('submit', function (event) { - event.preventDefault(); - - var paymentType = $(this).find("[name=saferpayPaymentType]").val(); - - //NOTE: if it's not a hosted iframe then we don't need to submitHostedFields. - if (paymentType !== saferpay_payment_types.hosted_iframe) { - event.target.submit(); - - return; - } - - var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); - - var selectedCard = 0; - - $(this).find("[name=saved_card_" + selectedCardMethod + "]").each(function () { - if ($(this).is(':checked')) { - selectedCard = $(this).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 diff --git a/views/js/front/opc/thecheckout/saferpay_saved_card_16.js b/views/js/front/opc/thecheckout/saferpay_saved_card_16.js deleted file mode 100644 index 184c35eb..00000000 --- a/views/js/front/opc/thecheckout/saferpay_saved_card_16.js +++ /dev/null @@ -1,31 +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 () { - $('.saferpay_method.js_credit_card').on('click', function () { - event.preventDefault(); - var method = $(this).attr('data-saferpay-method'); - $('.saferpay_additional_info').hide(); - var $additionalInfo = $('.saferpay_additional_info.' + method); - $additionalInfo.show(); - }) -}); \ No newline at end of file From d0e20a501ccbdacd76cf75e7e68dd8b4e564ae14 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 17:38:56 +0300 Subject: [PATCH 51/67] fix --- views/js/front/opc/thecheckout/hosted_fields.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index e1e52fc2..e8af4ef3 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -37,13 +37,15 @@ $(document).on('change', 'input[name^="saved_card_"]', function () { }); $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (e) { - handleSubmit(e); + var idPayment = $(this).parent('div').attr('id').match(/\d+/)[0]; + handleSubmit(e, idPayment); }); -function handleSubmit(event) { +function handleSubmit(event, idPayment) { event.preventDefault(); - let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); + let selectedCardMethod = $('#' + "payment-option-" + idPayment + "-additional-information").find('input[type="hidden"]').val(); + // let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); From d1c51297e3e3f21a15a16c4a15e626480952fca0 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Wed, 16 Oct 2024 17:39:41 +0300 Subject: [PATCH 52/67] fix --- views/js/front/opc/thecheckout/hosted_fields.js | 1 - 1 file changed, 1 deletion(-) diff --git a/views/js/front/opc/thecheckout/hosted_fields.js b/views/js/front/opc/thecheckout/hosted_fields.js index e8af4ef3..ed2299f3 100644 --- a/views/js/front/opc/thecheckout/hosted_fields.js +++ b/views/js/front/opc/thecheckout/hosted_fields.js @@ -45,7 +45,6 @@ function handleSubmit(event, idPayment) { event.preventDefault(); let selectedCardMethod = $('#' + "payment-option-" + idPayment + "-additional-information").find('input[type="hidden"]').val(); - // let selectedCardMethod = $('[data-module-name*="saferpayofficial"]:checked').closest('div').find('.h6').text().toUpperCase(); let form = $(document).find("[name=selectedCreditCard_" + selectedCardMethod + "]").closest('form'); let hiddenInput = form.find("input[name='selectedCreditCard_" + selectedCardMethod + "']"); From 092ff2d90815b59880204c1d3504ecbab097beca Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Thu, 17 Oct 2024 10:58:25 +0300 Subject: [PATCH 53/67] 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 54/67] 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 55/67] 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 56/67] 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 57/67] 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 58/67] 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 59/67] 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 60/67] 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 61/67] 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 62/67] 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 63/67] 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 64/67] 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 65/67] 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 b5d59449212986c20ab380d8e985b24040dbc262 Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 18 Oct 2024 16:17:16 +0300 Subject: [PATCH 66/67] fix --- src/Presentation/Loader/PaymentFormAssetLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Presentation/Loader/PaymentFormAssetLoader.php b/src/Presentation/Loader/PaymentFormAssetLoader.php index 4eeceb44..be73df09 100755 --- a/src/Presentation/Loader/PaymentFormAssetLoader.php +++ b/src/Presentation/Loader/PaymentFormAssetLoader.php @@ -89,7 +89,7 @@ private function registerOnePageCheckoutAssets($controller) private function registerTheCheckoutAssets($controller) { - if (get_class($controller) !== SaferPayConfig::THE_CHECKOUT_FRONT_CONTROLLER) { + if (!$controller instanceof \TheCheckoutModuleFrontController) { return; } From ab141d73414ce2cd1215ee59ebd3912e296651ea Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Fri, 18 Oct 2024 16:53:29 +0300 Subject: [PATCH 67/67] fix --- src/Config/SaferPayConfig.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 546ef3d4..a9f93af5 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -277,9 +277,6 @@ 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 OPC_MODULE_LIST = [ self::ONE_PAGE_CHECKOUT_MODULE, self::THE_CHECKOUT_MODULE,