VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: j_vovus on January 31, 2012, 15:02:12 PM

Title: [fixed] PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on January 31, 2012, 15:02:12 PM
Hi,
In the plgVmOnPaymentNotification function, the  PayPal plugin does a lot of staff before it checks whom the event is addressed.
Here is the fail-part:


    function plgVmOnPaymentNotification() {
if (!class_exists('VirtueMartModelOrders'))
    require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
$paypal_data = JRequest::get('post');
//$this->_debug = true;
$order_number = $paypal_data['invoice'];
$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($paypal_data['invoice']);
$this->logInfo('plgVmOnPaymentNotification: virtuemart_order_id  found ' . $virtuemart_order_id, 'message');


I have no invoice parameter in my $_POST data. So, JDispatcher->trigger($event, $args) fails in foreach on the PayPal observer before all observers are called.
Yes, I put the invoice parameter to my plugin like a hack to make it work, but this is bad.
I cannot put the invoice parameter to my $_POST, because transaction checksum check will fail.
So, any payment plugin, that doesn't get $_POST['invoice'] to notification event handler, fails to handle this event.

VM 2.0.0 public, J1.7

Best regards,
Vladimir
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: alatak on February 01, 2012, 11:09:41 AM
Hi,

Strange, if i look in the code from the version 2.0.0 i don't have the same code as you.

Here is the correct code from the notification trigger


function plgVmOnPaymentNotification() {
if (!class_exists('VirtueMartModelOrders'))
    require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
$paypal_data = JRequest::get('post');

$order_number = $paypal_data['invoice'];
$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($paypal_data['invoice']);


if (!$virtuemart_order_id) {    
    exit;
}
.....
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on February 01, 2012, 11:24:10 AM
Hi,

Even so, it doesn't matter.
Without paypal's invoice parameter in POST, it fails to get virtuemart_order_id and exits.
So dispatcher's foreach exits too, before all modules will be checked on the plgVmOnPaymentNotification listener.
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: alatak on February 01, 2012, 12:02:44 PM
Hi,

QuoteWithout paypal's invoice parameter in POST, it fails to get virtuemart_order_id and exits.
yes but paypal does return the invoice number.
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on February 01, 2012, 12:58:11 PM
Hi,

But I'm developing other payment plugin for other payment service. And my gateway does not returns $_POST['invoice'].
But PayPal is the first in dispatcher queue for observer binding, so it exits from whole foreach in JDispatcher->trigger($event, $args) method.
After the PayPal's plgVmOnPaymentNotification method exits, all payment plugins that are next in the queue will not be processed by dispatcher and finally their plgVmOnPaymentNotification will not be called.
Sorry, but did you read my first message in this topic?
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: alatak on February 01, 2012, 13:16:13 PM
Hi,

Yes i read your message :).

I fix it that way:

Quote
   if (!class_exists('VirtueMartModelOrders'))
       require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
   $paypal_data = JRequest::get('post');
   if (!isset($paypal_data['invoice'])) {
       return;
   }
   $order_number = $paypal_data['invoice'];
   $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($paypal_data['invoice']);
   //$this->logInfo('plgVmOnPaymentNotification: virtuemart_order_id  found ' . $virtuemart_order_id, 'message');

   if (!$virtuemart_order_id) {
       return;
   }

Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on February 01, 2012, 13:24:47 PM
Thank you very much! Can you say when approximately this fix will be applied to the public version?
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: Milbo on February 01, 2012, 13:29:58 PM
It will be today in the 2.0.1c, which should be released then as 2.0.2
Title: Re: PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on February 01, 2012, 13:32:38 PM
Okay, thank you again.

So, topic is solved. (I can't find the button to edit topic title and add "[SOLVED]").
Title: Re: [fixed] PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: Milbo on February 01, 2012, 13:46:58 PM
There isnt any, but good idea.... There should be a button for threads starters to set it fixed or solved.
Title: Re: [fixed] PayPal plugin breaks event plgVmOnPaymentNotification for other plugins
Post by: j_vovus on February 01, 2012, 14:09:47 PM
Quote from: Milbo on February 01, 2012, 13:46:58 PM
There isnt any, but good idea.... There should be a button for threads starters to set it fixed or solved.

Yes, it could be very convenient.

P.S.:  I don't know whether to create a new topic, maybe you can help me here or give a direction where to search:
How to get total taxed percentage for each product in the cart? (exactly in percents)