VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: olgri on November 10, 2016, 23:24:00 PM

Title: VM2 Paypal status changes from Confirmed to Cancelled if you hit the Back button
Post by: olgri on November 10, 2016, 23:24:00 PM
Hi everyone,
Has anyone noticed the following bug in VM2? (I couldn't find anything on the forum).

Joomla! 2.5.28
VirtueMart 2.6.6

When you select Paypal as the payment method and the payment is successful, you get redirected back to the shop to the "Thank you for your order" page with the details of the order and Paypal Transaction ID.
The status of the order is "Confirmed" at this stage. All good.

Now, if you hit the back button in your browser (say accidentally - this is especially likely to happen if you are using a touch screen smartphone), you get redirected back to Paypal. Paypal then displays "Your payment was completed. To continue shopping, please return to the merchant." message and a "Return to [Shop Name]" button. Click the "Return to [Shop Name]" button and you get redirected back to the shop. However now you see a "You have cancelled your payment" message and the status of the order is updated to 'Cancelled'.

Money doesn't get refunded so the shopper is waiting for the goods to arrive and shop admins think the order was cancelled and therefore ignore it.

This has been happening more and more often recently. Probably because more and more people use their smartphones for online shopping.

Is there a fix for this issue?
Does this happen in VM3 as well?

Thanks.
Title: Re: VM2 Paypal status changes from Confirmed to Cancelled if you hit the Back button
Post by: GJC Web Design on November 11, 2016, 00:58:18 AM
No - this bug was discovered and fixed in VM3

see-> http://forum.virtuemart.net/index.php?topic=135778.msg473257#msg473257

you could make this change in your VM2 Paypal
Title: Re: VM2 Paypal status changes from Confirmed to Cancelled if you hit the Back button
Post by: olgri on November 11, 2016, 03:20:18 AM
That fixed it! Thanks a lot!!  :)

Just for a record...

plugins/vmpayment/paypal/paypal.php

plgVmOnUserPaymentCancel() function around line 602.

Add the following code before VmInfo(vmText::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED'));


$method = $this->getPluginMethod($virtuemart_paymentmethod_id);
$oM = VmModel::getModel('orders');
$theorder = $oM->getOrder($virtuemart_order_id);
if ($theorder['details']['BT']->order_status == $method->status_success || $theorder['details']['BT']->order_status == $method->status_pending ||   $theorder['details']['BT']->order_status == $method->status_capture) {
return NULL;
}