Testing paypal recurring payments using the IPN simulator

17 October 2013

Testing paypal recurring payments using the IPN simulator

Testing payment systems is a real chore. Most payment systems allow for 'test mode' or some other variable to test them, but generally this involves going through the motions of making a payment via their payment system just to try out a small change in your callback detection scripts. 

Paypal makes this process a lot easier by providing an IPN  simulator. The IPN simulator is used to fire an instant payment notification post to your webpage. In the simulator, you enter the url of your listener (the script or web page used to process the form post) and then select the payment type from a drop down list. Depending on which payment type you select, a number of pre-filled fields appear which are the most common ones used for that payment type.

Unfortunately, if you want to testrecurring payments, there is no default option in the IPN simulator for this particular transaction type. here you have two options:

1. Change the value of Txn_type field 


Select 'express checkout' from the drop down in the transaction type, then check the 'show all fields' check box. Then, in the txt_type field enter one of the following:

recurring_payment_profile_created - for when profiles are created or,

recurring_payment - for the payment itself

This will allow you to simulate a basic IPN call, which you can use to test your listener is responding to the correct event.

However, there are more fields that are sent in the IPN for recurring payments than are available in the IPN simulator, these are:


Variable Name



Amount of recurring payment


Amount of recurring payment per cycle


Initial payment amount for recurring payments


Next payment date for a recurring payment


Outstanding balance for recurring payments


Payment cycle for recurring payments


Kind of period for a recurring payment


Product name associated with a recurring payment


Product name associated with a recurring payment


Profile status for a recurring payment


Recurring payment ID


The merchant’s own unique reference or invoice number, which can be used to uniquely identify a profile.

Length: 127 single-byte alphanumeric characters


When a recurrng payment was created

The full list of variables sent with recurring payments IPN is available here.

If you want to test your listener with all these fields, you will have to go with option 2 below:

2. Simulate a subscription

What you need to do here is to go through the process of creating a subscription via your site - the easiest way to do this is to create a subscription button which takes you through to paypals subscription process. The code for this button looks something like this:

<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="me@mybusiness.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="a3" value="5.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">

Where a3  is the subscription amount, t3 is the time period ("d" = days, "m" = months, "y" = years) and sra is the number of times the payment is repeated. Note the form url is https://www.sandbox.paypal.com/cgi-bin/webscr - for live testing, remove the 'sandbox' part of the url. Make sure you replace me@mybusiness.com with the email address of the text account that you have set up in the paypal sandbox. If the email address is not correct you will get a message saying "The link you have used to enter the paypal system is invalid" - you might also get this error message if you are not using the sandbox url for the form action.

Once you have created this button and added it to a test page, you can set up a recurring payments profile. I would recommend that you set the d3 field to "d" and the p3 field to "1" which will automatically post a recurring payment once per day. You can remove these payment notifications once you have made sure that your system is working correctly.