We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    1. Create events.xml at app/code/Magemonkeys/DisablePayment/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="MagemonkeysDisablePaymentObserverPaymentMethodAvailable" />
          </event>
      </config>
    2.  Create PaymentMethodAvailable.php at app/code/Magemonkeys/DisablePayment/Observer/ with the following code
      <?php
      namespace MagemonkeysDisablePaymentObserver;
      use MagentoFrameworkEventObserverInterface;
      class PaymentMethodAvailable implements ObserverInterface
      {
          public function execute(MagentoFrameworkEventObserver $observer)
          {
              // you can replace "checkmo" with your required payment method code
              if($observer->getEvent()->getMethodInstance()->getCode()=="checkmo"){
                  $checkResult = $observer->getEvent()->getResult();
                  $checkResult->setData('is_available', false); 
              }
          }
      }
    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote