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

How to Make a Payment Method Visible Only to Admin in Magento 2

By Jignesh ParmarUpdated on May 22, 2025 2 min read

Magento 2 supports number of payment methods to allow customers pay online. But at times, the admin may have set up the collaboration with the customers in such a way that they pay directly through cash, cheque or bank transfer method and the admin places orders on behalf of those customers. In such a case, the admin require to enable such payment methods only in the Magento 2 backend and not in the frontend for the customers.

The default Magento 2 does not provide any such functionality to make a payment method visible only to admin and invisible in the frontend. To satisfy the above scenario, I’ve come up with a method to make a payment method visible only to admin in Magento 2. Using this method, the payment method won’t be visible on the frontend to the customers.

Method to Make a Payment Method Visible Only to Admin in Magento 2

1. Create events.xml at app/code/Vendor/Extension/etc/

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="payment_method_is_active">
        <observer name="disable_payment" instance="Vendor\Extension\Observer\PaymentMethodAvailable" />
    </event>
</config>

2. Create PaymentMethodAvailable.php at app/code/Vendor/Extension/Observer/

<?php
namespace Vendor\Extension\Observer;
 
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\State;
 
class PaymentMethodAvailable implements ObserverInterface
{
 
 protected $state;
 
 public function __construct (
 State $state
 ) {
 $this->state = $state;
 }
 
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        // you can replace "checkmo" with your required payment method code
        if($observer->getEvent()->getMethodInstance()->getCode()=="checkmo"){
 if($this->state->getAreaCode()!="backend"){
 $checkResult = $observer->getEvent()->getResult();
 $checkResult->setData('is_available', false); 
 }
        }
    }
}

Using the code mentioned above, you can make a payment method only visible to the admin and invisible to the customers in the frontend.

Same way, as an admin, you may require to restrict payment methods in frontend. You can explore Magento 2 Payment Restrictions extension by Meetanshi to create condition based payment rules for restricting payment methods in frontend.

Also if you want your customers to use one particular payment method you can give discount on payment methods in Magento 2 and encourage them to use that payment method.

Do share the post with others in the community via social media!

Do not forget to rate the post with 5 ⭐ if found useful!

Thanks for reading!

Jignesh Parmar Full Image
Article byJignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.