QuestionQ8

Orders, Payments, Shipping, and Tax

An Adobe Commerce Architect receives a request to modify existing payment-gateway functionality so that voided transactions are allowed only for a specified range of paid amounts.

In the vendor module file etc/config.xml, the payment method has the can_void option set to 1.

How should this customization be implemented?

  • A Extend Magento\Payment\Model\Method\Adapter and reimplement method void. Use this new class as a new type of payment method facade configuration overriding virtualType type for adapter.
  • B Declare a new plugin for class Magento\Payment\Gateway\Config\ConfigValueHandler and using the afterHandle method, change the result for subject can_void.
  • C Add new handler with name can_void to virtualType based on type Magento\Payment\Gateway\Config\ValueHandlerPool in payment method facade configuration.
Explanation

A payment method’s ValueHandlerPool supports configuration values that depend on runtime conditions. A custom handler registered under can_void can evaluate the paid amount and return whether voiding is permitted for that payment, while leaving the standard payment facade and void operation intact. Adobe Commerce specifically documents can_void as a configuration value that can depend on transaction status or paid amount.

Learn more

Community Discussion

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