🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Disable Payment Method Programmatically in Magento

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Payment system management is a core of Magento store system. Handling it carefully in order to optimize the sales in the best possible way to maximize the profits and minimize the efforts is crucial. Need to disable payment method programmatically in Magento occurs when you want to show specific methods like CCAvenue to Indian Customers only or restrict Magento customer groups to use offline payment methods, etc.

One of the ways to do so is to disable payment method programmatically in Magento store based on conditions. The store owner can restrict specific payment methods based on the customer groups, product or order attributes, and shipping parameters.

Steps to disable payment method programmatically in Magento:

1. Add the below code in the config.xml file

<global>
    ...
    <events>
        <payment_method_is_active>
            <observers>
                <disable_paymentmethod>
                    <class>Vendor_Extension_Model_Observer</class>
                    <method>paymentMethodIsActive</method>
                </disable_paymentmethod>
            </observers>
        </payment_method_is_active>
    </events>
    ...
</global>

2. Add the below code in the Observer.php file.

<?php

class Vendor_Extension_Model_Observer {

    public function paymentMethodIsActive(Varien_Event_Observer $observer) {
        $method = $observer->getMethodInstance();
        
        if ($method->getCode() == 'payment_method_code') {
            
            if (condition) {
                $result = $observer->getResult();
                $result->isAvailable = false;
            }
        }
        
    }
}

Implement these steps and control the choices of payment methods at the checkout based on different conditions!

If you are looking for the same solution in Magento 2, check disable payment method programmatically in Magento 2.

Also, do let us know your review and ratings for the solution 🙂

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.