Magento: How to get all active payment modules

Magento: How to get all active payment modules

This code bellow will get you all active Magento payment modules. This example below return an array which you can use to create drop down menu or something else in Magento’s front-end or admin sections.

class Inchoo_Vendor_Model_Activpayment
{
 
 
	public function getActivPaymentMethods()
	{
	   $payments = Mage::getSingleton('payment/config')->getActiveMethods();
 
	   $methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));
 
	   foreach ($payments as $paymentCode=>$paymentModel) {
            $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
            $methods[$paymentCode] = array(
                'label'   => $paymentTitle,
                'value' => $paymentCode,
            );
        }
 
        return $methods;
 
	} 
 
}

You made it all the way down here so you must have enjoyed this post! You may also like:

Run methods that are specified in module’s xml file using XPath and Varien_Object Ivan Galambos
Ivan Galambos, | 0

Run methods that are specified in module’s xml file using XPath and Varien_Object

Magento PayPal Standard – How to pay with currency other than base one and do it in your language Tomas Novoselic
, | 50

Magento PayPal Standard – How to pay with currency other than base one and do it in your language

Are Recurring Payments PCI Compliant? Mladen Lotar
Mladen Lotar, | 15

Are Recurring Payments PCI Compliant?

10 comments

  1. Magento1 specific shipping display specific payment option

    I want to show specific payment method when specific shipping is selected

  2. @oreales, @Contempo:

    This function returns all the payment methods configured in the Magento store, not the ACTIVE payment methods.

  3. @Contempo thx for the update, apart for that change, it seems still being the same function and more / less the same behavior isn“t it?

  4. Thanks a lot for this code. And if anyone wants to have only the active payment methods which are enabled on the back end then they can check a condition given below

    if($paymentModel->canUseCheckout()==1):
    
    $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
    
    /*And followed by your code*/
    
    endif;
  5. There is another “standard” and “cleaner” way of do it:

    Mage_Payment_Helper_Data has a method: getPaymentMethodList that returns an array. Returned array format depends on parameters passed to this method. This is used in different grids in Admin to show an HTML select of payment methods, and can be used in frontend also.

    To get an array of Payment Methods, with label and value to show a select in the front, you can use this code:

    Mage::helper("sales")->getPaymentMethodList(true, true, true);
  6. Hi,

    Very useful article. One of my college used this.

    Can you explain what is what in this code.

    I want to get all active shipping methods.

    Regards,
    Saurabh

  7. i m newbie in magento, how to use this module i want the paypal payment module to be shown to my customers while they shop
    can u suggest me some thing to do this paypal enable
    thanks

  8. And getActiveMethods() method has a bug , dependent on store based settings in multi store/website environment “googlecheckout/payment” will always return as active method even if it’s disabled

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.