3

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?

3

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

  • thanks... but that extension doesn't work with Magento 1.8.1.0 and it doesn't work with Credit Card (WorldPay). – Saul Karl Sep 1 '14 at 7:46
  • every payment gate have different different logic.. their magento extension have customization according to there logic. so, it not possible to define ,there we stop to create invoice. – Amit Bera Sep 1 '14 at 7:50
  • I had some other problem on similar lines, but taking cue from this answer I could solve it. Thank you. Upvoted – Aakash Aug 26 '17 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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