I am creating an invoice by running cron job after order completion, but it creates an invoice with status 'Paid'. I want invoice to be created with status 'Pending'. This is the code i am using for creating invoice

$invoice = $order->prepareInvoice();

1 Answer 1


Try this code:

    $capture = Mage_Sales_Model_Order_Invoice::NOT_CAPTURE;
    /** @var Mage_Sales_Model_Order_Invoice $invoice */
    $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();

    $transaction = Mage::getModel('core/resource_transaction')


The $capture is one of the Mage_Sales_Model_Order_Invoice predefined values (const):

const CAPTURE_ONLINE   = 'online';
const CAPTURE_OFFLINE  = 'offline';
const NOT_CAPTURE      = 'not_capture';


If you want to have ability to manage capture of the COD payment method, you need to rewrite the Mage_Payment_Model_Method_Cashondelivery and add to it:

protected $_canCapture = true;

After that you can use "capture case" with no capture value when creating a new invoice and capture that invoice later using the capture button on the invoice view page:


  • Same result . Invoice created with status 'Paid' .
    – Seefan
    Commented Apr 29, 2016 at 6:34
  • @Nafees What payment method you are using for order? Commented Apr 29, 2016 at 6:37
  • Cash on Delivery
    – Seefan
    Commented Apr 29, 2016 at 6:38
  • @Nafees Unfortunately it is inaccessible for the COD method, because the COD method can't be captured later by default Commented Apr 29, 2016 at 7:15
  • @Nafees I've updated my answer Commented Apr 29, 2016 at 7:29

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.