The best approach to this would be to register an Observer in an Event thrown during the payment capture process, but I do not see too many relevant ones, unfortunately. You can try sales_order_invoice_save_before intercept save (), but I'm not interested in this, as this may confuse the controller with why the failure to save the account 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 it does not already exist, and payment is the full amount of the order. To verify this, use the _isCaptureFinal($amount) method.
One option is to extend Mage_Sales_Model_Order_Payment and override _isCaptureFinal($amount) with the code in the lines:
foreach($this->getOrder()->getAllItems() as $oOrderItem){ if($oOrderItem()->getProduct()->getTypeId() == 'your_custom_product_type'){ return false; } } return parent::_isCaptureFinal($amountToCapture);
Do not forget the final call of the parent !!
You will do all this in a custom module (start with ModuleCreator if you want) and paste the following into the config.xml file
<global> <models> <modulename> <class>Namespace_Modulename_Model</class> </modulename> <sales> <rewrite> <order_payment>Namespace_Modulename_Model_Order_Payment</order_payment> </rewrite> </sales> </models>
The standard disclaimers apply, you are helpless with cash transactions here, so make sure you thoroughly test it really really .
Please note that this approach applies to all payment methods that call Mage_Sales_Model_Order_Payment::registerCaptureNotification($amount) , and not just in Paypal.
Good luck
Jd
source share