QuestionQ4

Design and implement optimal solutions for Adobe Commerce to meet business needs

While 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:

Question Image

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

Question Image

The Architect must recommend an optimal approach to eliminate redundant dependencies and duplicated code across the methods.

Which solution should the Architect recommend?

Explanation

A shared payment gateway configuration base class centralizes retrieval and decryption of the encrypted user_secret. Its payment-method-specific subclasses inherit that behavior and no longer need to declare the repeated scope-config and encryptor dependencies themselves. A virtual type of the generic payment config class does not implement secret decryption, and a plugin on the general configuration getter would apply cross-cutting behavior based on a generic field name rather than encapsulating the payment configuration concern.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!