3
votes

I've developed a Payment Method extension for Magento. In this extension, I've added:

protected $_canRefund = true;

However, when I click an invoice and select Credit Memo, I can only see 'Refund Offline' and not 'Refund'. All tutorials I followed insist that I only have to change that value to true to activate the button (obviously I still have to implement the refund method and the actual refund procedure) but I can't see a way to do this.

If I, within a block on the order screen, execute this line $order->getPayment()->getMethodInstance()->canRefund(); it does indeed return true, but still no luck with the actual credit memo.

Edit

I've changed the title of the question to reflect my new find.
Basically, the reason it's not appearing is because my invoices aren't created with transaction IDs - I have no idea why, but this is my capture payment method that runs when generating an invoice:

public function capturePayment($order) {
    try {
        if (!$order->canInvoice()) {
            Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
        }
        $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
        if (!$invoice->getTotalQty()) {
            Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
        }
        $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
        $invoice->register();
        $transactionSave = Mage::getModel('core/resource_transaction')
               ->addObject($invoice)
               ->addObject($invoice->getOrder());
        $transactionSave->save();
        $order->setState('processing', 'payment_received', "Payment has been received", false);
        $order->save();
    } catch (Mage_Core_Exception $e) {
        Mage::throwException("Error Taking Payment, Please Try Again:\n" . $e);
    }
}

Why isn't a transaction ID being assigned to my capture?

1
please put the original capture() from your module (in model) where you will be getting success of the payment capture from gateway. You will be getting a reference id(transaction id) there for the captured payment - Mohammad Faisal
I've been successful in my attempts and it now works. I'll post the solution, shortly - Dan Hanly
bump did you say you found a solution @DanHanly? - Doug McLean
@DougMcLean I'd love to help you out, but this was over a year ago, and I've no idea what the solution is. Apologies. - Dan Hanly
I'm having exactly the same problem here :( - Leo Ribeiro

1 Answers