Skip to content

PRE-3606: Show the Scalapay installment widget - #342

Merged
ilajili merged 1 commit into
developfrom
feature/PRE-3606_scalapay-installment-widget
Nov 24, 2026
Merged

ilajili merged 1 commit into
developfrom
feature/PRE-3606_scalapay-installment-widget

Conversation

@ilajili

@ilajili ilajili commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Description

Shows the Scalapay installment widget (v5) on the product page, the cart page and the checkout, as
the ticket asks, with the exact script and element Scalapay provides (CCD2): nothing is altered,
hidden or moved, and the plugin adds no text next to it.

  • The merchant token comes from PayPlug getAccount (payment_methods.scalapay.merchant_token,
    CORP-54617). It is stored with the PPRO limits of the method by PproConfigurationRefresher and
    read from there when a page is displayed: no API call on the shop pages. No token (Scalapay not
    enabled) or a token fetched in the other mode (test/live) means no widget.
  • Per-page toggles and CSS amount selectors are set in the Scalapay widget block of the Scalapay
    payment method page (gateway config key scalapay_widget, form extension
    ScalapayWidgetTypeExtension). Defaults match the Sylius 2 default theme.
  • Eligibility reuses PproEligibilityChecker (PRE-3677: amount range, billing country). The widget
    needs the channel base currency and the displayed currency to be EUR.
  • The environment attribute follows the PayPlug platform, not the gateway mode:
    PAYPLUG_OAUTH_BASE_URL unset or the production platform -> no attribute (Scalapay production
    token); any other URL (QA) -> environment="integration" (Scalapay sandbox token). A shop
    connected to the QA platform must set PAYPLUG_OAUTH_BASE_URL.
  • The checkout widget is rendered right under the Scalapay payment method card, outside its
    <label>, through the Sylius hook sylius_shop.shared.form.select_payment.payment.choice.payplug_scalapay
    (a click on the widget must not select the method).

Motivation: PRE-3606, Scalapay widget in the Sylius plugin.

Related issue(s): PRE-3606

Type of Change

  • ✨ New feature (non-breaking change that adds functionality) [x]

BC note: templates/shared/form/select_payment/payment/choice.html.twig (plugin override) now
renders the choice.<factory> hooks like Sylius does from 2.0.8, so a hook registered on that name
is displayed. See UPGRADE.md.


Checklist

Code Quality

  • Code is linted and formatted
  • No unnecessary commented-out code or debug logs
  • No hardcoded values (use env variables or config) — two on purpose: the Scalapay v5 script URL
    (imposed by the ticket, CCD2) and the production host api.payplug.com in
    ScalapayWidgetEnvironment, the reference of the environment rule. A test checks it against
    payplug.oauth_base_url.default of services.yaml.

Testing

  • Unit tests added / updated (full PHPUnit suite: 1304 tests green)
  • New/changed code is covered by tests — to be confirmed by the sonarcloud job

Security & Ops

  • No sensitive data or secrets introduced (the token is never written in the code)
  • Logging and error handling are appropriate


Testing notes

Validated manually in sandbox (QA platform, integration token): the widget shows on the product,
cart and checkout pages, follows variant/quantity/coupon changes, and a click on the checkout
widget does not select the method.

Reviewer note (out of scope): templates/shop/integrated/index.html.twig hard-codes
cdn-qa.payplug.com. Not touched here.

@ilajili ilajili self-assigned this Nov 23, 2026
@ilajili
ilajili force-pushed the feature/PRE-3606_scalapay-installment-widget branch from abb8499 to ad21296 Compare November 23, 2026 14:24

