Skip to content

Commit

Permalink
Merge pull request #218 from alma/develop
Browse files Browse the repository at this point in the history
Release 3.0.3
  • Loading branch information
Benjamin-Freoua-Alma authored Sep 28, 2023
2 parents 8a816df + 00ecac6 commit d9f633f
Show file tree
Hide file tree
Showing 39 changed files with 423 additions and 448 deletions.
85 changes: 85 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
- id: detect-private-key
- id: check-merge-conflict

- repo: local
hooks:
- id: coding-standard-fixer
name: PHP and Prestashop coding standards Fixer test
language: script
entry: ./scripts/coding-standard-fixer.sh
stages: [commit]

- repo: local
hooks:
- id: coding-standard
name: Check the PHP and Prestashop coding standards
language: script
entry: ./scripts/coding-standard.sh
stages: [commit]

- repo: local
hooks:
- id: php-compatibility
name: Check the PHP compatibility
language: script
entry: ./scripts/php-compatibility.sh
stages: [commit]

# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.0-alpha.4
# hooks:
# - id: prettier
# files: "(^.*\\.js$)|(^pos/frontend/.*$)"

# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v8.29.0
# hooks:
# - id: eslint
# files: "(^dashboard/frontend/src/.*\\.[jt]sx?$)" # *.js, *.jsx, *.ts and *.tsx
# types: [file]
# args:
# - --fix

# - repo: https://github.com/thibaudcolas/pre-commit-stylelint
# rev: v14.16.0
# hooks:
# - id: stylelint
# files: "(^src/assets/css/.*\\.css$)|(^src/assets/widget/css/.*\\.css$)|(^.*\\.css$)"
# args:
# - --config
# - stylelint.config.cjs
# additional_dependencies:
# - [email protected]
# - [email protected]
# - [email protected]
# - [email protected]

- repo: https://github.com/returntocorp/semgrep
rev: v1.27.0
hooks:
- id: semgrep
args:
- --error
- --config
- semgrep/rules/
- --metrics
- "off"
- --quiet
- --disable-version-check
- --skip-unknown-extensions
pass_filenames: false # Passing files explicitely override semgremignore

- repo: https://github.com/alma/pre-commit-hooks
rev: 1.1.2
hooks:
- id: check-branch-name
args:
- "-r^((chore|ci|dependabot|devx|docs|feature|fix|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|HEAD)$$"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v3.0.3

- fix: Change event system for In-Page on Prestashop 1.7+
- fix: Issue modal In-Page on Prestashop before 16.0.12
- fix: Clear the partial refund amount after a partial refund
- fix: Issue error when merchant not allow to create payments

## v3.0.2

- fix: issue modal In-Page with jQuery noConflict
Expand Down
7 changes: 7 additions & 0 deletions alma/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v3.0.3

- fix: Change event system for In-Page on Prestashop 1.7+
- fix: Issue modal In-Page on Prestashop before 16.0.12
- fix: Clear the partial refund amount after a partial refund
- fix: Issue error when merchant not allow to create payments

## v3.0.2

