Magento 1.9 – Online Refunding with Custom Payment Method

ce-1.9.0.1magento-1.9magento-communitypaymentrefund

I'm using Magento 1.9.1.0 CE and trying to implement payment method with online refunds.

My model looks like:

class X_Y_Model_Standard extends Mage_Payment_Model_Method_Abstract {

        protected $_canAuthorize = true;
        protected $_canRefund = true;
        protected $_canCapture = true;

        ...

        public function refund(Varien_Object $payment, $amount) {   

            ...
            return parent::refund($payment, $amount);
        }

        ...

        public function capture(\Varien_Object $payment, $amount) {

            $payment->setTransactionId($myApiTransactionId);        
            $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, "");
            $transaction->setIsClosed(true);       

            return parent::capture($payment, $amount);
        }   

        ...

        public function processInvoice($invoice, $payment) {

            $invoice->setTransactionId($myApiTransactionId);

            return parent::processInvoice($invoice, $payment);
        }

        ...
    }

After creating invoice I can only refund offline.

Any idea?

Best Answer

You can only do refunds online if you've captured the invoice online (e.g via a payment gateway). Since this is not the case you only can do offline refunds.

Related Topic