Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #283

Merged
merged 7 commits into from
Jan 11, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions alma/alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class Alma extends PaymentModule
{
const VERSION = '3.1.2';
const VERSION = '3.1.3';

public $_path;
public $local_path;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
25 changes: 0 additions & 25 deletions alma/lib/Helpers/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 0 additions & 2 deletions alma/lib/Helpers/ConstantsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
9 changes: 0 additions & 9 deletions alma/lib/Helpers/SettingsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
*
Expand Down
50 changes: 50 additions & 0 deletions alma/upgrade/upgrade-3.1.3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* 2018-2023 Alma SAS.
*
* THE MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @author Alma SAS <[email protected]>
* @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;
}