0

I am developing a Magento 2 custom payment module for one of my clients, yet I am now totally blocked in finding a way to process an online refund for any of the created orders. I can't locate the Online refund button and all I found was the offline refund button, so I tried to trigger the refund by adding canRefund throw the config.xml file and add it in the payment module but there is something still missing so if any one can help i will be appreciated?

config.xml

<active>1</active>
<can_refund>1</can_refund>
<can_capture>1</can_capture>

payment.php

    namespace magento\payment\Model;
    
    
    class Payment extends \Magento\Payment\Model\Method\AbstractMethod
    {
    
        protected $_isInitializeNeeded      = false;
        protected $redirect_uri;
        protected $_code = "mycode";
        protected $_canOrder = true;
        protected $_isGateway = true;
        protected $_canCapture = true;
        protected $_canCapturePartial = true;
        protected $_canRefund = true;
    
    
    
        public function getOrderPlaceRedirectUrl() {
           return \Magento\Framework\App\ObjectManager::getInstance()
                                ->get('Magento\Framework\UrlInterface')->getUrl("mycode/redirect");
       }
       public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
       {
          // some code

          return ;
       }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.