I have a problem that is driving me nuts. What I'm trying to accomplish is the following:

During checkout I want to have different payment methods available depending on which shipping method was chosen.

I know there was already the same question before, but the answerrsprovided there didn't do he job. I tell you why: I have done exactly what is suggested in the answer of OnePage Checkout - Hide Payment method depending on Shipping Method

What I have done is to create an Observer on the payment_method_is_active event:

class MyNameSpace_PaymentMethodFilter_Model_Observer{

public function paymentMethodIsActive(Varien_Event_Observer $observer){
    $event = $observer->getEvent();
    $method = $event->getMethodInstance();

    $result = $event->getResult();
    $carriers = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
    if($carriers == 'flatrate_flatrate' ){
                if($method->getCode() == 'checkmo'){
                    $result->isAvailable = true;
                    $result->isAvailable = false;


The Problem with this observer is, that the payment_method_is_active event is only dispatched when the onepage is loaded the first time. This means, that after saving the shipping method, the observer doesn't receive any event and therefore can not apply the changes to the payment methods.

The availability of payment methods would rather need to be set when checkout_controller_onepage_save_shipping_method is fired. But if I write an Observer for this event I don't know how I can access the current payment method instances to modify availability accordingly.

Can anyone show me how to solve my problem?

Thanks a lot!


I've had a similar problem (removing dynamically payment methods) and solved it by extending the _canUseMethod($method) function in Mage_Checkout_Block_Onepage_Payment_Methods. There you can return false for specific payment methods which should not be shown in the payment selection.


class Company_Module_Block_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods {
    protected function _canUseMethod($method) {
        if ($method != null && $method == 'checkmo') {
            if ($carriers == 'flatrate_flatrate') {
                return parent::_canUseMethod($method);
            } else {
                return false;

        return parent::_canUseMethod($method);

The config XML would look like:


That way I could remove payment methods right before they get shown in the one page checkout.

Hope that helps anyone.

  • This was the solution that worked for us. We are integrating a new payment method that does not flow through the normal checkout, however the payment method was still available as a payment option during normal checkout. This solved the issue for us. Thank you! – Derik Nel Jan 12 '16 at 7:07
  • Hi @7ok3n. I have this issue magento.stackexchange.com/questions/137738/… so how to achieve this using events.xml instead of Plugin Can? What will be <event name="controller_action_predispatch_XXX_XXX_XX">? – Ankit Shah Oct 4 '16 at 2:39

Mage_Payment_Model_Method_Abstract provides a method isAvailable which returns a boolean value defining if this payment method is available for the current quote. Payment methods that extends this class can add their own logic that defines if it can be used or not. e.g Mage_Paypal_Model_Standard.

If you only want to do this to a single payment method as your SO question suggests, e.g Mage_Payment_Model_Method_Cashondelivery. You could try extending it and creating your own is available function.

  • Thank you for your answer. It didn't answer my question but I already found a way to deal with the issue – Manuel Mar 3 '15 at 3:24
  • 1
    Please elaborate on what approach you used instead – DWils Mar 10 '15 at 23:45

Your Answer

