News:

Looking for documentation? Take a look on our wiki

Main Menu

PayPal cancellation results in Confirmation email

Started by OpenGlobal, March 11, 2012, 01:39:54 AM

Previous topic - Next topic

OpenGlobal

I've been trawling through the code to try to work out why this is happening but I just can't find it.

When using the Paypal payment plugin, whatever happens, a confirmation email is sent. Even if the user cancels the paypal payment and the order gets completely deleted from the Orders list, a confirmation email is still sent.

Basically, every return type from paypal results in a confirmation email.

Does anyone know why this is happening or where the payment confirmation email is getting sent?

OpenGlobal

llper

Unfortunately I cannot help in solving the problem, but I can confirm that the problem exists, at least in my 2.0.2 test environment!
This should definitively get fixed. I know that if the seller logs in and does not find any order in the orders list could think of ignoring the received confirmation email, but it is not nice!

Regards,
D

OpenGlobal

Anyone?

This seems like such a trivial error that should be easy to fix.

OpenGlobal

Merry

Quote from: openglobal on March 29, 2012, 16:13:32 PM
Anyone?

This seems like such a trivial error that should be easy to fix.

OpenGlobal
OpenGlobal,

Go to SHOP -> Payment Methods -> PayPal -> Configuration Tab - scroll all the way down and double-check these 3 boxes:

Order Status for Pending transactions    
Order Status for Successful transactions    
Order Status for Failed transactions

Regards,
Merry
Answer is probably from my VirtueMart 2 User Manual ebook, includes FREE updates. FREE Admin Menu Cheatsheet, Quick Install Guide & 30-Minute Quick Setup Guide http://showmeguides.com/

OpenGlobal

This isn't a configuration issue, it's a code issue. The order status is being updated appropriately (or not as the case may be), it's just the emails that are being sent out incorrectly.

OpenGlobal

OpenGlobal

I've discovered this in the code (/administrator/components/com_virtuemart/plugins/vmpsplugin.php):


                function handlePaymentUserCancel($virtuemart_order_id) {

                        if ($virtuemart_order_id) {
                                // send the email only if payment has been accepted
                                if (!class_exists('VirtueMartModelOrders'))
                                require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );

                                $modelOrder = VmModel::getModel('orders');
                                $order['order_status'] = 'X';
                                $order['virtuemart_order_id'] = $virtuemart_order_id;
                                $order['customer_notified'] = 0;
                                $order['comments'] = '';
                                $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, true);
                                $modelOrder->remove(array('virtuemart_order_id' => $virtuemart_order_id));
                        }
                }


The comment "send the email only if payment has been accepted" doesn't seem to refer to anything. At no point is a check for an accepted payment being made. The only "check" is that the virtuemart_order_id has been specified. And the email isn't sent from this function anyway. We still want to send the email, just not a "confirmed" email.

I'll continue my investigation but this is just sloppy and reflects badly on Virtuemart as a whole

OpenGlobal

#6
Right, well I've worked out what the problem is.....sort of.

components/com_virtuemart/views/invoice/view.html.php creates the email using the subject COM_VIRTUEMART_VENDOR_NEW_ORDER_CONFIRMED. There is no equivalent COM_VIRTUEMART_VENDOR_NEW_ORDER_CANCELLED.

The solution could either be to to send the email with an appropriate subject rather than a hard coded "confirmed", or just to not send an email at all when a payment is cancelled.

Can someone from the VM team contribute an opinion on this?

OpenGlobal