How to Test PayPal Instant Payment Notification (IPN)
Some of the questions I see most in the PayPal developer forum regarding IPN is how to initially configure it and test it. In a previous blog I posted a PHP IPN template that you can use to get passed most of the configuration hurdles. Testing your solution is another story, though. Here are the steps I like to take to ensure flawless IPN integration.
1 – Local IPN Testing
The first thing I do is create a local HTML form that consists of hidden fields which resemble the same thing PayPal’s system would post to my server when an IPN occurs. Here’s a sample.
When testing this way, the IPN script will run through your Invalid IPN code because the post did not come from PayPal’s server. As such, you’ll need to adjust your IPN script to force a Valid response. If you’re using my IPN template you can adjust line 56 to…
if(strcmp ($res, “VERIFIED”) == 0 || 1 == 1)
Then, simply set the action of the form to your IPN listener and then submit it. This way you’ll be able to see the on-screen result of your IPN script and can easily troubleshoot any errors that may exist. You can add or remove any fields you’d like from the test form and you can adjust the names according to what fields you expect to get from the IPN you’re testing for. Once you’re able to successfully run your test IPN within a browser without any errors you can remove the forced Validity and move on to the next step.
2 – PayPal Developer IPN Simulator
PayPal provides an IPN Simulator from within your developer account. You can use the simulator to easily send test IPN’s to your server for a number of different scenarios. At this point you’ll just need to make sure your IPN script is configured to run on the sandbox servers (see the notes at the top of the IPN template) and then these IPN Simulator posts will validate because they are indeed coming from PayPal’s server. Once these simulated IPN’s are working as expected you’re ready to launch.
3 – Deploy
At this point you’re ready to set your IPN script to production mode instead of sandbox mode and then upload it to your live web server. You can enable IPN within your PayPal profile or you can also include the NotifyURL field in your standard payment buttons or API requests to PayPal.Tags: how to test paypal ipn, instant payment notification, ipn, paypal