Payment methods such as cash-on-delivery and check/money order need to visible in the admin-panel check-out section and not in the front-end for the customer. Magento 2 provides dynamic functionality to implement this using plugins.
Using one such plugin, we can restrict the payment method to display not on front-end and Admin section. Let us see how!
First you need to create di.xml in your module and add below dependency injections for “Cash On Delivery” and “Check/Moneyorder” payment method.
- Cash-On Delivery
Create Directory Structure for plugins
{Namespace}\Module\Plugin\Payment\Method\CashOnDelivery\;
Create Available.php with below code
- Check/Moneyorder
{Namespace}\Module\Plugin\Payment\Method\Checkmo;
Create Available.php with below code