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:


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

1 Answer 1


Have you tried this?

$invoice = Mage::getModel('sales/order_invoice')->load(...id_of_invoice...);
  • With that code I get the following error: PHP Fatal error: Call to a member function hasForcedState() on a non-object in app/code/core/Mage/Sales/Model/Order/Invoice.php on line 405
    – Chris
    Jan 22, 2015 at 14:38
  • For reference, the payment method of the invoice I am trying to update is "Check / Money Order" (checkmo).
    – Chris
    Jan 22, 2015 at 14:41
  • Does this order has payment? Looks like line $this->getOrder()->getPayment()->hasForcedState() is causing the problem.
    – rafal-kos
    Jan 22, 2015 at 14:42
  • The order doesn't have payment as it's an offline payment method. It's an order with a pending invoice that we want to mark as paid (we changed the payment method from online credit card to offline as the customer paid by phone).
    – Chris
    Jan 22, 2015 at 14:48
  • So in this case I would suggest this solution : $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID)->save()
    – rafal-kos
    Jan 22, 2015 at 14:51

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.