diff --git a/.github/PULL_REQUEST_TEMPLATE.yml b/.github/PULL_REQUEST_TEMPLATE.yml new file mode 100644 index 00000000..9cd514fa --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.yml @@ -0,0 +1,23 @@ +## Self-Checks +- [ ] I have performed a self-review of my code. +- [ ] I have updated/added necessary technical documentation in the [README](/README.md) file. + +## Summary + + +## QA Checklist Labels +- [ ] Bug fix? +- [ ] New feature? +- [ ] Improvement? +- [ ] Technical debt? +- [ ] Reusable? +- [ ] Covered by tests? + +## QA Checklist + + + ## Additional Context + + + ## Frontend Changes + \ No newline at end of file diff --git a/.github/workflows/PULL_REQUEST_LABELS.yml b/.github/workflows/PULL_REQUEST_LABELS.yml new file mode 100644 index 00000000..3912c210 --- /dev/null +++ b/.github/workflows/PULL_REQUEST_LABELS.yml @@ -0,0 +1,10 @@ +name: Apply Labels Based on PR Template + +on: + pull_request: + types: [opened, edited] + +jobs: + label-management: + uses: Invertus/github-templates/.github/workflows/label-management.yml@v1.0.2 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/PULL_REQUEST_NAMING_RULES.yml b/.github/workflows/PULL_REQUEST_NAMING_RULES.yml new file mode 100644 index 00000000..96b84b8b --- /dev/null +++ b/.github/workflows/PULL_REQUEST_NAMING_RULES.yml @@ -0,0 +1,12 @@ +name: Names rules + +on: [pull_request, workflow_dispatch] + +jobs: + branch-name-check: + uses: Invertus/github-templates/.github/workflows/branch-name-check.yml@v1.0.2 + secrets: inherit + + pr-title-check: + uses: Invertus/github-templates/.github/workflows/pr-title-check.yml@v1.0.2 + secrets: inherit \ No newline at end of file diff --git a/changelog.md b/changelog.md index 3ffb1c8d..d4895f9d 100755 --- a/changelog.md +++ b/changelog.md @@ -175,4 +175,10 @@ - Implemented code logging - Requiring card holder name when entering card details - Removed depreciated feature for custom CSS -- Compatibility with most popular OPC modules (The Checkout, Super Checkout, One Page Checkout PS) \ No newline at end of file +- Compatibility with most popular OPC modules (The Checkout, Super Checkout, One Page Checkout PS) + +## [1.2.5] +- Fixed issue with JSON API Password escaping HTML entities +- Added new payment methods: Blik, ClickToPay +- Fixed performance issues when loading "Payments" tab in Back office. +- Fixed issue when saferpay logic is executing on other payment methods which is not saferpay diff --git a/controllers/admin/AdminSaferPayOfficialPaymentController.php b/controllers/admin/AdminSaferPayOfficialPaymentController.php index 8b9ac801..3fe6f9c4 100755 --- a/controllers/admin/AdminSaferPayOfficialPaymentController.php +++ b/controllers/admin/AdminSaferPayOfficialPaymentController.php @@ -164,6 +164,11 @@ protected function renderShoppingPointOptions() $fieldsForm = []; $fieldsForm[0]['form'] = $this->fields_form; + /** @var \Invertus\SaferPay\Service\SaferPayObtainPaymentMethods $saferPayObtainPaymentMethods */ + $saferPayObtainPaymentMethods = $this->module->getService(SaferPayObtainPaymentMethods::class); + + $paymentMethodsList = $saferPayObtainPaymentMethods->obtainPaymentMethods(); + foreach ($paymentMethods as $paymentMethod) { $isActive = $paymentRepository->isActiveByName($paymentMethod); $isLogoActive = $logoRepository->isActiveByName($paymentMethod); @@ -184,7 +189,7 @@ protected function renderShoppingPointOptions() 'paymentMethod' => $paymentMethod, 'countryOptions' => $this->getActiveCountriesList(), 'countrySelect' => $selectedCountries, - 'currencyOptions' => $this->getActiveCurrenciesList($paymentMethod), + 'currencyOptions' => $this->getActiveCurrenciesList($paymentMethod, $paymentMethodsList), 'currencySelect' => $selectedCurrencies, 'is_field_active' => $isFieldActive, 'supported_field_payments' => SaferPayConfig::FIELD_SUPPORTED_PAYMENT_METHODS, @@ -219,14 +224,18 @@ public function getActiveCountriesList($onlyActive = true) return $countriesWithNames; } - public function getActiveCurrenciesList($paymentMethod) + public function getActiveCurrenciesList($paymentMethod, $paymentMethods) { - /** @var \Invertus\SaferPay\Service\SaferPayObtainPaymentMethods $saferPayObtainPaymentMethods */ - $saferPayObtainPaymentMethods = $this->module->getService(SaferPayObtainPaymentMethods::class); + $currencyOptions[0] = $this->l('All'); - $paymentMethods = $saferPayObtainPaymentMethods->obtainPaymentMethods(); + if (!isset($paymentMethods[$paymentMethod]['currencies']) && in_array($paymentMethod, SaferPayConfig::WALLET_PAYMENT_METHODS)) { + foreach (Currency::getCurrencies() as $currency) { + $currencyOptions[$currency['id_currency']] = $currency['iso_code']; + } + + return $currencyOptions; + } - $currencyOptions[0] = $this->l('All'); foreach ($paymentMethods[$paymentMethod]['currencies'] as $currencyIso) { if (Currency::getIdByIsoCode($currencyIso)) { $currencyOptions[Currency::getIdByIsoCode($currencyIso)] = $currencyIso; diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 0cf1b1b7..6949988a 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -125,8 +125,9 @@ public function initOptions() ], SaferPayConfig::PASSWORD => [ 'title' => $this->l('JSON API Password'), - 'type' => 'text', + 'type' => 'password_input', 'class' => 'fixed-width-xl', + 'value' => Configuration::get(SaferPayConfig::PASSWORD), ], SaferPayConfig::CUSTOMER_ID => [ 'title' => $this->l('Customer ID'), @@ -192,8 +193,9 @@ public function initOptions() ], SaferPayConfig::PASSWORD . SaferPayConfig::TEST_SUFFIX => [ 'title' => $this->l('JSON API Password'), - 'type' => 'text', + 'type' => 'password_input', 'class' => 'fixed-width-xl', + 'value' => Configuration::get(SaferPayConfig::PASSWORD . SaferPayConfig::TEST_SUFFIX), ], SaferPayConfig::CUSTOMER_ID . SaferPayConfig::TEST_SUFFIX => [ 'title' => $this->l('Customer ID'), diff --git a/saferpayofficial.php b/saferpayofficial.php index c467a61a..553b14cd 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -21,6 +21,8 @@ *@license SIX Payment Services */ +use Invertus\SaferPay\Config\SaferPayConfig; + if (!defined('_PS_VERSION_')) { exit; } @@ -40,7 +42,7 @@ public function __construct($name = null) { $this->name = 'saferpayofficial'; $this->author = 'Invertus'; - $this->version = '1.2.4'; + $this->version = '1.2.5'; $this->module_key = '3d3506c3e184a1fe63b936b82bda1bdf'; $this->displayName = 'SaferpayOfficial'; $this->description = 'Saferpay Payment module'; @@ -216,11 +218,16 @@ public function hookPaymentOptions($params) foreach ($paymentMethods as $paymentMethod) { $paymentMethod['paymentMethod'] = str_replace(' ', '', $paymentMethod['paymentMethod']); - if (!in_array($paymentMethod['paymentMethod'], $activePaymentMethods)) { - continue; + if (in_array($paymentMethod['paymentMethod'], SaferPayConfig::WALLET_PAYMENT_METHODS)) { + foreach (Currency::getCurrencies() as $currency) { + $currencyOptions[$currency['id_currency']] = $currency['iso_code']; + } + + $paymentMethod['currencies'] = $currencyOptions; } - if (!in_array($this->context->currency->iso_code, $paymentMethods[$paymentMethod['paymentMethod']]['currencies'])) { + if (!in_array($this->context->currency->iso_code, $paymentMethod['currencies']) + && !in_array($paymentMethod['paymentMethod'], SaferPayConfig::WALLET_PAYMENT_METHODS)) { continue; } diff --git a/src/Adapter/Cart.php b/src/Adapter/Cart.php index b0aa490f..b3e70504 100644 --- a/src/Adapter/Cart.php +++ b/src/Adapter/Cart.php @@ -23,6 +23,10 @@ namespace Invertus\SaferPay\Adapter; +if (!defined('_PS_VERSION_')) { + exit; +} + class Cart { /** diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index d1e6b359..aaa47760 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -49,7 +49,7 @@ class SaferPayConfig const RESTRICT_REFUND_AMOUNT_TO_CAPTURED_AMOUNT = 'SAFERPAY_RESTRICT_REFUND_AMOUNT_TO_CAPTURED_AMOUNT'; const CONFIGURATION_NAME = 'SAFERPAY_CONFIGURATION_NAME'; const TEST_SUFFIX = '_TEST'; - const API_VERSION = '1.40'; + const API_VERSION = '1.43'; const PAYMENT_METHODS = [ self::PAYMENT_ALIPAY, self::PAYMENT_AMEX, @@ -78,6 +78,7 @@ class SaferPayConfig self::PAYMENT_WLCRYPTOPAYMENTS, self::PAYMENT_WECHATPAY, self::PAYMENT_ACCOUNTTOACCOUNT, + self::PAYMENT_CLICKTOPAY, ]; const PAYMENT_ALIPAY = 'ALIPAY'; @@ -113,10 +114,13 @@ class SaferPayConfig const PAYMENT_CARD = 'CARD'; const PAYMENT_POSTFINANCE_PAY = 'POSTFINANCEPAY'; const PAYMENT_WECHATPAY = 'WECHATPAY'; + const PAYMENT_CLICKTOPAY = 'CLICKTOPAY'; + const PAYMENT_BLIK = 'BLIK'; const WALLET_PAYMENT_METHODS = [ self::PAYMENT_APPLEPAY, self::PAYMENT_GOOGLEPAY, + self::PAYMENT_CLICKTOPAY, ]; const PAYMENT_METHODS_KEYS = [ @@ -144,6 +148,7 @@ class SaferPayConfig 'Card' => self::PAYMENT_CARD, 'PostFinancePay' => self::PAYMENT_POSTFINANCE_PAY, 'WeChatPay' => self::PAYMENT_WECHATPAY, + 'Blik' => self::PAYMENT_BLIK, ]; const FIELD_SUPPORTED_PAYMENT_METHODS = [ @@ -315,7 +320,9 @@ public static function isRedirectPayment($paymentMethod) self::PAYMENT_POSTFINANCE_PAY, self::PAYMENT_DIRECTDEBIT, self::PAYMENT_SOFORT, - self::PAYMENT_PAYPAL + self::PAYMENT_PAYPAL, + self::PAYMENT_CLICKTOPAY, + self::PAYMENT_BLIK, ]; return in_array($paymentMethod, $paymentsAlwaysRedirect); diff --git a/src/Context/index.php b/src/Context/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/src/Context/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/src/Controller/AbstractAdminSaferPayController.php b/src/Controller/AbstractAdminSaferPayController.php index 9cc6521f..a952b30c 100644 --- a/src/Controller/AbstractAdminSaferPayController.php +++ b/src/Controller/AbstractAdminSaferPayController.php @@ -27,6 +27,10 @@ use Invertus\SaferPay\Response\JsonResponse; use Invertus\SaferPay\Utility\ExceptionUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class AbstractAdminSaferPayController extends \ModuleAdminController { const FILE_NAME = 'AbstractAdminSaferPayController'; diff --git a/src/EntityManager/index.php b/src/EntityManager/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/src/EntityManager/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/src/Logger/Formatter/index.php b/src/Logger/Formatter/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/src/Logger/Formatter/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 4d6e8887..f8b1351d 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -33,6 +33,10 @@ use Invertus\SaferPay\Provider\BasicIdempotencyProvider; use Invertus\SaferPay\Repository\PrestashopLoggerRepositoryInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class Logger implements LoggerInterface { const FILE_NAME = 'Logger'; diff --git a/src/Logger/index.php b/src/Logger/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/src/Logger/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/src/Service/LegacyTranslator.php b/src/Service/LegacyTranslator.php index 5c53b5d2..e87ce4e7 100755 --- a/src/Service/LegacyTranslator.php +++ b/src/Service/LegacyTranslator.php @@ -82,6 +82,9 @@ private function getTranslations() SaferPayConfig::PAYMENT_CARD => $this->module->l('Card', self::FILE_NAME), SaferPayConfig::PAYMENT_POSTFINANCE_PAY => $this->module->l('PostFinancePay', self::FILE_NAME), SaferPayConfig::PAYMENT_WECHATPAY => $this->module->l('WeChatPay', self::FILE_NAME), + SaferPayConfig::PAYMENT_BLIK => $this->module->l('Blik', self::FILE_NAME), + SaferPayConfig::PAYMENT_GOOGLEPAY => $this->module->l('Googlepay'), + SaferPayConfig::PAYMENT_CLICKTOPAY => $this->module->l('Clicktopay', self::FILE_NAME), ]; } } diff --git a/src/Service/SaferPayObtainPaymentMethods.php b/src/Service/SaferPayObtainPaymentMethods.php index 27a00dbe..86e7a625 100755 --- a/src/Service/SaferPayObtainPaymentMethods.php +++ b/src/Service/SaferPayObtainPaymentMethods.php @@ -87,7 +87,6 @@ public function obtainPaymentMethods() $paymentMethods[$wallet->WalletName] = [ 'paymentMethod' => $wallet->WalletName, 'logoUrl' => $wallet->LogoUrl, - 'currencies' => $paymentMethodObject->Currencies, ]; } } diff --git a/upgrade/install-1.2.5.php b/upgrade/install-1.2.5.php new file mode 100644 index 00000000..82f48f66 --- /dev/null +++ b/upgrade/install-1.2.5.php @@ -0,0 +1,34 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ + +use Invertus\SaferPay\Config\SaferPayConfig; +use Invertus\SaferPay\DTO\Request\RequestHeader; + +if (!defined('_PS_VERSION_')) { + exit; +} + +function upgrade_module_1_2_5(SaferPayOfficial $module) +{ + return Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION); +} diff --git a/views/js/front/hosted-templates/hosted_fields.js b/views/js/front/hosted-templates/hosted_fields.js index 2ee1e631..63bfc9d2 100755 --- a/views/js/front/hosted-templates/hosted_fields.js +++ b/views/js/front/hosted-templates/hosted_fields.js @@ -30,6 +30,13 @@ $(document).ready(function () { $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { event.preventDefault(); + var isSaferPayMethodSelected = $('[data-module-name*="saferpayofficial"]:checked').length; + + if (!isSaferPayMethodSelected) { + event.target.submit(); + return; + } + var selectedCardMethod = $(this).find("[name=saved_card_method]").val(); var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val(); diff --git a/views/js/front/opc/onepagecheckoutps/hosted_fields.js b/views/js/front/opc/onepagecheckoutps/hosted_fields.js index 2b8162f7..a4a1c647 100644 --- a/views/js/front/opc/onepagecheckoutps/hosted_fields.js +++ b/views/js/front/opc/onepagecheckoutps/hosted_fields.js @@ -41,6 +41,13 @@ $('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) { return; } + var isSaferPayMethodSelected = $('[data-module-name*="saferpayofficial"]:checked').length; + + if (!isSaferPayMethodSelected) { + event.target.submit(); + return; + } + $.ajax(saferpay_official_ajax_url, { method: 'POST', data: { diff --git a/views/js/front/opc/onepagecheckoutps/index.php b/views/js/front/opc/onepagecheckoutps/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/views/js/front/opc/onepagecheckoutps/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/js/front/opc/supercheckout/index.php b/views/js/front/opc/supercheckout/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/views/js/front/opc/supercheckout/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/js/front/opc/thecheckout/index.php b/views/js/front/opc/thecheckout/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/views/js/front/opc/thecheckout/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/templates/admin/field-option-settings/helpers/options/options.tpl b/views/templates/admin/field-option-settings/helpers/options/options.tpl index 2051521c..4c100589 100755 --- a/views/templates/admin/field-option-settings/helpers/options/options.tpl +++ b/views/templates/admin/field-option-settings/helpers/options/options.tpl @@ -23,6 +23,18 @@ {extends file="helpers/options/options.tpl"} {block name="input" append} + {if $field['type'] == 'password_input'} +
+ +
+ {/if} {if $field['type'] == 'desc'}
{if $field['template'] == 'field-javascript-library-desc.tpl'} diff --git a/views/templates/admin/logs/index.php b/views/templates/admin/logs/index.php new file mode 100644 index 00000000..ee622726 --- /dev/null +++ b/views/templates/admin/logs/index.php @@ -0,0 +1,31 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit;