Auto Invoice Generation – How to Stop with Credit Card or Paypal

invoicemagento-1.8

I need to stop Magento (version 1.8.1.0) from generating invoices automatically with credit card or paypal payment methods.

I look at registerCaptureNotification() in app/code/Mage/Sales/Model/Order/Payment.php. If I comment out the following code snippet:

if (!$invoice) {
        if ($this->_isCaptureFinal($amount)) {
            // comment out the following to stop creating invoices automatically
            //$invoice = $order->prepareInvoice()->register();
            //$order->addRelatedObject($invoice);
            //$this->setCreatedInvoice($invoice);
        } else {
            if (!$skipFraudDetection) {
                $this->setIsFraudDetected(true);
            }
            $this->_updateTotals(array('base_amount_paid_online' => $amount));
        }
}

But this doesn't seem to work. Invoices are still being generated using credit card payment.

What is the right way to prevent auto invoice generation?

Best Answer

Karl,goto app/code/core/Mage/Paypal/Model/Ipn.php
copy to

app/code/local/Mage/Paypal/Model/Ipn.php

here magento create invoice on paypal order

find the code:

app/code/core/Mage/Paypal/Model/Ipn.php goto function

here create invoice by below code:

if ($invoice = $payment->getCreatedInvoice()) {
            $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
            $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
                ->setIsCustomerNotified(true)
                ->save();
        }

just change it to

$order->sendNewOrderEmail()
                ->setIsCustomerNotified(true)
                ->save();

here function $payment->getCreatedInvoice() create invoice of an order

or used the extension:

http://www.magentocommerce.com/magento-connect/disable-automatic-generation-of-invoice.html