Skip to content

PRE-3682: scope API client creation to the payment method - #325

Merged
adumont-payplug merged 1 commit into
feature/PRE-3440_multi_shop_configurationfrom
fix/PRE-3682_scope_client_to_payment_method
Sep 15, 2026
Merged

adumont-payplug merged 1 commit into
feature/PRE-3440_multi_shop_configurationfrom
fix/PRE-3682_scope_client_to_payment_method

Conversation

@adumont-payplug

@adumont-payplug adumont-payplug commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Description

PayPlugApiClientFactory::create(string $factoryName) resolves its gateway config with
findOneBy(['factoryName' => $factoryName]). Since PRE-3628 several enabled GatewayConfig
rows may share a factoryName — one per channel — so Doctrine returns an arbitrary one and the
plugin can sign a request for channel A with channel B's account credentials.

This PR routes the remaining direct callers through the correctly-scoped
createForPaymentMethod(PaymentMethodInterface) and removes create() from
PayPlugApiClientFactoryInterface, so the compiler — not review — is the guard against the
ambiguous path being reintroduced.

  • IpnAction and IntegratedPaymentController now use createForPaymentMethod(). The latter
    also moved off the concrete final PayPlugApiClientFactory type-hint, which made it untestable.
  • Five further classes type-hinted the concrete factory and would have leaked straight past the
    new guard (OneClickAction, PaymentStateResolver, CaptureAuthorizedPaymentProcessor,
    IsOneyEnabledValidator, PayplugPermissionValidator). All already called
    createForPaymentMethod(), so they now depend on the interface. lint:container passes.
  • SupportedMethodsProvider's two resolvers take the GatewayConfigInterface instead of the
    ambient $factoryName; shared suffix logic extracted into paymentMethodKey().
  • The Behat mocker implements the new interface.

Not included — create() stays on the concrete class, marked @internal. The ticket assumed
4 call sites; there are 7 more, reaching it through the payplug_sylius_payplug_plugin.api_client.*
singletons in client.xml (<factory … method="create"/>), #[Autowire]d into OneyChecker,
CardController, OneyRulesExtension, ShowMeaExtension, OneySimulationDataProvider,
ApplePayPaymentProvider and RefundUnitsCommandCreatorDecorator. Three of them have no payment
method in scope at all and need a design decision, so that half stays open on PRE-3682.
CLAUDE.md described these singletons as dead wiring; corrected here, and PRE-3684 corrected too.

⚠️ Base branch: stacked on fix/PRE-3683_per_config_account_memo, not develop — PRE-3683
already removed the SupportedMethodsProvider create() calls this PR builds on.

Motivation: a cross-channel credential leak — a multi-boutique merchant's payment can be
created, captured or refunded against another channel's PayPlug account.

Related issue(s): PRE-3682 — do not auto-close, one criterion stays open (see above).


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 💥 Breaking change (fix or feature that causes existing functionality to change and that could impact other libs)
  • 🔒 Security fix

Checklist

Code Quality

  • Code is linted and formatted
  • No unnecessary commented-out code or debug logs
  • No hardcoded values (use env variables or config)

Testing

  • Unit tests added / updated
  • New/changed code is covered by tests — SonarCloud Quality Gate (coverage on new code) passes on the sonarcloud CI job

Security & Ops

  • No sensitive data or secrets introduced
  • Logging and error handling are appropriate

@adumont-payplug
adumont-payplug added this pull request to stack #326 September 14, 2026 15:20
@adumont-payplug
adumont-payplug force-pushed the fix/PRE-3682_scope_client_to_payment_method branch from a28640f to 35ba028 Compare September 14, 2026 15:23
@adumont-payplug
adumont-payplug removed this pull request from stack #326 September 15, 2026 08:15
@adumont-payplug
adumont-payplug added this pull request to stack #328 September 15, 2026 08:17
Base automatically changed from fix/PRE-3683_per_config_account_memo to feature/PRE-3440_multi_shop_configuration September 15, 2026 08:17
@adumont-payplug
adumont-payplug force-pushed the fix/PRE-3682_scope_client_to_payment_method branch from 35ba028 to 104e6b6 Compare September 15, 2026 08:17

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.

Tip: disable this comment in your organization's Code Review settings.

@adumont-payplug
adumont-payplug merged commit f7fe9a3 into feature/PRE-3440_multi_shop_configuration Sep 15, 2026
5 of 6 checks passed
@adumont-payplug
adumont-payplug deleted the fix/PRE-3682_scope_client_to_payment_method branch September 15, 2026 08:19
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.

1 participant