Darkmarauder Posted August 12, 2008 Share Posted August 12, 2008 After creating the first order on my website, using Paypal I completed the checkout without any problems.I checked the Paypal account used and the money had transferred as expected (so no Paypal problems).When I return to my store, and the account I used to make the transaction I had a problem.When going to 'Order History' it shows no orders listed and shows the message:-'You have not placed any orders'.Now for me thats not a problem, but I can see users of the shop panicing somewhat at getting that message!Any help? Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 I've been working on this today, and it looks to me like there's a bug in the paypal payment module.In the forum sent to paypal, the return_url field is being sent the url to validation.php.The url for validation.php should be sent in a notify_url field in the form I think. This would also mean that you won't have to specify it in your paypal account; which is what you do according to threads I've read on here, but that's only because of the error in the paypal module, and is a work-around. e.g. here: http://www.prestashop.com/forums/viewthread/3257/ I could be miles out.... but you could try editing paypal.tpl for now and change "return_url" to "notify_url" and see if that helps. I'll have a closer look at the paypal documentation mean time and confirm my suspicions.This should also mean that you can run multiple stores from one paypal account.PaulUpdate 16:19 12/08/2008: From the Paypal documentation: PayPal posts HTML FORM variables to a program at a URL you specify. You can specifythis URL either in your account profile or with the notify_url variable on eachtransaction. This post is the heart of IPN. Included in the notification is the paymentinformation, such as the payer’s name and the amount paid. All possible variables in IPNposts are detailed in the Order Management Integration Guide.When your server receives anotification, it must process the incoming data. Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 You should also add an additional value to the form names "rm" and a value of "1" This will set the return method, which should get paypal to send your customer back to the correct page.i.e. the end of paypal.tpl should read: <input type="hidden" name="notify_url" value="{$returnUrl}" /> <input type="hidden" name="rm" value="1" /> </form> Link to comment Share on other sites More sharing options...
ken Posted August 12, 2008 Share Posted August 12, 2008 HiThere is certainly something wrong, but I am not sure where.I now have the cart moving to orders and the payment is received OK but the IPN fails with Warning: fsockopen() [function.fsockopen]: unable to connect to www.paypal.com:80 (Connection refused) in /home/www/mysite.co.uk/modules/paypal/validation.php on line 21 And this causes an email to be sent to the customer saying that there is a payment errorHere are some checks to make1) check your permissions.Put this into your browserwww/mysite.co.uk/modules/paypal/validation.phpif you get a Error 500: Script Execution Failure. Then your permissions are set too highlower the permissions to 775 or 755 until the error goes away.2) Check your host supports fsockopenCreate a php file and put this in <?php if(function_exists('fsockopen')) { echo "fsockopen function is enabled"; } else { echo "fsockopen is not enabled"; } ?> Upload it to the server and run it.3) Check the port is openGo here to check port 80 is openhttp://webtools.live2support.com/nt_cport.phpI just had a reply from Paypal who say this Below should be the one you want:$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);You want to compare your IPN script with below:https://paypaltech.com/SG2/Please reply if you have further questions. However this still does not resolve the problem. It just gives a similar error Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.paypal.com:443 (Connection refused) in /home/www/mysite.co.uk/modules/paypal/validation.php on line 26 @PaulPaul your fix did not work Could the problem be caused by the “/”ie.home/www/mysite.co.ukAnd should the www be added as amwdesign suggest in the link aboveWe need to get this sortedRegardsKen. Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 Does the following url work? (assuming that presta is installed in the root directory of www.mysite.co.uk)e.g. http://www.mysite.co.uk/modules/paypal/validation.phpIf the above url doesn't work, then that's the problem. The fix I posted wasn't related to this, it takes care of the configuration of the IPN return url without the need to specify it in your paypal account. return_url doesn't exist as far as paypal are concerned, whilst the notify_url one should be sent with the url paypal should send notifications to.Its now been tested and works. We have two PrestaShops working off one paypal account now.Paul Link to comment Share on other sites More sharing options...
pcbob Posted August 12, 2008 Share Posted August 12, 2008 I set up the paypal IPN as instructed by prestashop and then made the modification to the paypal.tpl<input type="hidden" name="notify_url" value="{$returnUrl}" /> <input type="hidden" name="rm" value="1" /></form> it was tested live and all worked well. - order in shop, email to customer, email to admin.You will need to add an IPN email so paypal can tell you a payment has been made.Not sure about the auto return as the tester clicke the button and went back to the site manually.Hope it helpsBob Link to comment Share on other sites More sharing options...
ken Posted August 12, 2008 Share Posted August 12, 2008 Putting http://www.mysite.co.uk/modules/paypal/validation.phpinto my browser gives the errorWarning: fsockopen() [function.fsockopen]: unable to connect to www.paypal.com:80 (Connection refused) in /home/www/mysite.co.uk/modules/paypal/validation.php on line 21Adding your fix or pcbob’s does not helpKen Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 It should configure the paypal url as :https://www.paypal.com/cgi-bin/webscrfor production, orhttps://www.sandbox.paypal.com/cgi-bin/webscrfor the sandbox. What's at line 24 in paypal.php?Paul Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 Sorry ignore the previous post I misread you. It's the validation that isn't working. It looks like your server should fail when using the script you posted regarding the test for fsockopen function?If this is the case, then you'll need to fix THAT. Nothing to do with prestashop itself.If the test works, then it isn't allowing connections outwith your machine, so that needs fixed.You're not with siteground by any chance? http://kb.siteground.com/article/Php_fsockopen_problems.htmlPaul Link to comment Share on other sites More sharing options...
ken Posted August 12, 2008 Share Posted August 12, 2008 Agreed. But the script does NOT failThis is what I can’t understandI am using Awardspace.com and osCommerce was working OK.Ken Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 osCommerce will use curl instead of fsockopen, so that may be why it worked before but not now. I can have a look at a modified version of paypal.php that tries both methods if you like, and we can see if that works?Paul Link to comment Share on other sites More sharing options...
ken Posted August 12, 2008 Share Posted August 12, 2008 Thank You Paul.That would be great.I have read about a lot of people having this problem and from what I have read curl should solve itAll this is beyond my programming skills so I would be most grateful if you find a solutionRegards.Ken. Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 I've got a spare hour or two tonight, so I'll have a go at putting something together now.Paul Link to comment Share on other sites More sharing options...
Paul C Posted August 12, 2008 Share Posted August 12, 2008 Ken I've sent you a PM with a modified version of validation.php (not paypal.php as I stated earlier - need to get some sleep some time I think).Paul Link to comment Share on other sites More sharing options...
ken Posted August 12, 2008 Share Posted August 12, 2008 Hi Paul.Thank you very much for re-coding the validation.phpI thought it was going to work because http://www.mysite.co.uk/modules/paypal/validation.phpNo longer gives an errorHowever with a test purchase the customer still receives this message Hi name,Your order #7 historyThere is a problem with your payment for order #7. Please contact us at your earliest convenience. Your order will not be shipped until we have resolved this problem. You can review this order and download your invoice from the "Order history" section of your account by clicking "My account" on our website. And in back officeWarning: £ 0.00 paid instead of £ 9.95 The payment error message has changed from(2008-08-10 22:37:30) [Private]: Impossible to connect to PayPal server with Prestashop validation.phpto(2008-08-13 02:54:43) [Private]: PayPal payment not set to VERIFIED but: With your validation.phpSo I think you are very close to fixing thisI hope you can find the problem?Regards.Ken. Link to comment Share on other sites More sharing options...
Paul C Posted August 14, 2008 Share Posted August 14, 2008 Just to let anyone following this thread we are still working on it (communications via private messages don't help folks viewing this thread stay in the loop)! I have a version of the module that will now use cURL to connect to paypal should fsockopen fail (resulting in the "Impossible to connect to PayPal server" error message). This has been tested (via the sandbox) using both methods and they operate correctly in my test environment.If only we could get it to work on Ken's site now....@Ken: I've placed a new version (today) on your site, with some improved error checking that may hopefully shed some more light on what exactly is going wrong, if it indeed fails again (as I suspect it will).If anyone would like a copy of my current version please PM me an email address and I'll send it on, although it's still work in progress. Maybe another pair of eyes could spot any errors in there.After spending so long looking at the PayPal module I think I'll write an alternative one though, as there are several areas where the current one produces misleading error messages etc. and it could be greatly improved upon.Paul Link to comment Share on other sites More sharing options...
ken Posted August 15, 2008 Share Posted August 15, 2008 HiThanks Paul for all your help. The code is working perfectly.The new code is much improved on the original verification code.It can connect with fopen or cURL and will be invaluable to all the people who do not have fsockopen() enabled (GoDaddy ??)Thanks Again.Ken Link to comment Share on other sites More sharing options...
Paul C Posted August 15, 2008 Share Posted August 15, 2008 Thanks Ken,I've uploaded the code here for anyone that wants to try it out:Paypal IPN modified versionPaul Link to comment Share on other sites More sharing options...
bond Posted August 16, 2008 Share Posted August 16, 2008 Tried the new file and still getting the message about no orders after i purchase something and also after purchasing some products i still have those products on my cart...Still have that IPN error 500 when testing paypal. Link to comment Share on other sites More sharing options...
Paul C Posted August 16, 2008 Share Posted August 16, 2008 That's more likely to be a permissions error on the files or a .htaccess setting that would cause an HTTP 500 error. Fixing it will depend on the server configuration. I would suggest that the permissions on the files in the /modules/paypal directory should be 644 (i.e. paypal.php, validation.php etc.). The directories from the root downwards should be 755 (i.e. /modules and /modules/paypal if your shop is in the root directory). If those don't work then slowly relax the permissions (e.g. 664 for files and 775 for directories). Temporarily rename any .htaccess files during your testing too (turn off friendly urls in the back office while you test to prevent errors caused by having it switched on with no corresponding .htaccess entries.). You may not even see .htaccess files listed your ftp client depending on how the server and client are set up. If in doubt (and you don't have SSH access to the server) you could always get your hosting company to check.While changing permissions use http://www.example.com/modules/paypal/validation.php as the test url. You should get a blank page when everything is working correctly (as detailed in the thread I referenced earlier).PHP files shouldn't need the execute bit set (e.g. 755 or 775) but if all else fails I guess your server could be configured that way also. I'd leave that as a final option though if all else fails.Paul Link to comment Share on other sites More sharing options...
bond Posted August 16, 2008 Share Posted August 16, 2008 Thanks.Just did a test and now it shows : IPN delivery failed. HTTP error code 404: Not Found I'm getting a blank page when typing the url. Link to comment Share on other sites More sharing options...
Paul C Posted August 16, 2008 Share Posted August 16, 2008 Where is that error from? I may be useful to post or PM a url to the site too, so I can have a browse myself. Sounds like something isn't configured correctly.Paul Link to comment Share on other sites More sharing options...
bond Posted August 17, 2008 Share Posted August 17, 2008 Success!I changed the permissions like you said and it worked!Thanks! Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 24, 2008 Author Share Posted August 24, 2008 When I originally posted this topic I was originally after a resolve to a problem witht items not showing in the order history when returning to my shop after making a purchase via Paypal.I've followed the first steps, with the modification and addition to the paypal.tpl file.I haven't noticed any changes, and the same issue is occuring.Apologies for not posting earlier, been a bit busy here.Any ideas? Link to comment Share on other sites More sharing options...
Paul C Posted August 25, 2008 Share Posted August 25, 2008 Howdy there,I suspect what you'll find is that the purchases DO eventually appear, just not immediately when the customer returns to your store from paypal?I've been working on a much enhanced paypal module that should address this issue too, although it's slightly more complex, and I'm still testing the combinations. This problem is particularly severe when payments are made via eCheck or when the paypal payment is pending for another reason (e.g. if you haven't set it to automatically convert currencies in paypal and the customer pays in a currency other than your default).The way paypal works is asynchronously (it goes off and authorises the payment out-with the PrestaShop payment execution path). PrestaShop is synchronous in nature, so expects paypal to get there at the same time your customer does.The way the default paypal module works is that it creates the order when it receives the "Payment Complete" IPN, but it ignores all the other IPN messages..... It also doesn't even create the order until it receives this one single valid IPN. Even for instant payments straight from a paypal account this can be 30seconds or a few hours, depending on how busy the paypal service is!I'm attempting to get around this by creating a "Paypal Processing" status message and creating the order at the same time your customer leaves to pay with paypal. That way, you'll at least see that the order has been placed, and is awaiting authorised payment. I've also implemented the other IPN messages to update the order as it progresses through paypal.I hope to get at least a BETA version of this out this week. If you fancy testing it out to check that it's addressing the problem you have, then drop me a PM.Paul Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 25, 2008 Author Share Posted August 25, 2008 Unfortunetly after about 8 hours, I've logged back on to the account that I used to make the purchase and the order history still shows the 'you have not placed any orders' message.I have checked and the money was instantly transferred from one paypal account to my shop paypal account. No pending or echeck messages.Anything else I can try in the meantime? Link to comment Share on other sites More sharing options...
Paul C Posted August 25, 2008 Share Posted August 25, 2008 Can you access the following page in your browser? http://www.example.com/modules/paypal/validation.php If so then the last thing to check is whether your hosting company firewall is blocking outgoing connections.To test, create a file called "paypal_test.php" containing the following: <?php /* Paypal connection test script for paypal payment module Author: P. Campbell Version: 1.0 ; August 2008 */ $fsocket = false; $curl = false; $result = false; $cURL_connect = false; // Test for curl support on the server if (function_exists('curl_exec')) { $curl = true; } // Try a secure fsockopen connection and if not, then the worst case insecure fsockopen // only use the insecure method if nothing else (secure fsockopen or cURL) works! // The insecure sock should be removed for production servers. if ( (PHP_VERSION >= 4.3) && ($fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30)) ) { $fsocket = true; } elseif ( ($fp = fsockopen('http://www.paypal.com', 80, $errno, $errstr, 30)) && (!$curl) ) { $fsocket = true; } elseif (!$curl) { echo 'Can\'t make external connections to paypal using any method.'; } // ***************To test curl when fsockopen works, uncomment the two lines below //$fsocket=false; //if ($fp) fclose($fp); if (($curl) AND (!$fsocket)) { $ch = curl_init('https://www.paypal.com/cgi-bin/webscr'); // If the above fails, then try the url with a trailing slash (fixes problems on some servers) if (!$ch) $ch = curl_init('https://www.paypal.com/cgi-bin/webscr/'); // Error checking if ($ch) { $cURL_connect=true; curl_close($ch); } else { $cURL_connect=false; echo 'Failed to connect to paypal'; } } if (($fsocket) || ($cURL_connect)) { echo 'Connection to PayPal OK'; } else { echo 'Connection to PayPal Failed'; } ?> Place the resulting file in the root of your server, then go to the following: http://www.example.com/paypal_test.php If your server communications with Paypal is working the above should print the message: 'Connection to PayPal OK' otherwise it will display 'Connection to PayPal Failed', or 'Can't make external connections to paypal using any method'.Let us know how you get on Paul Link to comment Share on other sites More sharing options...
DrÿSs' Posted August 25, 2008 Share Posted August 25, 2008 Hi all,We have added curl(), secure fsockopen() and notify_url support to our PayPal module, as Paul C made it.Thanks to him and our community,Coming in release 1.1. Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 25, 2008 Author Share Posted August 25, 2008 When I use the link http://www.example.com/modules/paypal/validation.php I get the following error message:-'500 Internal Server Error'The server encountered an internal error or misconfiguration and was unable to complete your request.After checking the file does exist in the path I have chosen, so maybe a permission issue? Link to comment Share on other sites More sharing options...
ken Posted August 25, 2008 Share Posted August 25, 2008 Hi DarkmarauderApologies for mis-reading your initial postThe ‘500 Internal Server Error’ is caused by permissions.Try lowering them.See post 3 (step1) of this thread.Hope this helpsKen Link to comment Share on other sites More sharing options...
Paul C Posted August 25, 2008 Share Posted August 25, 2008 Or try raising them :-) It depends on semantics! 755 for directories /modules and /modules/paypal and 644 for validation.php should work.Setting the execute bit on files can cause server 500 errors.Paul Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 25, 2008 Author Share Posted August 25, 2008 Sorry, tried changing the file attributes to validation.php and still got the 500 error message.- One question:- what is the fault level (644, 755, 775 etc) that the modules/paypal folder should have?I ask this as I suspect I may have flowed rights down to the file level rather than just the folder itself. Link to comment Share on other sites More sharing options...
Paul C Posted August 25, 2008 Share Posted August 25, 2008 As per the previous post, the module directories should be 755 (rwxr-xr-x) and all module files should be 644 (rw-r--r--). If that doesn't work, then there's another (server configuration) reason for it not liking that page, which is strange. Are you using the "friendly urls" option?Paul Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 25, 2008 Author Share Posted August 25, 2008 I thought I'd ask about the permissions just to double check.I've now resorted the permissions as per your comment, and when I now type in the http://www.mysite.com.....validation.php the screen goes blank, but no error message.Is this good or bad?Also, i'm not using friendly urls, that I am aware of. Link to comment Share on other sites More sharing options...
Paul C Posted August 25, 2008 Share Posted August 25, 2008 A blank page is exactly what you want! If you do a test purchase now, then it should work fine (although the order may take a little while to appear, as I indicated earlier).Paul Link to comment Share on other sites More sharing options...
Darkmarauder Posted August 25, 2008 Author Share Posted August 25, 2008 Yes, just tried a test purchase and it all works fine. Thank you very much for the help. I was relying on using Paypal until my store gets more popularity so you've saved me there.Thanks again! Link to comment Share on other sites More sharing options...
MikeR Posted September 4, 2008 Share Posted September 4, 2008 Got mine workin gtoo.After many problems - some of which were paypals fault and I happend to pick a time when there were kicking out a 30mins delay !!Any way chuffed now.thanks Link to comment Share on other sites More sharing options...
Paul C Posted September 5, 2008 Share Posted September 5, 2008 I'm afraid the fun isn't over yet (particularly after the IPN delays from PayPal yesterday, which just highlights this issue further) you folks may want to have a read of this (the important bit is at the end!) and volunteer!http://www.ecartservice.net/20082008/improving-paypal-prestashop/Paul Link to comment Share on other sites More sharing options...
chrischnian Posted October 19, 2008 Share Posted October 19, 2008 Hi folks I have here a big problem.When I shop in a customer makes an order then everything runs smoothly.The customer selects PayPal, and everywhere else is done everything right.Now, the data from customers and also the price and all true.The Pay with PayPal goes so far.Only in the last step where the button is "back to the dealership" comes the mistake.I as a customer come directly into the history.php and the appointment comes a "payment error"I've tried different now and no result found the scripts of "http://www.ecartservice.net" resolve the problem can not!Now the test script brings the message that it was able to successfully connect.Please team of PS if you already have a new module, then send it by mail through because the store is to go online and otherwise I would like to test you need to report errors.GrussChris Link to comment Share on other sites More sharing options...
chrischnian Posted October 20, 2008 Share Posted October 20, 2008 Ok I have now again the beta of 2.0 Paypal downloaded and uploaded and installed. The payments come now. But now is my price for shipping is always free to set so 0 €.Who ever had the problem? Link to comment Share on other sites More sharing options...
Nakano Posted December 23, 2008 Share Posted December 23, 2008 Good thing I bookmark these troubleshooting pages... I got this problem again and was about to start pulling my hair out . Paul's advice is correct, but the Wiki Page still insist While you have your FTP connected to your Web hosting server, make sure the following PrestaShop folders have ‘write’ permissions (also known as “CHMOD 777” – explanation of file permissions here) but do not apply these permissions recursively (to their subfolders): /config, /upload, /download, /tools/smarty/compile. Then make sure the following folders have ‘write’ permissions and apply these permissions recursively (to their subfolders): /img, /mails, /modules, /themes/prestashop/lang, /translations.This was written on 30 June 2008, and with 1.1 Final out, maybe it's time to correct this, Prestateam, or more people will run into these kind of problems. Link to comment Share on other sites More sharing options...
Recommended Posts