Home » Magento, Magento 29 January 2017

Magento 2: Get Payment Methods (All/Active/Used)

This article shows how to get payment methods in Magento 2. We will be fetching 3 types of payment methods. They are:

1) All Payment Methods
2) Active/Enabled Payment Methods
3) Payment Methods that have been used while placing orders

I will be showing both ways (Dependency Injection & Object Manager way) to get payment methods.

Using Dependency Injection (DI)

Here is the code that you need to write in your Block class.

Using Object Manager

Sample Output of getUsedPaymentMethods():

Sample Output of getAllPaymentMethodsList():

Sample Output of getAllPaymentMethods():

The output array of of getActivePaymentMethods() is very long. So, I have just printed out the keys of the array. Keys of the output array contains active method’s code.

Sample Output of array_keys(getActivePaymentMethods()):

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Praful Rajput

    Very Helpful Tutorial. Thank you!