PayPal Plugin order status and emails not working correctly

Started by nicole2292, November 20, 2011, 10:29:58 AM

Previous topic - Next topic

nicole2292

Hello,

I have been trying to configure a new shop on Joomla 1.7.3 - VM 1.9.8m and I am having endless problems with the paypal plugin.

The shop was supposed to be live last week in time for Christmas so this is quite an urgent matter now.

I will detail the problems I am having with the paypal payment method below:

1. Order status remains "pending" even after successful (live not sandbox) paypal payment and the customer being returned successfully to the site and seeing the message "Thank you for your order!".
The order status is always "pending" regardless of the settings. Even if I set the configuration "Order Status for Pending Payments" to "Confirmed". It is even still always pending.

2. No order emails are being sent to the customer or the store owner. I know this is a problem with the paypal plugin as if I use the standard payments plugin I get order emails even though the status of the order in that case is still pending as the payment has not actually received.

Whilst these two issues exist the site cannot go live. Please provide a solution asap. I certainly don't have time to wait for another release candidate or the stable version.

I know someone will surely say I shouldn't be using VM2 for a (nearly) live shop as it is not yet a stable release. Well I will tell you that I have a number of stores still running VM on Joomla 1.5 and these sites are so outdated now that they have been repeatedly hacked. I simply cannot risk running such an outdated version of Joomla for this new client due to the security issues it presents. Therefore I have no choice but to use the not yet stable VM2 so I can use a more recent and secure version of Joomla. As a long time Joomla and VM user I am actually extremely disappointed it has taken this long for VM2 stable to be released, but that is a separate matter.

Your assistance with this urgent paypal matter is greatly appreciated.

Nicole

alatak

Hi,

Please try to apply that fix first:
http://forum.virtuemart.net/index.php?topic=93021.new;topicseen#new

If your problem remains, tell me , i will try to see how i can help you.

nicole2292

Hi Atalak,

Thanks for your fast reply and suggestion. I have made the changes as suggested in http://forum.virtuemart.net/index.php?topic=93021.new;topicseen#new

My code now looks like this:

foreach ($returnValues as $returnValue) {
if ($returnValue !== null  ) {
if ($returnValue == 1 )   {
//We delete the old stuff
JRequest::setVar('html' , $html);
// send the email only if payment has been accepted
// update status?
if ($new_status) {
    if (!class_exists('VirtueMartModelOrders'))
require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
    $modelOrder = new VirtueMartModelOrders();
    $orders[$orderID]['order_status'] = $new_status;
    $orders[$orderID]['virtuemart_order_id'] = $orderID;
    $orders[$orderID]['customer_notified'] = 0;
    $orders[$orderID]['comments'] = '';
    $modelOrder->updateOrderStatus($orders, $orderID); //
}
$this->sentOrderConfirmedEmail($order->getOrder($orderID));
$this->emptyCart();
} elseif ($returnValue == 0 )   {
    // error while processing the payment
$mainframe = JFactory::getApplication();
$mainframe->enqueueMessage($html);
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'),JText::_('COM_VIRTUEMART_CART_ORDERDONE_DATA_NOT_VALID'));

}
break;
}
//Returnvalue 'null' must be ignored; it's an inactive plugin so look for the next one
}


Still the exact same problem is existing. It does seem to be somewhat related to the cart not emptying as even after I have successfully made the purchase and returned to the site and I see "Thankyou for your order!" If I go back to the cart the cart still has the product(s) in it. It really should be empty if it was working correctly.

The order has gone into the system and is shown as pending only.

The return url from paypal looks like this http://www.mydomain.com/index.php?option=com_virtuemart&view=paymentresponse&task=paymentresponsereceived&pelement=paypal&pm=1 so theorhetically it should work...

Any further suggestions?

alatak

Hi,

If you did that modification it should work.

Stupid question, but i must ask for it: are you testing on a whebhosing or locally? Locally it will not work because Paypal cannot reach your web host.

Since it does not, can you do the following:
1) Set to Yes   the debug mode in the paypal payment.
2) Go in the logs folder and check the content of the file "paypal.log". It logs everything that it happening when receiving a notification.

If you don't have that file, may be you can check that Paypal is acctually calling you by checking your web site log.

You have a debug option in paypal configuration. Can you set it to on. And after look at the file in log/paypal.log ?




nicole2292

This is a live site on web hosting and using a real paypal merchant account and I am testing live payments with a different paypal account and a using real credit card. So everything is totally live, exactly as it needs to be for the store.
It's is waiting on going public until this issue can be resolved.

There is definitely something very serious wrong as there is nothing in my logs folder. Even after I have enabled debug and run through a live payment. You are talking about the normal logs folder in the root director of the Joomla installation aren't you? I have even made this logs folder 777 permissions in case permissions were the reason I have not logs at all.

As I said the return URL is http://www.mydomain.com/index.php?option=com_virtuemart&view=paymentresponse&task=paymentresponsereceived&pelement=paypal&pm=1
Isn't that all that is needed to tell Virtuemart the transaction has been successful? Doesn't that mean paypal is doing everything correctly and VM is just not doing the right thing with this URL?

