I'm creating invoices programmatically by an own observer for the sales_order_save_after event.
Unfortunately, the invoice is immediately marked as paid.
How can I achieve that the new invoice is still open and a admin has to set it to paid state?
My code so far:
$invoiceId = Mage::getModel('sales/order_invoice_api')
->create($order->getIncrementId(), array());
$invoice = Mage::getModel('sales/order_invoice')
->loadByIncrementId($invoiceId);
$invoice->capture()->save();
EDIT: To make my comment to urfusion's answer understandable, here the code snippet:
public function order_placed($observer) {
$event = $observer->getEvent();
// ....
$emailInvoice = false;
$captureInvoice = false;
$order = Mage::getModel("sales/order")->load($data['entity_id']);
if($order->canInvoice() and $order->getIncrementId())
{
$invoiceApi = Mage::getModel('sales/order_invoice_api');
$invoiceId = $invoiceApi->create(
$order->getIncrementId(),
array(),
Mage::Helper('sales')->__('Pending Invoice created!'),
$emailInvoice,
false);
if($captureInvoice) {
$invoiceApi->capture($invoiceId);
}
}
}