How can we check show payment method magento by using codes ?
In default function of magento, the owner store can disable or enable payment method. But in some special cases, for instance, their requirement is disabling this payment method for B2B customer and showing this method for B2C customer.

In my example, the B2C customer are guests or customers belong to default customer group which is configured in admin and B2B customer belong to other groups.
In this case, we need to override the method  : isAvailable($quote = null) of this payment method to fit their request.
For example : with Check/Money Order payment method. We override isAvailable() method in the file : app/code/core/Mage/Payment/Model/Method/Checkmo.php 

Put isAvailable() method as below :

public function isAvailable($quote = null)

$defaultCustomerGroupId = Mage::helper('customer')->getDefaultCustomerGroupId();


$customerData = Mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getCustomer()->getId())->getData();
$currentCustomerGroupId = intval($customerData['group_id']);

if($currentCustomerGroupId && $currentCustomerGroupId!=$defaultCustomerGroupId ){
return false;


return parent::isAvailable();;

return parent::isAvailable();




Hope it helps.