I will point out again that I am seeing "Thankyou for your order!" on return to the Joomla site, although the cart has not been emptied after the successful transaction.

Your further help is greatly appreciated.

alatak

Hi,

QuoteYou are talking about the normal logs folder in the root director of the Joomla installation aren't you?
yes i am.

QuoteAs I said the return URL is http://www.mydomain.com/index.php?option=com_virtuemart&view=paymentresponse&task=paymentresponsereceived&pelement=paypal&pm=1
This is the retourn URL from paypa, but it is not this URL that will update the order status.
The order status is updated with a server-to-server call notification.

QuoteEven after I have enabled debug and run through a live payment.
The debug option in Paypal, logs everything that is going on when a notification is recevied. If there are no files called paypal.log, then maybe there is a problem with the notification.

Is your website blocked by an .htpassword? if so, then the notification cannot be executed.

To check that a notification is sent to your website, you have to inspect your website logs.

QuoteI will point out again that I am seeing "Thankyou for your order!" on return to the Joomla site, although the cart has not been emptied after the successful transaction.
The cart should be emptied. I will check that point, and give you feed back.

nicole2292

Hi Alatak,

Thanks again for your help.

The website is not not blocked by htpassword - it is literally a live site on standard web hosting. It's just not advertised to the public yet due to this issue. We just have a temporary index.html file in the root site directory.

I have no idea why this is not working on why there are no logs. The entire Joomla site and all other plugins work correctly on this server and for the most part Virtuemart works correctly as well - the standard payments work fine, just not paypal.

I'm really struggling here and getting quite desperate as I'm running out of options and I simply don't know what to do to get this site live for the client...

Nicole

alatak

Hi,

1)
Did you check that you are getting the paypal notification?
To check that you have to go on your web site.

2) if you get the paypal notification, then you should at least have the paypal.log file created.
The file is in [root]/logos/paypal.log



nicole2292

Alatak: I don't quite know what you mean by the "paypal notification". The paypal payments are going through perfectly. I receive emails that the payments are through and the money has been transferred. I'm not sure what other notification you are referring to.

All of the payment data is correctly stored in the database. If I go to the orders page in admin and view an order all of the payment data is stored in there perfectly.

Payment Method
Payment Name   Paypal
Full amount of the customer's payment   2.10
Currency   AUD
Invoice   58adf03f
eligibility   Ineligible
Unique customer ID   L8P8XJA34NLYN
Tax   0.00
Date/time of the IPN   23:53:15 Nov 22, 2011 PST
Payment_status   Completed
Customer's first name   Nicole
Customer's last name   REMOVED FOR PRIVACY
Transaction fee   0.35
Customer's primary email address   REMOVED FOR PRIVACY
Email address or account ID of the payment recipient   REMOVED FOR PRIVACY
Primary email address of the payment recipient   REMOVED FOR PRIVACY
Transaction subject   375b77d0ef16390e20eacce2e6c85bf0
ISO 3166 country code   AU

I have spent the entire day looking at this in between tearing my hair out and and contemplating throwing the computer out the window... oh and also wishing I had used proprietary ecommerce software as it would have worked out far easier and cheaper than this.

Needless to say I have not solved the problem. I have narrowed it down to the fact that if I look in the file plugins/vmpayment/paypal/paypal.php at the function plgVmOnPaymentResponseReceived the problem seems to be in there somewhere.

I have found that although the values are stored in the database as per above if I echo $html that the values for "Order Number" and "Amount" are actually empty. Even though they exist and were stored in the database just fine.
This seems to be the root of the problem. As if I manually define $paypal_data['invoice'] then it all works correctly and I recieve the order emails (albeit to the email address for the order / invoice number I have manually defined).

function plgVmOnPaymentResponseReceived(&$virtuemart_order_id, &$html) {
// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
$pelement = JRequest::getWord('pelement');

if ($this->_pelement != $pelement) {
    return null;
}

$vendorId = 0;
if (!($payment = $this->getPaymentMethod($virtuemart_paymentmethod_id))) {
    return null; // Another method was selected, do nothing
}
$params = new JParameter($payment->payment_params);
$paypal_data = JRequest::get('post');
$paypal_data['invoice'] = '26abf3c4'; //NICOLES NOTE: THIS MAKES IT WORK AND EMAILS ARE RECEIVED
$order_number = $paypal_data['invoice'];
$return_context = $paypal_data['custom'];
if (!class_exists('VirtueMartModelOrders'))
    require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number);
$payment_name = $this->getPaymentName($payment);
$html = $this->_getPaymentResponseHtml($paypal_data, $payment_name);
return true;
    }


So where to from here? Sorry my php knowledge is far to limited to take this any further and I simply cannot spend any longer on this. I am falling extremely far behind on my other work.

