Payment Methods in Magento

These days I am working on Payment Module.

I am writing here the code which is useful and related to Payment module

1) To fetch the existing Payment Methods

There is a payment module helper file existing in default Magento, which is really very helpful.

Path – app/code/core/Mage/Payment/Helper/Data.php

<?php

$payment_helper = Mage::helper('payment');	
$method_list = $payment_helper->getPaymentMethodList();
echo '<pre>';
print_r($method_list); //this will display all the existing payment methods
?>

2) To fetch only enable Payment Methods

<?php
	$active_methods = Mage::getSingleton('payment/config')->getActiveMethods(); 
	$options = array();
	foreach ($active_methods as $_code => $payment_model) 
	{
		$status = $payment_model->canUseCheckout();   		    				
	    if($status==1)
	    {
	    	$_title = Mage::getStoreConfig('payment/'.$_code.'/title');        
	    	$options[$_code] = strip_tags($_title);
	    }
	} 
	echo '<pre>';
	print_r($options); //this will display all the active payment methods   

?>

Hope this is helpful.

2 thoughts on “Payment Methods in Magento

Leave a Reply to werk26 Cancel reply

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

Scroll to top