Retrieve All Payment Methods list in Magento 2.

In Magento 2 You can retrieve all the available payment methods by Magento\Payment\Model\Config\Source\Allmethods class.

Using Allmethods class you can get all the payment methods in the system whether its enable or disable in the admin setting.

You can get only the active payment methods by Get all active payment methods in Magento 2.

List of all the payment methods in Magento 2 getting by below code snippets,

Create Block file,

Get function in template file by below way using phtml template file,

The output will be like(Test in Magento 2.2.6),