From 2213b9bfc560fc0bc7ad0eaf92063c6d22aefcb6 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Thu, 11 Jan 2024 11:53:18 +0100 Subject: [PATCH] Remove merchant tag for in-page on Prestashop --- CHANGELOG.md | 4 ++ alma/alma.php | 4 +- .../hook/GetContentHookController.php | 6 +-- alma/lib/Helpers/ApiHelper.php | 25 ---------- alma/lib/Helpers/ConstantsHelper.php | 2 - alma/lib/Helpers/SettingsHelper.php | 9 ---- alma/upgrade/upgrade-3.1.3.php | 50 +++++++++++++++++++ 7 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 alma/upgrade/upgrade-3.1.3.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b798328bd..cacc2711b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.1.3 + +- feat: Remove merchant tag for in-page on Prestashop + ## v3.1.2 - hotfix: Select payment In-Page without open the modal and try to pay with other payment method diff --git a/alma/alma.php b/alma/alma.php index c728d4162..5bbfd1902 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -30,7 +30,7 @@ class Alma extends PaymentModule { - const VERSION = '3.1.2'; + const VERSION = '3.1.3'; public $_path; public $local_path; @@ -65,7 +65,7 @@ public function __construct() { $this->name = 'alma'; $this->tab = 'payments_gateways'; - $this->version = '3.1.2'; + $this->version = '3.1.3'; $this->author = 'Alma'; $this->need_instance = false; $this->bootstrap = true; diff --git a/alma/controllers/hook/GetContentHookController.php b/alma/controllers/hook/GetContentHookController.php index 159afc15f..a314c9aee 100644 --- a/alma/controllers/hook/GetContentHookController.php +++ b/alma/controllers/hook/GetContentHookController.php @@ -590,10 +590,8 @@ protected function buildForms($needsKeys, $feePlansOrdered, $installmentsPlans) $fieldsForms[] = $shareOfCheckoutBuilder->build(); } - if (SettingsHelper::isInpageAllowed()) { - $inpageBuilder = new InpageAdminFormBuilder($this->module, $this->context, $iconPath); - $fieldsForms[] = $inpageBuilder->build(); - } + $inpageBuilder = new InpageAdminFormBuilder($this->module, $this->context, $iconPath); + $fieldsForms[] = $inpageBuilder->build(); } if (SettingsHelper::isPaymentTriggerEnabledByState()) { diff --git a/alma/lib/Helpers/ApiHelper.php b/alma/lib/Helpers/ApiHelper.php index 7e5f10782..20fd84a1e 100644 --- a/alma/lib/Helpers/ApiHelper.php +++ b/alma/lib/Helpers/ApiHelper.php @@ -70,31 +70,6 @@ public static function getMerchant($module, $alma = null) throw new ActivationException($module); } - static::saveFeatureFlag($merchant, 'cms_allow_inpage', ConstantsHelper::ALMA_ALLOW_INPAGE); - return $merchant; } - - /** - * @param \Alma\API\Entities\Merchant $merchant - * @param string $merchantKey - * @param string $configKey - * - * @return void - */ - protected static function saveFeatureFlag($merchant, $merchantKey, $configKey) - { - $value = 1; - - if (property_exists($merchant, $merchantKey)) { - $value = $merchant->$merchantKey; - } - - SettingsHelper::updateValue($configKey, (int) $value); - - // If Inpage not allowed we ensure that inpage is deactivated in database - if (0 === $value) { - SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, (int) $value); - } - } } diff --git a/alma/lib/Helpers/ConstantsHelper.php b/alma/lib/Helpers/ConstantsHelper.php index fca9d0d1d..804322210 100644 --- a/alma/lib/Helpers/ConstantsHelper.php +++ b/alma/lib/Helpers/ConstantsHelper.php @@ -53,6 +53,4 @@ class ConstantsHelper const SOURCE_CUSTOM_FIELDS = 'CustomFieldsHelper'; const ALMA_KEY_PAYNOW = 'general_1_0_0'; - - const ALMA_ALLOW_INPAGE = 'ALMA_ALLOW_INPAGE'; } diff --git a/alma/lib/Helpers/SettingsHelper.php b/alma/lib/Helpers/SettingsHelper.php index 889867d20..3ca4ab9fa 100644 --- a/alma/lib/Helpers/SettingsHelper.php +++ b/alma/lib/Helpers/SettingsHelper.php @@ -147,7 +147,6 @@ public static function deleteAllValues() 'ALMA_CART_WDGT_NOT_ELGBL', 'ALMA_PRODUCT_WDGT_NOT_ELGBL', 'ALMA_CATEGORIES_WDGT_NOT_ELGBL', - ConstantsHelper::ALMA_ALLOW_INPAGE, ]; foreach ($configKeys as $configKey) { @@ -271,14 +270,6 @@ public static function getCurrentTimestamp() return $date->getTimestamp(); } - /** - * @return bool - */ - public static function isInpageAllowed() - { - return (bool) static::get(ConstantsHelper::ALMA_ALLOW_INPAGE, 0); - } - /** * Get API mode saved in Prestashop database. * diff --git a/alma/upgrade/upgrade-3.1.3.php b/alma/upgrade/upgrade-3.1.3.php new file mode 100644 index 000000000..1a4ca15a0 --- /dev/null +++ b/alma/upgrade/upgrade-3.1.3.php @@ -0,0 +1,50 @@ + + * @copyright 2018-2023 Alma SAS + * @license https://opensource.org/licenses/MIT The MIT License + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +use Alma\PrestaShop\Helpers\ClientHelper; +use Alma\PrestaShop\Helpers\SettingsHelper; + +function upgrade_module_3_1_3() +{ + if (SettingsHelper::isFullyConfigured()) { + $alma = ClientHelper::defaultInstance(); + + if (!$alma) { + return true; + } + + $deleteKeys = [ + 'ALMA_ALLOW_INPAGE', + ]; + + foreach ($deleteKeys as $deleteKey) { + Configuration::deleteByName($deleteKey); + } + } + + return true; +}