Skip to content

Commit

Permalink
Merge pull request #602 from alma/release/v4.5.0
Browse files Browse the repository at this point in the history
Release v4.5.0
  • Loading branch information
Benjamin-Freoua-Alma authored Nov 18, 2024
2 parents d0fd812 + dd24dfa commit cabafce
Show file tree
Hide file tree
Showing 36 changed files with 662 additions and 417 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backport-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

create-backport-pull-request:
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release')) }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

lint-and-test:

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
Expand All @@ -25,6 +25,11 @@ jobs:
version: 3.x
repo-token: ${{ github.token }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-post-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:

e2e-post-results:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
launch:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'hotfix')

strategy:
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
repositories: integration-infrastructure

- name: Trigger E2E tests in the integration-infrastructure repository
uses: codex-/return-dispatch@v1
uses: codex-/return-dispatch@v2
id: e2e-tests-workflow-dispatch
with:
token: ${{ steps.github-token-infrastructure.outputs.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hotfix-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:

create-hotfix-pull-request:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
contents: read
pull-requests: write

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: TimonVS/pr-labeler-action@v5
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

release:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:

create-release-pull-request:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.0
rev: v3.30.1
hooks:
- id: commitizen
name: Check commit message format
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
stages: [commit]

- repo: https://github.com/returntocorp/semgrep
rev: v1.87.0
rev: v1.96.0
hooks:
- id: semgrep
args:
Expand All @@ -58,4 +58,4 @@ repos:
hooks:
- id: check-branch-name
args:
- "-r^((chore|ci|dependabot|devx|docs|feature|fix|release|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|develop|HEAD)$$"
- "-r^((chore|ci|dependabot|devx|renovate|docs|feature|fix|release|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|develop|HEAD)$$"
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## v4.5.0 - 2024-11-13

### Changes

### 🚀 New Features

- feat: add inpage setting for selector payment buttons (#581)

### 🐛 Bug Fixes

- fix: Update wording for In-Page advanced feature (#594)
- fix: Prevent crash when there is not quantity input on product page for insurance (#598)
- fix: issue with some translation in payment buttons (#593)

#### Contributors

@Benjamin-Freoua-Alma, @alma-renovate-bot, @alma-renovate-bot[bot], @carine-bonnafous, @github-actions and @olance

## v4.4.1 - 2024-10-30

### 🐛 Bug Fixes
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.4.1';
const VERSION = '4.5.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.4.1';
$this->version = '4.5.0';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public function run($params)
? $productParams['id_product_attribute']
: null;

$quantityWanted = isset($productParams['quantity_wanted']) ? $productParams['quantity_wanted'] : 1;

$cmsReference = $this->insuranceHelper->createCmsReference($productId, $productAttributeId);

$staticPrice = $this->productHelper->getPriceStatic($productId, $productAttributeId);
Expand All @@ -132,11 +134,12 @@ public function run($params)
'productDetails' => $this->handleProductDetails($params),
'settingsInsurance' => $this->handleSettings($merchantId),
'iframeUrl' => sprintf(
'%s%s?cms_reference=%s&product_price=%s&product_name=%s&merchant_id=%s&customer_session_id=%s&cart_id=%s',
'%s%s?cms_reference=%s&product_price=%s&product_quantity=%s&product_name=%s&merchant_id=%s&customer_session_id=%s&cart_id=%s',
$this->adminInsuranceHelper->envUrl(),
ConstantsHelper::FO_IFRAME_WIDGET_INSURANCE_PATH,
$cmsReference,
$staticPriceInCents,
$quantityWanted,
$productName,
$merchantId,
$this->context->cookie->checksum,
Expand Down
12 changes: 12 additions & 0 deletions alma/controllers/hook/FrontHeaderHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,20 @@ private function assetsInPage()
$this->controller->unregisterJavascript(ConstantsHelper::WIDGETS_JS_ID);
}
}

$content .= $this->almaInPageHeader();
}

return $content;
}

/**
* @return string
*/
protected function almaInPageHeader()
{
$settings = json_encode($this->settingsHelper->getInPageSettings());

return "<div id='alma-inpage-global' data-settings='{$settings}'></div>";
}
}
4 changes: 4 additions & 0 deletions alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ final class GetContentHookController extends AdminHookController
'action' => 'cast_bool',
'suffix' => '_ON',
],
InpageAdminFormBuilder::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR => 'none',
InpageAdminFormBuilder::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR => 'none',
'ALMA_ACTIVATE_LOGGING' => [
'action' => 'cast_bool',
'suffix' => '_ON',
Expand Down Expand Up @@ -709,6 +711,8 @@ protected function getFieldsValueForForm()
PaymentButtonAdminFormBuilder::ALMA_PNX_AIR_BUTTON_DESC
),
InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE . '_ON' => $this->settingsHelper->isInPageEnabled(),
InpageAdminFormBuilder::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR => $this->settingsHelper->getKey(InpageAdminFormBuilder::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR, InpageAdminFormBuilder::ALMA_INPAGE_DEFAULT_VALUE_PAYMENT_BUTTON_SELECTOR),
InpageAdminFormBuilder::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR => $this->settingsHelper->getKey(InpageAdminFormBuilder::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR, InpageAdminFormBuilder::ALMA_INPAGE_DEFAULT_VALUE_PLACE_ORDER_BUTTON_SELECTOR),
'ALMA_SHOW_DISABLED_BUTTON' => SettingsHelper::showDisabledButton(),
'ALMA_SHOW_ELIGIBILITY_MESSAGE_ON' => SettingsHelper::showEligibilityMessage(),
'ALMA_CART_WDGT_NOT_ELGBL_ON' => SettingsHelper::showCartWidgetIfNotEligible(),
Expand Down
26 changes: 25 additions & 1 deletion alma/lib/Forms/InpageAdminFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
class InpageAdminFormBuilder extends AbstractAlmaAdminFormBuilder
{
const ALMA_ACTIVATE_INPAGE = 'ALMA_ACTIVATE_INPAGE';
const ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR = 'ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR';
const ALMA_INPAGE_DEFAULT_VALUE_PAYMENT_BUTTON_SELECTOR = '[data-module-name=alma]';
const ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR = 'ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR';
const ALMA_INPAGE_DEFAULT_VALUE_PLACE_ORDER_BUTTON_SELECTOR = '#payment-confirmation button';

/**
* @return array
Expand All @@ -44,9 +48,29 @@ protected function configForm()
$this->inputAlmaSwitchForm(
self::ALMA_ACTIVATE_INPAGE,
$this->module->l('Activate in-page checkout', 'InpageAdminFormBuilder'),
$this->module->l('Activate in-page checkout for Pay Now, P2X, P3X and P4X', 'InpageAdminFormBuilder'),
$this->module->l('Activate in-page checkout for all Alma payment methods', 'InpageAdminFormBuilder'),
$this->module->l('The checkout in-page in your own website', 'InpageAdminFormBuilder')
),
$this->inputTextForm(
self::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR,
$this->module->l('Input payment button Alma selector', 'InpageAdminFormBuilder'),
sprintf(
$this->module->l('%1$sAdvanced%2$s [Optional] CSS selector used by our scripts to identify the Alma payment button', 'InpageAdminFormBuilder'),
'<b>',
'</b>'
),
$this->module->l('E.g. #id, .class, ...', 'InpageAdminFormBuilder')
),
$this->inputTextForm(
self::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR,
$this->module->l('Place order button selector', 'InpageAdminFormBuilder'),
sprintf(
$this->module->l('%1$sAdvanced%2$s [Optional] CSS selector used by our scripts to identify the payment confirmation button', 'InpageAdminFormBuilder'),
'<b>',
'</b>'
),
$this->module->l('E.g. #id, .class, ...', 'InpageAdminFormBuilder')
),
];
}

Expand Down
2 changes: 1 addition & 1 deletion alma/lib/Helpers/PaymentOptionTemplateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function buildTemplateVar(

if ($isDeferred) {
$templateVar['installmentText'] = sprintf(
$this->translationHelper->getTranslation('0 € today then %1$s on %2$s', 'PaymentOptionsHookController'),
$this->translationHelper->l('0 € today then %1$s on %2$s', 'PaymentOptionTemplateHelper'),
$this->priceHelper->formatPriceToCentsByCurrencyId(
$plans[0]['purchase_amount'] + $plans[0]['customer_fee']
),
Expand Down
6 changes: 3 additions & 3 deletions alma/lib/Helpers/PlanHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,18 @@ public function buildDates($plans, $locale, $feePlans, $key, $isPayNow)
$plans[$keyPlan]['human_date'] = $this->dateHelper->getDateFormat($locale, $paymentPlan['due_date']);

if (0 === $keyPlan) {
$plans[$keyPlan]['human_date'] = $this->translationHelper->getTranslation('Today', 'PaymentService');
$plans[$keyPlan]['human_date'] = $this->translationHelper->l('Today', 'PlanHelper');
continue;
}

if ($isPayNow) {
$plans[$keyPlan]['human_date'] = $this->translationHelper->getTranslation('Total', 'PaymentService');
$plans[$keyPlan]['human_date'] = $this->translationHelper->l('Total', 'PlanHelper');
continue;
}

if ($this->settingsHelper->isDeferredTriggerLimitDays($feePlans, $key)) {
$plans[$keyPlan]['human_date'] = sprintf(
$this->translationHelper->getTranslation('%s month later', 'PaymentService'),
$this->translationHelper->l('%s month later', 'PaymentService'),
$keyPlan
);

Expand Down
14 changes: 14 additions & 0 deletions alma/lib/Helpers/SettingsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public static function deleteAllValues()
PaymentButtonAdminFormBuilder::ALMA_PNX_AIR_BUTTON_DESC,
ExcludedCategoryAdminFormBuilder::ALMA_NOT_ELIGIBLE_CATEGORIES,
InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE,
InpageAdminFormBuilder::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR,
InpageAdminFormBuilder::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR,
'ALMA_STATE_REFUND',
'ALMA_STATE_REFUND_ENABLED',
'ALMA_STATE_TRIGGER',
Expand Down Expand Up @@ -496,6 +498,18 @@ public function isInPageEnabled()
return (bool) (int) $this->getKey(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, false);
}

/**
* @return array
*/
public function getInPageSettings()
{
return [
'enabled' => $this->isInPageEnabled(),
'paymentButtonSelector' => $this->getKey(InpageAdminFormBuilder::ALMA_INPAGE_PAYMENT_BUTTON_SELECTOR, InpageAdminFormBuilder::ALMA_INPAGE_DEFAULT_VALUE_PAYMENT_BUTTON_SELECTOR),
'placeOrderButtonSelector' => $this->getKey(InpageAdminFormBuilder::ALMA_INPAGE_PLACE_ORDER_BUTTON_SELECTOR, InpageAdminFormBuilder::ALMA_INPAGE_DEFAULT_VALUE_PLACE_ORDER_BUTTON_SELECTOR),
];
}

/**
* Return activated plans.
*
Expand Down
2 changes: 1 addition & 1 deletion alma/lib/Helpers/TranslationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct($moduleFactory)
*
* @return mixed
*/
public function getTranslation($string, $file)
public function l($string, $file)
{
return $this->module->l($string, $file);
}
Expand Down
4 changes: 2 additions & 2 deletions alma/tests/Unit/Helper/PaymentOptionTemplateHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testBuildTemplateVarNoDeferredPlan()
$this->settingsHelperMock->shouldReceive('getModeActive')->andReturn('test');
$this->settingsHelperMock->shouldReceive('getIdMerchant')->andReturn('merchantId');
$this->configurationHelperMock->shouldReceive('isInPageEnabled')->andReturn(true);
$this->translationHelperMock->shouldReceive('getTranslation')->andReturn('My translation');
$this->translationHelperMock->shouldReceive('l')->andReturn('My translation');
$this->priceHelperMock->shouldReceive('formatPriceToCentsByCurrencyId')->andReturn('110.00');
$this->dateHelperMock->shouldReceive('getDateFormat')->andReturn('22/05/2024');

Expand Down Expand Up @@ -163,7 +163,7 @@ public function testBuildTemplateVarDeferredPlan()
$this->settingsHelperMock->shouldReceive('getModeActive')->andReturn('test');
$this->settingsHelperMock->shouldReceive('getIdMerchant')->andReturn('merchantId');
$this->configurationHelperMock->shouldReceive('isInPageEnabled')->andReturn(true);
$this->translationHelperMock->shouldReceive('getTranslation')->andReturn('My translation');
$this->translationHelperMock->shouldReceive('l')->andReturn('My translation');
$this->priceHelperMock->shouldReceive('formatPriceToCentsByCurrencyId')->andReturn('110.00');
$this->dateHelperMock->shouldReceive('getDateFormat')->andReturn('22/05/2024');

Expand Down
Loading

0 comments on commit cabafce

Please sign in to comment.