Repository navigation
PRE-3606: Show the Scalapay installment widget - #342
Conversation
abb8499 to
ad21296
Compare
jhoaraupp
left a comment
There was a problem hiding this comment.
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.
ad21296 to
e02bd47
Compare
e02bd47 to
aedc58c
Compare
adumont-payplug
left a comment
There was a problem hiding this comment.
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.
| @@ -0,0 +1,69 @@ | |||
| # Scalapay widget | |||
There was a problem hiding this comment.
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.
| ## 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). |
There was a problem hiding this comment.
Medium (same point): this section links doc/scalapay_widget.md; it should link the wiki page once the documentation is moved there.
| {% set method = form.method.vars.choices[key].data %} | ||
| {% hook ['choice.' ~ method.gatewayConfig.factoryName, 'choice'] with {'parent_form': form, 'form': choice_form, 'method': method} %} |
There was a problem hiding this comment.
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.
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.
getAccount(payment_methods.scalapay.merchant_token,CORP-54617). It is stored with the PPRO limits of the method by
PproConfigurationRefresherandread 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.
payment method page (gateway config key
scalapay_widget, form extensionScalapayWidgetTypeExtension). Defaults match the Sylius 2 default theme.PproEligibilityChecker(PRE-3677: amount range, billing country). The widgetneeds the channel base currency and the displayed currency to be EUR.
environmentattribute follows the PayPlug platform, not the gateway mode:PAYPLUG_OAUTH_BASE_URLunset or the production platform -> no attribute (Scalapay productiontoken); any other URL (QA) ->
environment="integration"(Scalapay sandbox token). A shopconnected to the QA platform must set
PAYPLUG_OAUTH_BASE_URL.<label>, through the Sylius hooksylius_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
BC note:
templates/shared/form/select_payment/payment/choice.html.twig(plugin override) nowrenders the
choice.<factory>hooks like Sylius does from 2.0.8, so a hook registered on that nameis displayed. See UPGRADE.md.
Checklist
Code Quality
(imposed by the ticket, CCD2) and the production host
api.payplug.cominScalapayWidgetEnvironment, the reference of the environment rule. A test checks it againstpayplug.oauth_base_url.defaultofservices.yaml.Testing
sonarcloudjobSecurity & Ops
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.twighard-codescdn-qa.payplug.com. Not touched here.