How To Get All Payment Methods In Magento 2

PHOTO EMBED

Tue Jan 21 2025 19:47:04 GMT+0000 (Coordinated Universal Time)

Saved by @zaki

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();        
 
$paymentHelper = $objectManager->get('Magento\Payment\Helper\Data');
$allPaymentMethods = $paymentHelper->getPaymentMethods();
$allPaymentMethodsArray = $paymentHelper->getPaymentMethodList();
 
var_dump($allPaymentMethodsArray);
var_dump($allPaymentMethods);
 
$paymentConfig = $objectManager->get('Magento\Payment\Model\Config');
$activePaymentMethods = $paymentConfig->getActiveMethods();
 
var_dump(array_keys($activePaymentMethods));
 
$orderPaymentCollection = $objectManager->get('\Magento\Sales\Model\ResourceModel\Order\Payment\Collection');
$orderPaymentCollection->getSelect()->group('method');
$paymentMethods[] = array('value' => '', 'label' => 'Any');
foreach ($orderPaymentCollection as $col) { 
    $paymentMethods[] = array('value' => $col->getMethod(), 'label' => $col->getAdditionalInformation()['method_title']);            
}        
content_copyCOPY

https://www.mageplaza.com/devdocs/get-all-payment-methods-magento-2.html