cainfoxy Posted August 22, 2013 Share Posted August 22, 2013 (edited) Resulta que al querer hacer el pago en mi tienda con paypal me daba el "error ocurred" sin ningún dato más. Pues ayer buscando como solucionarlo encontré que cambiando en SEO/URL la web "www.midominio.com a midominio.com" lo solucionaban. Me puse a ello y algo avanzó. Ahora no me da el error pero me aparece un mensaje de paypal diciéndome que en ese momento no me pueden aceptar el pago y que vuelva a la página del vendedor a ver si hay otro medio de pago. ¿hay solución? Mis versiones son: Prestashop: 1.5.4.1 Paypal: 3.5.8 Gracias. Edited August 28, 2013 by cainfoxy (see edit history) Link to comment Share on other sites More sharing options...
Sergio Ruiz Posted August 27, 2013 Share Posted August 27, 2013 He encontrado esto: http://www.prestashop.com/forums/index.php?/topic/208395-paypal-error-occurred/page__view__findpost__p__1150997 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. Link to comment Share on other sites More sharing options...
moraira Posted August 27, 2013 Share Posted August 27, 2013 vaya con Paypal, por el momento a mi con las mismas versiones me funciona sin problemas (euros) cainfoxy de donde eres, o mejor dicho con que moneda trabajas (principal) ? Link to comment Share on other sites More sharing options...
cainfoxy Posted August 27, 2013 Author Share Posted August 27, 2013 Hola Sergio, si, esa es la solución, anoche la encontré la puse en práctica y funcionó. Muchas gracias igualmente. Euros moraira, pero ya está, gracias. Link to comment Share on other sites More sharing options...
Recommended Posts