[fixed] PayPal plugin breaks event plgVmOnPaymentNotification for other plugins

Started by j_vovus, January 31, 2012, 15:02:12 PM

Previous topic - Next topic

j_vovus

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

alatak

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;
}
.....

j_vovus

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.

alatak

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.

j_vovus

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?

alatak

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;
   }


j_vovus

Thank you very much! Can you say when approximately this fix will be applied to the public version?

Milbo

It will be today in the 2.0.1c, which should be released then as 2.0.2
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

j_vovus

Okay, thank you again.

So, topic is solved. (I can't find the button to edit topic title and add "[SOLVED]").

Milbo

There isnt any, but good idea.... There should be a button for threads starters to set it fixed or solved.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

j_vovus

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)