Paypal IPN from the sandbox not working

I spent two hours today trying to figure out why paypal wasn’t sending any instant payment notifications (IPN) to one of our new projects. Everything seemed right, I had notify_url in the form, the script could be accessed remotely, I had logging on for http and the script itself. After processing a payment I had 0 requests from the paypal servers hit our development server.

I read around various blogs and discussion forums for obvious problems, of which there are many (see below), but I was sure I had done everything right!

Eventually I stumbled across some posts on the paypal developers forum where a few posters were complaining that the sandbox IPN posts were either really slow (hours) or just never got sent. Worse still, there was one post where paypal acknowledged that payment notifications just did not work on the sandbox for two months!!

I used the IPN test in the sandbox area to test the script in the end. You have to type in the test values manually and you can’t test the entire process in one go but at least it got the job done. Needless to say, the single IPN tests work flawlessly. As one final test I used two live paypal accounts to send small payments to each other. IPN worked without a hitch on the live paypal site.

So, if you are stuggling to get IPN working and your logs show that paypal is not posting to your server, maybe this is your problem too. Before you assume it is however, I read of many other common issues that although blatantly obvious, many people (including myself) have often fallen for:

  1. I don’t know why, but some people were using URLs like http://localhost/ipn.php for the notify_url value. Their argument is that it works for the return url. The return URL works as localhost because paypal posts the value in your own browser, which can resolve localhost to the computer you are on. Paypals own servers obviously can’t!
  2. The ipn processing script was inaccessible (password protected, behind firewalls, etc). Make sure you can access it from outside your local network and that requests from paypal are in your web server logs.
  3. Certain types of escaping for the POST request to paypal can mean that paypal doesn’t understand the URL.
  4. The IPN processing script erroring before it can log any information. Make sure php/http/whatever logging is enabled for this script – logging is a god send for cases like this.

Hopefully you haven’t fallen for any of the above and its just paypal being crappy. In any case, I hope this post saves somebody a bit of time.