IPN Easy.NET - Demo Framework
How To Setup Your Test Environment
Requirements
You need to ensure that PayPal can send IPN messages to your local test / dev machine.
There are 2 ways of achieving this:
- You development /test machine need to have a public IP address.
- Your router (with a public IP) can be configured to route PayPal IPN messages to your local dev/test machine.
Here, we describe how to setup the PayPal Sandbox to send IPN messages to a machine that sits on a private network that is connected to The Internet via a router.
Step 1 - Find Your Public IP Address
Identify your public IP by clicking "What's My IP Address?".
Make a note of this.
Step 2 - Configure PayPal Sandbox
Logon to the PayPal Sandbox.
PayPal IPN Setup Example
- In "Test Accounts", logon to your sandbox account that you use to receive payments.
- Click Profile
- Under Selling Preferences, click Instant Payment Notification Preferences.
- Click the Edit settings button.
- In Notification URL, enter the public IP details (see Step 1). For example, if you are testing the database storage capability of the demo framework, the Notification URL might be something like http://81.45.12.128/Database.aspx.
- Select the radio button Receive IPN messages (Enabled).
- Click the Save button.
PayPal is now setup to send IPN messages to your test machine.
Step 3 - Setup Your Router
Your router connects your dev / test machine to the Internet. PayPal will send IPN's to your router and you need to tell your router to forward IPN requests to your local dev / test machine.
Setup your router configuration (refer to your router documentation on how to do this) to use port forwarding (or redirection) to send TCP traffic on public port 80 to your dev / test machines private IP at a port of your choice (e.g. we use 8081). A typical configuration might look like this:
Router NAT Port Redirection Rule
TCP Public Port 80 --> 192.168.1.2 (Port 8081)
Step 4 - Setup Your Firewall
You need to open a port in your dev/test machine firewall. Use the port that you assigned in step 3 and add a firewall exception for this TCP port in your Windows firewall rules. For more information on Windows Firewall, please see the appropriate topic in your Windows help topics.
Step 5 - Setup IIS
In IIS Manager, create a new web site defined as follows:
Example IIS7 Setup
- Site Name: - IPNEasyDemo
- Physical Path - {The path to the folder that you installed IpnEasyDemo Visual Studio files to}
- Binding - IP Address: All Unassigned, Port: the port that you assigned in step 3
- Host name: - leave empty
Step 5a - Setup SQL Database
In the ~/App_Data folder there are 3 files:
- PayPalIpn.mdf & PayPalIpn.ldf - Optional use for SQL Express User Instance database connection (not recommended).
- PayPalIpn.sql - SQL script to create PayPalIpn database and all associated objects. Load and execute this file using SQL Management Studio.
Note: If you choose option (1 - SQL Express User Instance), check the permissions on SQL database files PayPalIpn.mdf and PayPalIpn.ldf. These both need modify permissions granted to the NETWORK SERVICE account.
If you receive the following error message, you need to fix permissions as described above:
An attempt to attach an auto-named database for file {whatever your path is}\PayPalIpn.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Step 6 - Setup Visual Studio
Configure Visual Studio to use IIS to run the demo framework as follows:
- In Solution Explorer, right click and select "Properties".
- Select the "Web" tab on the left hand side.
- Click the option Use Local IIS Web Server.
- The ProjectURL is something similar to http://localhost:8081/ (substitute your port number as appropriate).
Step 7 - Getting PayPal to Send IPN
There are two options:
Option 1 - Create a PayPal Button
In your PayPal Sandbox account, create a payment button using the PayPal "My Saved Button" tool. Copy / paste the button code into any HTML file (you can host this locally - for example on your desktop).
This method has the advantage that you can create multiple items from a shopping cart as well as test subscription based buttons.
Option 2 - The PayPal IPN Sandbox Test Tool
You can use the PayPal Sandbox test tool. However, we found this to be fairly restrictive in terms of multiple cart items and it's inability to create subscription based IPN's.
Step 8 - Complete
Your test environment is now ready to run. Send some IPN's from PayPal and use the Visual Studio debug environment options to see exactly what's going on.