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.
Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…
E-commerce has transformed the way consumers shop for products and services and interact with businesses.…
The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…
Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…
Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…
We have brought exciting news for Magento store owners. Hyvä Themes recently released 1.3.6 and…