Skip to content

Save Manual Capture dependent config in the scope of the field - #6

Open
lbajsarowicz wants to merge 1 commit into
MultiSafepay:masterfrom
lbajsarowicz:fix/manual-capture-config-scope
Open

lbajsarowicz wants to merge 1 commit into
MultiSafepay:masterfrom
lbajsarowicz:fix/manual-capture-config-scope

Conversation

@lbajsarowicz

@lbajsarowicz lbajsarowicz commented Nov 15, 2026 •

Copy link
Copy Markdown

Problem

The Manual Capture field of the credit card, Visa, Mastercard and Maestro gateways is available in website and store scope, but ManualCapture::saveValue() calls the config writer without a scope. The dependent payment_action value and the *_recurring and *_vault manual_capture values are therefore always written to the default scope, so toggling Manual Capture for one website changes the payment action for every website.

Fix

saveValue() passes $this->getScope() and $this->getScopeId() to the writer, the same way Vault::afterSave() already does.
ManualCapture also gets an afterDelete() that removes the dependent rows from the website or store scope when the field is set back to "Use Default", so they do not stay behind and keep authorizing only.

Why this approach

The backend model is saved with the scope of the field being edited, so reusing that scope keeps the dependent values next to the field that triggered them and needs no new state or configuration.

Upgrade note

Shops that already saved Manual Capture at website or store scope on 4.4.1 or older still have payment_action, *_recurring and *_vault rows in the default scope that affect every website. Re-save the setting at the intended scope to correct them. This PR contains no migration.

Test plan

  • Added testAfterSaveWritesAtTheScopeOfTheField, testAfterSaveWritesAtTheDefaultScope, testAfterDeleteRemovesDependentValuesFromTheScope and testAfterDeleteKeepsDefaultScopeValues to Test/Integration/Model/Config/Backend/ManualCaptureTest.php.
  • Ran the class on PHP 8.5 against Magento 2.4.9 with mocked context: the website-scope test fails before the change ('websites' expected, 'default' written) and all 8 tests pass after it.
  • phpcs with the repository phpcs.xml reports no violations on the changed files.
  • bin/magento setup:di:compile and setup:static-content:deploy -f en_US on Magento Open Source 2.4.9 / PHP 8.5 with this branch installed: both pass.

ManualCapture::saveValue() passed no scope to the config writer, so
payment_action and the *_recurring and *_vault manual_capture values were
always written to the default scope, even when the field was saved for a
website or store. Pass the scope and scope id of the field, as Vault does.
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