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

Release v4.6.0 #615

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
69a3e84
feat: CMS is able to send the endpoint_url to backend
Benjamin-Freoua-Alma Oct 22, 2024
27578af
feat: add cmsdataexport front controller
Benjamin-Freoua-Alma Oct 24, 2024
6399e6f
feat: refacto controller front cmsdataexport
Benjamin-Freoua-Alma Oct 25, 2024
2c8eb85
fix: update previous test
Benjamin-Freoua-Alma Oct 29, 2024
fb115ce
fix: add test in function refactored
Benjamin-Freoua-Alma Oct 29, 2024
59484b0
feat: Hmac + Timetamp + CmsDataService + Helper Data CMS
Benjamin-Freoua-Alma Oct 31, 2024
957c882
feat: refacto controller + Test
Benjamin-Freoua-Alma Oct 31, 2024
9edbf24
fix: Sonar
Benjamin-Freoua-Alma Nov 4, 2024
cb2ad99
fix: Sonar include_once instead include
Benjamin-Freoua-Alma Nov 4, 2024
a3cc2c2
fix: php client dependency
Francois-Gomis Nov 14, 2024
01ed88f
fix: change merchant endpoint to configuration
Francois-Gomis Nov 14, 2024
5a4bb24
fix: alma php client version requirement
Francois-Gomis Nov 14, 2024
ffd32fd
feat: review [FRA] create ShopModel + docblock
Benjamin-Freoua-Alma Nov 15, 2024
2383ddb
fix: constante ALMA_CMSDATA_DATE
Benjamin-Freoua-Alma Nov 15, 2024
66dcbfb
Merge pull request #604 from alma/chore/backport-main-to-develop
Benjamin-Freoua-Alma Nov 18, 2024
11c2b8c
chore(deps): update pre-commit hook commitizen-tools/commitizen to v3…
alma-renovate-bot[bot] Nov 18, 2024
2f9076d
fix: Review [FRA] add ModuleProxy + AlmaModuleModel
Benjamin-Freoua-Alma Nov 18, 2024
de97302
feat: Review [MAR] change the upgrade file for this feature
Benjamin-Freoua-Alma Nov 18, 2024
a21b550
feat: Review [MAR] add deprecated phpdoc isInstalledModules
Benjamin-Freoua-Alma Nov 19, 2024
e321ed0
Merge pull request #587 from alma/feature/ecom-2127-ps-implement-php-…
Benjamin-Freoua-Alma Nov 19, 2024
7228240
Merge pull request #605 from alma/renovate/pre-commit-repositories
Benjamin-Freoua-Alma Nov 19, 2024
2a0e86c
chore(deps): update slackapi/slack-github-action action to v2
alma-renovate-bot[bot] Nov 25, 2024
dcddfd4
Handle breaking changes
remi-zuffinetti Nov 26, 2024
ac51fba
Merge pull request #606 from alma/renovate/github-actions
remi-zuffinetti Nov 26, 2024
7b2940f
chore(deps): update pre-commit hook returntocorp/semgrep to v1.97.0
alma-renovate-bot[bot] Dec 2, 2024
c935bc4
chore(deps): update pre-commit hook commitizen-tools/commitizen to v4
alma-renovate-bot[bot] Dec 2, 2024
19462d8
feat: Send the endpoint_url during the upgrade + normalize return jso…
Benjamin-Freoua-Alma Dec 2, 2024
ea0fcad
Merge pull request #609 from alma/renovate/pre-commit-repositories
Benjamin-Freoua-Alma Dec 2, 2024
7e1d999
Merge pull request #610 from alma/renovate/commitizen-tools-commitize…
Benjamin-Freoua-Alma Dec 2, 2024
ba60095
Merge pull request #612 from alma/feature/ecom-2240-ps-send-the-endpo…
Benjamin-Freoua-Alma Dec 6, 2024
98df2ac
fix: Custom Description for payment button credit
Benjamin-Freoua-Alma Dec 10, 2024
9e3aa6c
Merge pull request #614 from alma/feature/ecom-2263-ps-fix-custom-des…
Benjamin-Freoua-Alma Dec 10, 2024
ce7753e
chore: update version
Benjamin-Freoua-Alma Dec 10, 2024
21e765d
chore: remove TODO + update translation
Benjamin-Freoua-Alma Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ jobs:
cc <@france.berut> <@khadija.cherif>