Therefore PLEASE PLEASE PLEASE can someone who has better php knowledge than me try to solve this ASAP.

Also I find it hard to believe no one else is having this issue as well. Surely I'm not the only one? Is anyone else having this problem?

mattprudente

Yes! I am having the same problems. Virtuemart isn't sending out order emails with the PayPal payment, but will send out when you use standard payment. The order details don't update to confirmed when paid either.

I've noticed similar questions asked throughout the forum, but no one has a response. I'm trying to figure out how to change the code to work, but like you I do not have a vast PHP knowledge. My clients are asking for a resolution to this problem.

Any help would be greatly appreciated here too!

fmp.martins

#10
Same problem here!

I've passed the last two weeks bug fixing VM2 stuff... Some bugs seem like the code was writen and no one even bothered to test it once!...
Anyway, this is the last bug I must fix for the go live, so all help is welcome...


Edit: I've just found out that after the payment has been made, if I don't click the "take me back to the store" link and wait the 10 seconds for the automatic redirect to get back to the store, it works fine!
I'm using Sandbox, since I'm still developing it.

Edit: I've just found out that sometimes the "click here" link does work as expected. The problem is that it is non-deterministic!
I've also analyzed the 2.0.1 build from 02/Feb but the problems seem to remain.

I've tried to trick it using different techniques, the last one is saving the data in the session and use it if it was not post back.
Here's what i've tried in plugins\vmpayment\paypal\paypal.php
- plgVmConfirmedOrder (just right  before the function return:
        $session_post =& JFactory::getSession();
   $session_post->set( 'backup_paypal_post', array_merge($post_variables, $dbValues) );

- plgVmOnPaymentResponseReceived just before any usage of $payment_data:
      // PayPal return bug hack!
      if (empty($payment_data)) {
                $session_post = JFactory::getSession();   
      $payment_data = $session_post->get('backup_paypal_post');
      $payment_data['mc_currency'] = $payment_data['currency_code'];
      $payment_data['mc_gross'] = $payment_data['amount'];
      }

Yep, I'm desperate here!... :D
With this ugly hack one has the information required to display the message on the screen...
But the mains problem remains...

alatak

Hi,

QuoteI've passed the last two weeks bug fixing VM2 stuff... Some bugs seem like the code was writen and no one even bothered to test it once!...
That is not true. We do test it :).

Can you please try this version http://forum.virtuemart.net/index.php?topic=96945.0, and tell me if your problem is still there?

John2400

Hi alatak,

I've just done a new updated site and am running - Joomla 1.7.5 and VM 2.0.1 (d) - versions .

* I did the test Payments and I receive all emails from my server sent - lots of ways,   except the Paypal shop order from VM itself.The Vendor nor Buyer receive an email from VM when Paypal payment option is chosen.

Once it goes to paypal site - Then that's their problem. ( i'm not concerned at present about the actual emails from them)

* All other payment opitions - send an email

* I can run the store after a paypal invoice comes to me by logging into my site and looking up orders in admin. ( so it will work)

* I see there might be other areas - in this post related to this in regards to confirmation etc - but that's different.

* Information _ In regards to paypal confirmation not changing orders in the backend

The old VM 1  would not chnge orders if ( you did not configure at least one email on the host server as real ie you can have as many forwarder eamils as you like but you must have one configured eg admin@snoopdog.com
The old VM always did not like the Paypal email account @snoopdog .com etc different from the paypal email login. Paypal liked them to be the same. Thus you often got emails bouncing back from paypal and not changing the status of products.
This is just in the old version - sometimes.


alatak

Hi,

Just to make sure that we are talking about the same thing.
The checkout worflow in VM2 is not the same as the workflow in VM1.
In the case of Paypal, the order email is only sent if a payment has been done. Not before.

Quote* I did the test Payments and I receive all emails from my server sent - lots of ways,   except the Paypal shop order from VM itself.The Vendor nor Buyer receive an email from VM when Paypal payment option is chosen.
In my test the emails are sent, so i need to understand what you have you done exactly in order to find out what is going on.

In paypal there is a debug option, that logs infos in a file in log/paypal.log. Can you turn that option on? and give me the output of that file?

John2400

Ok,  Is this true?

In VM 1 - Virtuemart sent the first lot of Emails to the vendor and the buyer.

In VM 2 - Virtuemart will only send the emails if and when a  correct payment is done and completed through Paypal?

VM 2 Virtuemart will then send an email after paypal emails have arrived as confirmed. ( That's two to the buyer in total and two to the vendor) Is this true?

* Back the front from VM1 or as Alatak says" different work flows"
----------------------------------------------------------------------------------------------------------------------------------------

* If this is so, were are trusting possible sales to the transaction in paypal - ( I have see in the past  lots of customers order through the payment Paypal - then forget their login or things go wrong .

The vendor would have receive the initial VM 1 email and has contacted them and finished the sale personally.

Am I correct in the first statements and just a though about the last.

Thanks

* Maybe a visual diagram of the work flow "payment for paypal" would clear this post up?