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
Mage_Payment_Model_Method_Abstract
public function processInvoice($invoice, $payment)
{
$invoice->setTransactionId($payment->getLastTransId());
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)
{
$invoice->setTransactionId(1);
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?