@jhoaraupp jhoaraupp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review de ad21296 (re-review de abb8499, après l'amend « widget désactivé par défaut »).

Verdict : approuvable en l'état. Aucun point Blocking ni Medium. Les 4 points Low et le nit ci-dessous peuvent partir dans un ticket de suivi.

Widget désactivé par défaut (demande PM) : OK. ScalapayWidgetSettings::withDefaults() met enabled: false sur les pages sans réglage, en gardant le sélecteur par défaut pré-rempli. Tant qu'une page est désactivée, amountSelector() renvoie null et isScriptRequired() renvoie false : pas de widget, et pas de script Scalapay dans le <head>. Le nouveau test testNoWidgetOnAnyPageUntilTheMerchantTurnsItOn couvre les trois pages et le script. CHANGELOG, README, UPGRADE (point 2) et doc/scalapay_widget.md sont à jour. La 2.0.0 n'étant pas sortie, aucune config existante ne peut avoir enabled: true stocké, donc pas de migration à prévoir.

Checks lancés sur ad21296 (worktree, PHP 8.2, composer install) :

  • PHPUnit vendor/bin/phpunit tests/PHPUnit : exit 0, 1305 tests, 3087 assertions
  • PHPStan vendor/bin/phpstan analyse src -c ruleset/phpstan.neon : exit 0
  • ECS vendor/bin/ecs check -c ruleset/ecs.php : exit 0
  • Behat : non lancé (pas de base de test)

À garder : aucun appel API côté boutique (token stocké avec les limites PPRO, contrôlé TEST/LIVE, effacé au logout). Double défense sur les attributs : liste blanche et équilibre des délimiteurs pour les sélecteurs, regex pour le token, puis json_encode et autoescape Twig. Script chargé indépendamment du montant, pour suivre les changements de variante, quantité ou coupon. Bonne couverture de tests.

Comment thread src/Scalapay/ScalapayWidgetResolver.php Resolved
Comment thread src/Twig/ScalapayWidgetExtension.php Resolved
Comment thread translations/messages.fr.yml Resolved
Comment thread UPGRADE.md Resolved
@ilajili
ilajili force-pushed the feature/PRE-3606_scalapay-installment-widget branch from ad21296 to e02bd47 Compare November 23, 2026 15:58
@ilajili
ilajili force-pushed the feature/PRE-3606_scalapay-installment-widget branch from e02bd47 to aedc58c Compare November 24, 2026 13:21
@ilajili
ilajili merged commit 87cb249 into develop Nov 24, 2026
12 of 13 checks passed
@ilajili
ilajili deleted the feature/PRE-3606_scalapay-installment-widget branch November 24, 2026 13:32

@adumont-payplug adumont-payplug left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of PR 342 at aedc58c. Verdict: approve after the documentation move. No blocking issue.

Checks run on this head (PHP 8.2.30, vendor in sync with composer.lock): PHPUnit tests/PHPUnit exit 0 (1308 tests, 3100 assertions), PHPStan level max exit 0, ECS exit 0. Behat not run (test application database absent).

The five earlier threads are resolved and hold at head; the memoisation point (ScalapayWidgetResolver.php:93) was declined with a reasoned answer and is not raised again.

Checked and fine: selector validation and HTML/JSON escaping (no injection path), fail-closed behaviour (no token, non-EUR channel or display currency, ineligible amount or country), token tied to the payment method shown, token cleared on logout, translation key and placeholder parity across en/fr/it, off by default.

Not anchorable: nothing.

Comment thread doc/scalapay_widget.md
@@ -0,0 +1,69 @@
# Scalapay widget

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: the Scalapay documentation should live in the GitHub wiki, not in the repo.

Move the operator-facing content of this file (when the widget shows, selectors, environment rules, how to check a page) to a wiki page. Keep in UPGRADE.md only what a merchant must do on upgrade (payplug:ppro:refresh, custom-theme selectors, PAYPLUG_OAUTH_BASE_URL, the BC table). Then drop this file and replace the README section with a wiki link.

Comment thread README.md
Comment on lines +224 to +226
## Scalapay widget

The Scalapay installment widget can be shown on the product page, the cart page and at checkout once the merchant turns it on (it is off by default). You can check the [Scalapay widget documentation](doc/scalapay_widget.md).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (same point): this section links doc/scalapay_widget.md; it should link the wiki page once the documentation is moved there.

Comment on lines +10 to +11
{% set method = form.method.vars.choices[key].data %}
{% hook ['choice.' ~ method.gatewayConfig.factoryName, 'choice'] with {'parent_form': form, 'form': choice_form, 'method': method} %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: method.gatewayConfig.factoryName is read for every method. A method with no gateway config would raise under Twig strict_variables (dev) and build the hook name choice.. Sylius admin always creates one, so it is unlikely, but method.gatewayConfig.factoryName|default('') (or a null check) makes it safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants