{"id":2053,"date":"2022-08-05T11:51:14","date_gmt":"2022-08-05T11:51:14","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/make-a-payment-method-visible-only-to-admin-in-magento-2\/"},"modified":"2025-05-22T09:13:38","modified_gmt":"2025-05-22T03:43:38","slug":"make-a-payment-method-visible-only-to-admin-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/make-a-payment-method-visible-only-to-admin-in-magento-2\/","title":{"rendered":"How to Make a Payment Method Visible Only to Admin in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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\u2019ve come up with a method to&nbsp;<em><strong>make a payment method visible only to admin in Magento 2<\/strong><\/em>. Using this method, the payment method won\u2019t be visible on the frontend to the customers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Method to Make a Payment Method Visible Only to Admin in Magento 2<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<strong>events.xml<\/strong>&nbsp;at&nbsp;<strong>app\/code\/Vendor\/Extension\/etc\/<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Event\/etc\/events.xsd\">\n    &lt;event name=\"payment_method_is_active\">\n        &lt;observer name=\"disable_payment\" instance=\"Vendor\\Extension\\Observer\\PaymentMethodAvailable\" \/>\n    &lt;\/event>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>PaymentMethodAvailable.php<\/strong>&nbsp;at&nbsp;<strong>app\/code\/Vendor\/Extension\/Observer\/<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nnamespace Vendor\\Extension\\Observer;\n \nuse Magento\\Framework\\Event\\ObserverInterface;\nuse Magento\\Framework\\App\\State;\n \nclass PaymentMethodAvailable implements ObserverInterface\n{\n \n protected $state;\n \n public function __construct (\n State $state\n ) {\n $this->state = $state;\n }\n \n    public function execute(\\Magento\\Framework\\Event\\Observer $observer)\n    {\n        \/\/ you can replace \"checkmo\" with your required payment method code\n        if($observer->getEvent()->getMethodInstance()->getCode()==\"checkmo\"){\n if($this->state->getAreaCode()!=\"backend\"){\n $checkResult = $observer->getEvent()->getResult();\n $checkResult->setData('is_available', false); \n }\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the code mentioned above, you can make a payment method only visible to the admin and invisible to the customers in the frontend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Same way, as an admin, you may require to restrict payment methods in frontend. You can explore&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-payment-restrictions.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Payment Restrictions<\/a>&nbsp;extension by Meetanshi to create condition based payment rules for restricting payment methods in frontend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also if you want your customers to use one particular payment method you can&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/give-discount-on-payment-methods-in-magento-2\/\">give discount on payment methods in Magento 2<\/a>&nbsp;and encourage them to use that payment method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the post with others in the community via social media!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to rate the post with 5 \u2b50 if found useful!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2053","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2053"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2053\/revisions"}],"predecessor-version":[{"id":14150,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2053\/revisions\/14150"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}