If you are developing any payment related extension in Magento2 and you want to get the active Payment methods list with the multi selection option in Magento configuration,
You can follow this code.
use \Magento\Framework\App\Config\ScopeConfigInterface; use \Magento\Payment\Model\Config; class Paymethods implements \Magento\Framework\Option\ArrayInterface { protected $_appConfigScopeConfigInterface; protected $_paymentModelConfig; public function __construct( ScopeConfigInterface $appConfigScopeConfigInterface, Config $paymentModelConfig) { $this->_appConfigScopeConfigInterface = $appConfigScopeConfigInterface; $this->_paymentModelConfig = $paymentModelConfig; } public function toOptionArray() { $payments = $this->_paymentModelConfig->getActiveMethods(); $methods = array(); foreach ($payments as $paymentCode=>$paymentModel) { $paymentTitle = $this->_appConfigScopeConfigInterface->getValue('payment/'.$paymentCode.'/title'); $methods[$paymentCode] = array( 'label' => $paymentTitle, 'value' => $paymentCode ); } return $methods; } }
Do let us know if you face any trouble or suggestions. We will always be happy to assist you.
Happy Coding.
Hello Magento Friends, In today’s blog, I will explain How to Add Tooltip in Checkout…
MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…
In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…
Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…
The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…
Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…