When a store gets upgraded past Magento 1.5 it can lose the ability for online refunds due to the following change Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items

if ($this->getCreditmemo()->canRefund()) {
    if ($this->getCreditmemo()->getInvoice()) {

vs. new

if ($this->getCreditmemo()->canRefund()) {
    if ($this->getCreditmemo()->getInvoice() && $this->getCreditmemo()->getInvoice()->getTransactionId()) {

Unfortunately not many payment methods saw this change coming and therefore don't have the transaction_id present on the invoice.

Some payment method have now implemented the saving of the transaction_id by utilising/overriding


public function processInvoice($invoice, $payment)
    return $this;

including Magento's own implementation for Authorize.net

 * Mock capture transaction id in invoice
 * @param Mage_Sales_Model_Order_Invoice $invoice
 * @param Mage_Sales_Model_Order_Payment $payment
 * @return Mage_Payment_Model_Method_Abstract
public function processInvoice($invoice, $payment)
    return $this;

However the comment in the only place processInvoice is called Mage_Sales_Model_Order_Payment

$this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated

makes me think this is not the best approach.

  • What is the best way to implement the saving of the transaction_id on the invoice in your payment method?
  • What are good options to deal with legacy invoices?

1 Answer 1


Correctly Setting Transaction Id

As for the mapping invoices. Since Magento 1.4 gets introduced transactions, it sets transaction id automatically when invoice gets created by capture() or registerCaptureNotification() methods of order payment entity. Just look into _addTransaction() of Mage_Sales_Model_Order_Payment class. So you actually shouldn't care about setting this transaction ids manually. Also you can get confused by $this->getTransactionId() method call, but it is actually don't needed to be set by you, since Magento generates transaction id internally by calling _generateTransactionId() in capture or registration of capture notification.

Magento 1.4

All upgrades since Magento 1.4.x are safe, since this logic was always there, since introductions of order payment transaction entity. All Magento versions before 1.4 was having this huge upgradeability pain, even core Authorize.Net (check my answer on SO: https://stackoverflow.com/questions/14207721/why-isnt-payment-method-information-available-in-orders-after-upgrading-from-ma/14270191#14270191). If you were using this method for setting transaction id on invoice, than you should be safe with it, since this transaction id is automatically generated by Magento if you remove processInvoice() call and your original value that you've set is gets preserved as well for old transactions.


Of course I can be wrong at this case, because it was not tested in this way, so would be great to set it up and test before relying on my answer. At least non of my payment extensions was using this processInvoice() method and refunds was processed correctly by Magento with my creditmemos.


As for transaction information for your payment method, you need to make $this->getInfoInstance()->setTransactionId('your_txn_id') call in your authorize() or, if it is direct payment without authorization, capture() method transaction explicitly, to let Magento create transaction record for you. For old records follow my answer on SO.

  • Hi Ivan, thanks for the pointers. My payment method supports $_canCapture=false; $_canRefund=true; so registerCaptureNotification() looks like the way to go. Jan 30, 2013 at 7:46

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.