Jump to content

PayPal Error occurred!


sebow13

Recommended Posts

Prestashop 1.5.2.0 PayPal 3.4

 

Problem,

 

When you make an order on my website add all informations (full name, address, postal code, country, etc). After that, when you choose "Paypal" payment mode, Prestashop redirects you to a Paypal page with the amount of the cart. Great ! But I just have a problem. In the Paypal form last step where you have to click "confirm" you are being redirected back to the shop website with the message ERROR OCCURRED?

 

No payment has gone through!!! Please help as I can't sell anything.

 

 

www.andreascartersports.org

 

 

 

post-403489-0-14809600-1354577484_thumb.jpg

Link to comment
Share on other sites

I am seeing this error with PayPal and Moneybookers/Skrill. With skrill i end up in the code branch for error/unknown and as far as i can tell those payments do make it through.

I tried to find the code responsible for handling errors in paypal so it would print the entire $POST but i could not find it.

All i get is <h2>Error occurred:</h2>. According to the template it is supposed to list all the errors but it doesn't write anything

Link to comment
Share on other sites

  • 1 month later...

new install of 1.5.3.1 - PP module supplied in zip did not work - generated incorrect security header - out of desperation and lack of support/documentation - updated to new version 3.4.4 and works fine first time. Could also be an install issue - try deleting module entirely, downloading a new 3.4.4 and reinstall.

Link to comment
Share on other sites

  • 1 month later...

We were also experiencing this problem on Prestashop 1.5.3 using the latest PayPal Module version directly from GIT (as of 2013-03-20) only on our production server.

The Paypal express checkout would load with our cart contents, and allow us to login via paypal and pay for the order, however when returning to the store, an error would appear stating "ERROR OCCURRED:" with no log information.

 

How this error comes up

 

From debugging, our system was arriving at this error because /modules/paypal/express_checkout/payment.php was not "hitting" any of the conditions in the file, and instead exited via the else statement on line 344.

This is normally used when Paypal has returned an error; $ppec->logs would contains the errors and these would be put out to the screen, however PayPal had no errors to report in our case.

Looking at the code, we should have been taken in by the if condition on line 146 (see the comment preceding it), but we were not.

 

Debugging the error

 

We added the following two calls on line 100 to show us the values. This will firstly show us if PrestaShop is receiving the response from PayPal, and secondly what PrestaShop has stored for use in the conditions on line 146.

 

var_dump($_REQUEST);

var_dump($ppec);

 

Simply compare the contents of ppec's "token" and "payer_id" fields to what's received in _REQUEST.

If ppec has an empty token or payer_id, you've got the same bug I had, and please continue reading.

If instead you find _REQUEST is empty or incomplete, check your Network tab and ensure you haven't been redirected and you've lost the query variables from Paypal along the way (htaccess rewriteRule being the usual culprit here).

 

The PayPal module sends you to PayPal in the file /modules/paypal/express_checkout/process.php using the function redirectToAPI(). Inside this function, before the redirect to paypal, it calls _storeCookieInfo() which writes token and payer_id to the users cookie.

 

The Bug

 

Under some versions of PHP, PrestaShops method of saving the users cookie - which is to write the contents during the Cookie::_destructor - does not work. It flat out does not write the cookie reliably. I've documented this elsewhere in the past and it really should be addressed, but on later version of PHP (eg. 5.3) it's perfectly fine.

 

Notice in _storeCookieInfo() and redirectToAPI() there are no calls to cookie->write(). This code relies entirely on the Cookie::__destructor method to save the cookie data.

 

Our specific version is PHP 5.2.6 with Zend Engine 2.2.0 and ionCube 3.1.29 on a derivative of CentOS, in case you're wondering.

 

The Fix

 

Around line 420 of /modules/paypal/express_checkout/process.php, before the closing bracket of _storeCookieInfo(), add the following line:

 

$this->context->cookie->write();

 

This causes the cookie to be written before you're sent to paypal. When you come back, you'll now have the correct data stored and PrestaShop will recognise the request.

 

Further Reading

 

If this didn't solve your problem, I feel sorry for you because this has taken me far too long to debug.

If this did solve your problem, chances are you'll have additional issues with PrestaShop in its current configuration. Consider reading my other post on PrestaShop Cookies to address similar issues with Add to Cart and Login problems.

 

Final Thoughts

 

The PayPal modules validation should really be improved to catch this specific instance.

The check that's there is obviously to verify that the inbound users payer_id and token match that of the outbound user, but there's no alert for the user if the stored payer_id or token are empty are invalid.

 

Surely if you're inbound with a payer_id and token but ppec is empty, this means something has gone wrong and the user badly needs to know about it, because as far as PayPal is aware, that payment has gone through, but the order has been now been lost by PrestaShop.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi,

same problem for me on PS 1.6.0.8 and Paypal 3.7.2

 

I have set paypal express checkout, when the client selects a product quantity greater than the available quantity and click on Paypal button then appears the error page, but just with "Error occurred:"

 

I have edited the code of modules/paypal/express_checkout/payment.php

added

if(count($ppec->logs) < 1 ){
	$ppec->logs[] = $ppec->l('Problem with the product, check the quantity you have selected');
}

after line 383

 

how it appears my code:

/* Display result if error occurred */
else
{
	if (!$ppec->context->cart->id)
	{
		$ppec->context->cart->delete();
		$ppec->logs[] = $ppec->l('Your cart is empty.');
	}
	if(count($ppec->logs) < 1 ){
		$ppec->logs[] = $ppec->l('Problem with the product, check the quantity you have selected');
	}
	$ppec->context->smarty->assign(array(
		'logs' => $ppec->logs,
		'message' => $ppec->l('Error occurred:'),
	));

	$template = 'error.tpl';
}
  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Hello all.


 


I started having this same problem on a Prestashop v1.5.6 (with PayPal v3.6.6) store a few days ago. In my search for a solution I landed on a lengthy thread dating back to 2012 and went through all 13 pages of it. From what others were saying, the conclusion was that there was some communication problem between PayPal and the affected sites/servers.


 


I did as suggested by a few and create a clone of my site on a server at a completely different web host (in a country on the other side of the globe) but the problem persisted. Then I decided to test another Prestashop store (v1.3) I have on the original server. That one is still using PayPal v1.0. I found that PayPal checkout was working fine on this site with the older PayPal module.


 


This led me to conclude that it was not the server but something to do with the PayPal module. I did a Google search for the phrase "paypal api update 2015". This eventually led me to one of PayPal's Technical Support page: https://ppmts.custhe...2/kw/prestashop which states: 


"As of January 12, 2015 at 12:01 a.m. Pacific Standard Time (PST), PayPal has discontinued support for Secure Socket Layer version 3 (SSL 3.0)"


 


Scrolling down to the Prestashop link took me here: https://www.prestashop.com/forums/topic/380185-paypal-modification-ssl-v3-to-tls/


 


I followed the instructions on that page to manually update my PayPal module to v3.8.1 and voila! the PS v1.5.6 store is working perfectly on both servers.


 


Hopefully this will be of help to my fellow PS users.


Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...