0

I have a function which is creating an invoice, just the status of the invoice created is "pending". How can I create the invoice with the status "Complete"?

$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::STATE_PAID);
      $invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
    ->addObject($invoice)
    ->addObject($invoice->getOrder());

 $transactionSave->save();

CE 1.9

1 Answer 1

0

I solved with the following code

$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.