- name: Send changelog to Slack
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
channel-id: CR9C57YM6
slack-message: ${{ steps.slack-markdown-release-notes.outputs.text }}
method: chat.postMessage
token: ${{ secrets.SLACK_RELEASE_CHANGELOG_BOT_TOKEN }}
payload: |
{
"username": "${{ github.event.sender.login }}",
"icon_url": "${{ github.event.sender.avatar_url }}"
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_RELEASE_CHANGELOG_BOT_TOKEN }}
channel: CR9C57YM6
username: "${{ github.event.sender.login }}"
icon_url: "${{ github.event.sender.avatar_url }}"
text: ${{ toJson(steps.slack-markdown-release-notes.outputs.text) }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.1
rev: v4.0.0
hooks:
- id: commitizen
name: Check commit message format
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
stages: [commit]

- repo: https://github.com/returntocorp/semgrep
rev: v1.96.0
rev: v1.97.0
hooks:
- id: semgrep
args:
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## v4.6.0 - 2024-12-10

### Changes

### 🚀 New Features

- feat: Product analytics for plugin performance (#587)

### 🐛 Bug Fixes

- fix: Custom Description for payment button credit (#614)

#### Contributors

@Benjamin-Freoua-Alma, @alma-renovate-bot, @alma-renovate-bot[bot], @github-actions and @remi-zuffinetti

## v4.5.0 - 2024-11-13

### Changes
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 = '4.5.0';
const VERSION = '4.6.0';
const PS_ACCOUNTS_VERSION_REQUIRED = '5.3.0';

public $_path;
Expand Down Expand Up @@ -81,7 +81,7 @@ public function __construct()
{
$this->name = 'alma';
$this->tab = 'payments_gateways';
$this->version = '4.5.0';
$this->version = '4.6.0';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down
2 changes: 1 addition & 1 deletion alma/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"require": {
"php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4 || ~8.0 || ~8.1",
"alma/alma-php-client": "^2.2.0",
"alma/alma-php-client": "^2.3.1",
"ext-json": "*",
"ext-openssl": "*",
"prestashop/prestashop-accounts-installer": "^v1.0.4",
Expand Down
134 changes: 134 additions & 0 deletions alma/controllers/front/cmsdataexport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php
/**
* 2018-2024 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-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

use Alma\API\Entities\MerchantData\CmsFeatures;
use Alma\API\Entities\MerchantData\CmsInfo;
use Alma\API\Lib\PayloadFormatter;
use Alma\PrestaShop\Builders\Helpers\SettingsHelperBuilder;
use Alma\PrestaShop\Exceptions\CmsDataException;
use Alma\PrestaShop\Exceptions\ValidateException;
use Alma\PrestaShop\Helpers\CmsDataHelper;
use Alma\PrestaShop\Helpers\SettingsHelper;
use Alma\PrestaShop\Helpers\ValidateHelper;
use Alma\PrestaShop\Traits\AjaxTrait;

if (!defined('_PS_VERSION_')) {
exit;
}

/**
* AlmaCmsDataExportModuleFrontController
*/
class AlmaCmsDataExportModuleFrontController extends ModuleFrontController
{
use AjaxTrait;

/**
* @var ValidateHelper
*/
protected $validateHelper;
/**
* @var \Alma\PrestaShop\Helpers\SettingsHelper
*/
protected $settingsHelper;
/**
* @var \Alma\API\Lib\PayloadFormatter
*/
protected $payloadFormatter;
/**
* @var CmsDataHelper
*/
protected $cmsDataHelper;

public function __construct()
{
parent::__construct();
$this->validateHelper = new ValidateHelper();
$this->cmsDataHelper = new CmsDataHelper();
$this->settingsHelper = (new SettingsHelperBuilder())->getInstance();
$this->payloadFormatter = new PayloadFormatter();
}

/**
* @throws \Alma\PrestaShop\Exceptions\CmsDataException
* @throws \PrestaShopException
*/
public function postProcess()
{
parent::postProcess();
try {
$this->validateHelper->checkSignature($this->settingsHelper->getIdMerchant(), SettingsHelper::getActiveAPIKey(), $_SERVER['HTTP_X_ALMA_SIGNATURE']);
} catch (ValidateException $e) {
throw new CmsDataException('[Alma] checkSignature - ' . $e->getMessage());
} catch (\Exception $e) {
throw new CmsDataException('[Alma] Get Merchant Id - ' . $e->getMessage());
}

$cmsInfo = new CmsInfo($this->cmsDataHelper->getCmsInfoArray());
$cmsFeature = new CmsFeatures($this->cmsDataHelper->getCmsFeatureArray());

$payload = $this->payloadFormatter->formatConfigurationPayload($cmsInfo, $cmsFeature);
$this->ajaxRenderAndExit(json_encode($payload));
}

/**
* @param $validateHelper
*
* @return void
*/
public function setValidateHelper($validateHelper)
{
$this->validateHelper = $validateHelper;
}

/**
* @param $settingsHelper
*
* @return void
*/
public function setSettingsHelper($settingsHelper)
{
$this->settingsHelper = $settingsHelper;
}

/**
* @param $payloadFormatter
*
* @return void
*/
public function setPayloadFormatter($payloadFormatter)
{
$this->payloadFormatter = $payloadFormatter;
}

/**
* @param $cmsDataHelper
*
* @return void
*/
public function setCmsDataHelper($cmsDataHelper)
{
$this->cmsDataHelper = $cmsDataHelper;
}
}
27 changes: 22 additions & 5 deletions alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
}

use Alma\API\Entities\Merchant;
use Alma\API\Lib\IntegrationsConfigurationsUtils;
use Alma\API\RequestError;
use Alma\PrestaShop\Builders\Helpers\ApiHelperBuilder;
use Alma\PrestaShop\Builders\Helpers\ContextHelperBuilder;
use Alma\PrestaShop\Builders\Helpers\CustomFieldHelperBuilder;
use Alma\PrestaShop\Builders\Helpers\PriceHelperBuilder;
use Alma\PrestaShop\Builders\Helpers\SettingsHelperBuilder;
Expand All @@ -51,7 +53,9 @@
use Alma\PrestaShop\Helpers\ApiHelper;
use Alma\PrestaShop\Helpers\ApiKeyHelper;
use Alma\PrestaShop\Helpers\ClientHelper;
use Alma\PrestaShop\Helpers\CmsDataHelper;
use Alma\PrestaShop\Helpers\ConstantsHelper;
use Alma\PrestaShop\Helpers\ContextHelper;
use Alma\PrestaShop\Helpers\CustomFieldsHelper;
use Alma\PrestaShop\Helpers\MediaHelper;
use Alma\PrestaShop\Helpers\PriceHelper;
Expand All @@ -69,7 +73,7 @@ final class GetContentHookController extends AdminHookController
/** @var ApiKeyHelper */
private $apiKeyHelper;

/** @var Alma */
/** @var \Module */
protected $module;

/**
Expand Down Expand Up @@ -97,6 +101,11 @@ final class GetContentHookController extends AdminHookController
*/
protected $hasKey;

/**
* @var ContextHelper
*/
protected $contextHelper;

/**
* @var array
*/
Expand Down Expand Up @@ -178,6 +187,9 @@ public function __construct($module)
$mediaHelperBuilder = new MediaHelperBuilder();
$this->mediaHelper = $mediaHelperBuilder->getInstance();

$contextHelperBuilder = new ContextHelperBuilder();
$this->contextHelper = $contextHelperBuilder->getInstance();

$this->hasKey = false;

parent::__construct($module);
Expand Down Expand Up @@ -250,8 +262,8 @@ public function processConfiguration()
}

// Down here, we know the provided API keys are correct (at least the one for the chosen API mode)
$this->setKeyIfValueIsNotObscur($liveKey, ALMA_MODE_LIVE);
$this->setKeyIfValueIsNotObscur($testKey, ALMA_MODE_TEST);
$this->setKeyIfValueIsNotObscure($liveKey, ALMA_MODE_LIVE);
$this->setKeyIfValueIsNotObscure($testKey, ALMA_MODE_TEST);

// Try to get merchant from configured API key/mode
try {
Expand Down Expand Up @@ -421,20 +433,25 @@ public function processConfiguration()
return $credentialsError['message'];
}

if (IntegrationsConfigurationsUtils::isUrlRefreshRequired($this->settingsHelper->getKey(CmsDataHelper::ALMA_CMSDATA_DATE))) {
$this->apiHelper->sendUrlForGatherCmsData($this->contextHelper->getModuleLink('cmsdataexport', [], true));
$this->settingsHelper->updateKey(CmsDataHelper::ALMA_CMSDATA_DATE, time());
}

$this->context->smarty->clearAssign('validation_error');

return $this->module->display($this->module->file, 'getContent.tpl');
}

/**
* Check if Api key are obscur.
* Check if Api key are obscure.
*
* @param string $apiKey
* @param string $mode
*
* @return void
*/
private function setKeyIfValueIsNotObscur($apiKey, $mode)
private function setKeyIfValueIsNotObscure($apiKey, $mode)
{
if (ConstantsHelper::OBSCURE_VALUE === $apiKey) {
return;
Expand Down
33 changes: 33 additions & 0 deletions alma/exceptions/CmsDataException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* 2018-2024 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-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

namespace Alma\PrestaShop\Exceptions;

if (!defined('_PS_VERSION_')) {
exit;
}

class CmsDataException extends AlmaException
{
}
33 changes: 33 additions & 0 deletions alma/exceptions/ValidateException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* 2018-2024 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-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

namespace Alma\PrestaShop\Exceptions;

if (!defined('_PS_VERSION_')) {
exit;
}

class ValidateException extends AlmaException
{
}
5 changes: 4 additions & 1 deletion alma/lib/Builders/Helpers/SettingsHelperBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public function getInstance()
{
return new SettingsHelper(
$this->getShopHelper(),
$this->getConfigurationHelper()
$this->getConfigurationHelper(),
$this->getCategoryFactory(),
$this->getContextFactory(),
$this->getValidateHelper()
);
}
}
Loading