I have created new custom product type which extends virtual product in magento. Now I would like to block automatic invoicing for online payments eg. paypal when order contains at least one custom product type. All orders with such product have to be invoiced manually. How should I resolve this?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Get payment by transaction ID using PayPal API
- Can php detect if javascript is on or not?
The best approach to this would be register an Observer to an Event thrown during the payment capture process, but I'm not seeing too many relevant ones unfortunately. You could try
sales_order_invoice_save_before
to intercept the save(), but I'm not keen on that as it may confuse the controller(s) as to why the invoice save failed.Looking through the Paypal code, you will see in
Mage_Paypal_Model_Ipn::_processOrder()
that it calls$this->_registerPaymentCapture()
on success, which in turn calls$payment->registerCaptureNotification()
.Mage_Sales_Model_Order_Payment::registerCaptureNotification($amount)
creates a new invoice if one doesn't already exist and the payment is the full amount of the order. It uses the_isCaptureFinal($amount)
method to verify this.One option would be to extend
Mage_Sales_Model_Order_Payment
and override_isCaptureFinal($amount)
with code along the lines of:Don't forget the final call to parent!!
You would do all this in a custom module (start with the ModuleCreator if you want), and insert the following into the config.xml
Standard disclaimers apply, you're messing with funds transactions here, so makes sure that you test it really really thoroughly.
Note that this approach will apply to all payment methods that call
Mage_Sales_Model_Order_Payment::registerCaptureNotification($amount)
, not just Paypal.Good Luck,
JD