Magento – Change invoice status to paid programmatically

invoicemagento-1.7

How can we programmatically change the status of an invoice to Paid for an order with an offline payment method (eg bank transfer or cash)?

I have tried using the following capture method but this still leaves the invoice as Pending:

$order->load($_POST['order']);
$order->getPayment()->capture();
$order->save();

So how can we update an invoice with an offline payment method to Paid?

Best Answer

Have you tried this?

$invoice = Mage::getModel('sales/order_invoice')->load(...id_of_invoice...);
$invoice->pay()->save();
Related Topic