cancel
Showing results for 
Search instead for 
Did you mean: 

Any help - Magento 1.9 - How to get Payment method in Observer?

Any help - Magento 1.9 - How to get Payment method in Observer?

I want to assign specific payment method only for selected one customer group,

successfully get customer group & Payment method code,

How to add condition, following are my workout,

 

Following Tutorial : https://meetanshi.com/blog/disable-payment-method-programmatically-in-magento/

workout :

4 REPLIES 4

Re: Magento 1.9 - How to get Payment method in Observer?

Hello @Aveeva 

 

https://magento.stackexchange.com/questions/43672/onepage-checkout-get-selected-payment-method/43678...

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: Magento 1.9 - How to get Payment method in Observer?

@Meetanshi  Yes, i get my payment method code, how to add my code = payubiz to my script, tester customer group only pay via payubiz.

Re: Magento 1.9 - How to get Payment method in Observer?

Hello @Aveeva 

 

You need to add restriction for it and display an error message displaying "You have to select payubiz payment to place order"

 

https://github.com/riconeitzel/PaymentFilter module can be used for your solution.

 

Thanks.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: Magento 1.9 - How to get Payment method in Observer?

I just tried, any help thanks,

 

<?php
    class Gta_FindPaymentGateway_Model_Observer
    {
        public function paymenter($Observer)
        {
            if(Mage::getSingleton('customer/session')->isLoggedIn())
            {
                // Get group Id
                $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();

                //Get customer Group name
                $group = Mage::getModel('customer/group')->load($groupId);

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

                if($group->getCode() != 'Tester')
                {
                	if($paymentmethods['code'] == "payubiz")
                	{
                	  $paymentmethods->setData("is_available", false);
                	}
                }
            }
        }
    }
?>