QuestionQ4
Design and implement optimal solutions for Adobe Commerce to meet business needsWhile reviewing a newly created pull request that refactors several custom payment methods, the Architect observes that multiple classes rely on \Magento\Framework\Encryption\EncryptorInterface to decrypt sensitive credential data. The commonly duplicated code is:

In every module, the user_secret configuration is declared as follows:

The Architect must recommend an optimal approach to eliminate redundant dependencies and duplicated code across the methods.
Which solution should the Architect recommend?
- A Create a common config service class Vendor\Payment\Gateway\Config\Config under Vendor_Payment and use it as a parent class for all of the Vendor\PaymentModule\Gateway\Config\Config classes and remove $scopeConfig and $encryptor dependencies
- B Replace all Vendor\PaymentModule\Gateway\Config\Config classes with virtualType of Magento\Payment\Gateway\Config\Config and set <user_secret backend_model=“Magento\Config\Model\Config\Backend\Encrypted” /> under config.xml
- C Add a plugin after the getValue method of $scopeConfig, remove the $encryptor from dependency and use it in the plugin to decrypt the value if the config name is ‘user_secret’
Community Discussion