- fix: issue modal In-Page with jQuery noConflict
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.0.2';
const VERSION = '3.0.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.0.2';
$this->version = '3.0.3';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function canRun()
* @param array $params
*
* @return void
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function run($params)
{
Expand Down
6 changes: 5 additions & 1 deletion alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,11 @@ private function credentialsError($liveKey, $testKey)

foreach ($modes as $mode) {
$key = (ALMA_MODE_LIVE == $mode ? $liveKey : $testKey);
if (!$key || ConstantsHelper::OBSCURE_VALUE === $key) {
if (
!$key
|| ConstantsHelper::OBSCURE_VALUE === $key
|| SettingsHelper::getActiveMode() !== $mode
) {
continue;
}

Expand Down
13 changes: 10 additions & 3 deletions alma/exceptions/ActivationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ class ActivationException extends AlmaException
*/
public function __construct($module)
{
$message = sprintf(
$module - l('Your Alma account needs to be activated before you can use Alma on your shop.<br>Go to your <a href="%1$s" target="_blank">Alma dashboard</a> to activate your account.<br><a href="#">Refresh</a> the page when ready.', 'ActivationException'),
LinkHelper::getAlmaDashboardUrl(SettingsHelper::getActiveMode(), 'settings')
$message = $module->l('Your Alma account needs to be activated before you can use Alma on your shop.', 'ActivationException')
. sprintf(
$module->l('Go to your %1$sAlma dashboard%2$s to activate your account.', 'ActivationException'),
'<a href="' . LinkHelper::getAlmaDashboardUrl(SettingsHelper::getActiveMode(), 'settings') . '" target="_blank">',
'</a>'
)
. sprintf(
$module->l('%1$sRefresh%2$s the page when ready.', 'ActivationException'),
'<a href="#">',
'</a>'
);

parent::__construct($message);
Expand Down
7 changes: 4 additions & 3 deletions alma/exceptions/WrongCredentialsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class WrongCredentialsException extends AlmaException
*/
public function __construct($module)
{
$message = sprintf(
$module->l('Could not connect to Alma using your API keys.<br>Please double check your keys on your %s Alma dashboard %s.', 'WrongCredentialsException'),
sprintf('<a href="%1$s" target="_blank">', LinkHelper::getAlmaDashboardUrl(SettingsHelper::getActiveMode(), 'api')),
$message = $module->l('Could not connect to Alma using your API keys.', 'WrongCredentialsException')
. sprintf(
$module->l('Please double check your keys on your %1$sAlma dashboard%2$s.', 'WrongCredentialsException'),
'<a href="' . LinkHelper::getAlmaDashboardUrl(SettingsHelper::getActiveMode(), 'api') . '" target="_blank">',
'</a>'
);

Expand Down
12 changes: 12 additions & 0 deletions alma/lib/Helpers/DateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,16 @@ protected static function getFrenchDateFormat($timestamp)

return $date->format('d/m/Y');
}

/**
* @param string|int $timestamp
*
* @return bool
*/
public static function isValidTimeStamp($timestamp)
{
return ((string) (int) $timestamp === $timestamp)
&& ($timestamp <= PHP_INT_MAX)
&& ($timestamp >= ~PHP_INT_MAX);
}
}
1 change: 0 additions & 1 deletion alma/lib/Helpers/HookHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public function __construct()
'moduleRoutes' => 'all',
'actionAdminControllerInitBefore' => 'all',
'header' => 'all',
'Header' => 'all',
'displayHeader' => 'all',
'displayBackOfficeHeader' => 'all',
'displayShoppingCartFooter' => 'all',
Expand Down
5 changes: 5 additions & 0 deletions alma/lib/Helpers/OrderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function __construct()
* @param string $endDate
*
* @return \Order[]
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function getOrdersByDate($startDate, $endDate)
{
Expand All @@ -87,6 +90,8 @@ public function getOrdersByDate($startDate, $endDate)
* @param string $endDate
*
* @return array
*
* @throws \PrestaShopDatabaseException
*/
public function getOrdersIdByDate($startDate, $endDate)
{
Expand Down
19 changes: 16 additions & 3 deletions alma/lib/Helpers/ShareOfCheckoutHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ public function __construct($orderHelper)

/**
* @return bool
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function shareDays()
{
$shareOfCheckoutEnabledDate = $this->getEnabledDate();
if (
ShareOfCheckoutAdminFormBuilder::ALMA_SHARE_OF_CHECKOUT_CONSENT_NO === SettingsHelper::getShareOfCheckoutStatus()
|| empty($shareOfCheckoutEnabledDate)
|| !DateHelper::isValidTimeStamp($shareOfCheckoutEnabledDate)
) {
Logger::instance()->info('Share Of Checkout is disabled or invalide date');

Expand All @@ -102,6 +106,9 @@ public function shareDays()
* Put Payload to Share of Checkout.
*
* @return void
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function putDay()
{
Expand Down Expand Up @@ -152,6 +159,9 @@ public function getStartShareOfCheckout()
* Total Orders to send.
*
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function getTotalOrders()
{
Expand Down Expand Up @@ -437,7 +447,7 @@ private function getEndDateTime()
*
* @param string $id
*
* @return string
* @return array|bool|object|string|null
*/
private function getIsoCodeById($id)
{
Expand All @@ -453,6 +463,9 @@ private function getIsoCodeById($id)
* Payload Share of Checkout.
*
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function getPayload()
{
Expand All @@ -467,15 +480,15 @@ public function getPayload()
/**
* @return string|false
*/
protected function getEnabledDate()
public function getEnabledDate()
{
return \Configuration::get(ShareOfCheckoutAdminFormBuilder::ALMA_SHARE_OF_CHECKOUT_DATE);
}

/**
* @return array
*/
protected function getDatesInInterval($lastShareOfCheckout, $shareOfCheckoutEnabledDate)
public function getDatesInInterval($lastShareOfCheckout, $shareOfCheckoutEnabledDate)
{
return DateHelper::getDatesInInterval($lastShareOfCheckout, $shareOfCheckoutEnabledDate);
}
Expand Down
2 changes: 1 addition & 1 deletion alma/lib/Traits/AjaxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ protected function renderAndExit($value = null, $controller = null, $method = nu
*/
protected function ajaxRenderBefore16012($value)
{
exit(\Tools::jsonEncode($value));
exit($value);
}
}
9 changes: 2 additions & 7 deletions alma/phpunit.ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
stopOnFailure = "true">

<testsuites>
<testsuite name="Alma Installment Prestashop Unit Test Suite">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Alma Installment Prestashop Integration Test Suite">
<directory>tests/integration</directory>
<testsuite name="Alma Installment Prestashop Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

Expand Down
9 changes: 2 additions & 7 deletions alma/phpunit.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
stopOnFailure = "false">

<testsuites>
<testsuite name="Alma Installment Prestashop Unit Test Suite">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Alma Installment Prestashop Integration Test Suite">
<directory>tests/integration</directory>
<testsuite name="Alma Installment Prestashop Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
Expand Down
12 changes: 1 addition & 11 deletions alma/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,5 @@ cd modules/alma/

to launch test :
```
./vendor/bin/phpunit
```

to launch integration test :
```
./vendor/bin/phpunit --testsuite 'Alma Installment Prestashop Integration Test Suite'
```

to launch unit test :
```
./vendor/bin/phpunit --testsuite 'Alma Installment Prestashop Unit Test Suite'
./vendor/bin/phpunit -c phpunit.ci.xml
```
Loading

0 comments on commit d9f633f

Please sign in to comment.