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.');

    $transaction = Mage::getModel('core/resource_transaction');
    $transaction->addCommitCallback(array($order, 'place'));
    $transaction->addCommitCallback(array($order, 'save'));

    $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
    $transactionSave = Mage::getModel('core/resource_transaction')

    Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=> false));

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?

1 Answer 1


Well, after search in all the internet and inspect the visual element in charge to show the button, search in the backend templates for that view i notice that the botton have a condition asking for canCreditmemo() function in Order model class. Then i search the order class in sales in magento code and start debugin the conditions, long story short, the problem is with the estate of the Order

$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');

Change it to

$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, false, 'Payment Success.');

and problem solved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.