We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
Disable a Payment Method Programmatically

Do you need to disable a payment method in checkout under conditions? Let's see how you can do that!
Like in most of our previous posts, we create a new module for that post called Blog20. To achieve that we will use an event, the payment_method_is_active event. So we create an events.xml file to define our event under
/app/code/MageVision/Blog20/etc/
and adding the following code
So the payment_method_is_active event is dispatched, the PaymentMethodIsActiveObserver function is called where it checks if the customer is logged in or not. If not, then the Banktransfer payment method is disabled.
The full example as extension can be found here.
Feel free to share this post and ask your questions in the comments below.
Till next time!