I need the list of payment method codes.

My code


error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
echo "start<br>"; 

$allPaymentMethods = Mage::getModel('payment/config')->getAllMethods();

foreach($allPaymentMethods as $pippo) {
    echo $pippo;

echo count($allPaymentMethods); 
echo "<br>";
$activePaymentMethods =Mage::getModel('payment/config')->getActiveMethods();

foreach($activePaymentMethods as $menelao) {
    echo $menelao;
echo count($activePaymentMethods);  
echo "<br>";

echo "end";

It does not work. The array count works but echo $pippo and $menelao is blank.


1 Answer 1


Try to do this:

$allPaymentMethods = Mage::getModel('payment/config')->getAllMethods();

foreach($allPaymentMethods as $paymentMethod) {
    echo $paymentMethod->getCode();

The method getAllMethods() returns an array of payment method objects

 * Retrieve all system payments
 * @param mixed $store
 * @return array
public function getAllMethods($store=null)
    $methods = array();
    $config = Mage::getStoreConfig('payment', $store);
    foreach ($config as $code => $methodConfig) {
        $data = $this->_getMethod($code, $methodConfig);
        if (false !== $data) {
            $methods[$code] = $data;
    return $methods;

That is why if you want to get the payment method code you need to call the method getCode() on the $paymentMethod object

  • Great, I updated my answer to add more details if you are interested. The other method you are calling "getActiveMethods" is also returning an array of payment method objects. Please remember to mark the answer as accepted if this helped you.
    – lloiacono
    Commented Mar 10, 2016 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.