I'm making a new payment method for Magento 1.9. for now I can make an order and have the invoice correctly. I wane to add the possibility to make credit memos using my payment method, but i can't find the way. This is how i pay the order:
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');
$order->save();
$transaction = Mage::getModel('core/resource_transaction');
$transaction->addObject($order);
$transaction->addCommitCallback(array($order, 'place'));
$transaction->addCommitCallback(array($order, 'save'));
$transaction->save();
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$invoice->getOrder()->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=> false));
return;
I have this in my model:
protected $_canRefund = true;
public function refund(Varien_Object $payment, $amount) {
return parent::refund($payment, $amount);
}
But this do not allow the creation of a credit memo. I read here that natively, the Magento API doesn't support online refunds. You have to create a local version of it which implements some methods which are normally only called when raising credit memos in the admin. But after i implement the sample i was in the same place. Please, someone have an sample to make an online refund API?