Reoccuring payments Paypal Express Checkout and IPN payments

flynny used Ask the Experts™
Hi all,

I would just like some clarification on Paypal Payments and setting up reoccuring IPN payments.

Basically, I have a site whereby I will offer a service for a monthly reoccuring fee.

The user will fill in the signup form and then be taken to a Paypal Express Checkout button.

Initially they will be given 30days of the service free. But to complete the signup obviously I want them to sign up a reoccuring payments to be transferred each month once this 30 day trial is complete.

1. Is it possible and how would I set it so that the user logins into paypal and sets up the reoccuring payment.
2. Is it possible to set a limit on the cancellation of the reoccuring payment, i.e. 1 week (so for example if the user cancels on the 1st it would remain until it is deleted on the 8th).
3. I assume then when the payment is sent over (each month) I will need to tell paypal to send across an IPN to my listener.

Now looking at the following example

this is being sent to an ASPX page, would you recommend this? or is there a more 'hidden' method, i.e. could I use a webmethod for example? (i,e not a page someone in theory could navigate to).

4. Finally, from looking at the paypal api there are many fields sent through on a payment

would you recommend most of these be captured in the database?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Andrew AngellCo-Owner / Developer

You just need to include the billing agreement parameters in your SetExpressCheckout request so that you get a token that's valid to use within CreateRecurringPaymentsProfile.  Then you just replace DoExpressCheckout in the Express Checkout flow with CreateRecurringPaymentsProfile.

In the CRPP request, to do a free week, what you'll want to do is set the start date of the profile for a week away, but just leave the actual trial parameters empty.  Setup the normal amount and everything normally, but again, just leave the start date set for a week away.

When the profile is first created you'll get an IPN for it and it will have an active status.  Then on the profile start date the first payment would be processed as long as the profile is still active.  Each period that the profile is active the payment would be made, and IPN's would be sent for each payment so you can automate processing on the back-end.

You will need .NET, PHP, Java, or whatever you prefer to process the IPN's.  You can set this page up to only accept requests from PayPal's IP addresses if you want to protect it, but part of IPN is validating that the data came from PayPal anyway, so you can ignore any data that is verified, or treat it however you want.

As for the parameters you get, they'll be different depending on the txn_type, but yes, I like to save everything that IPN sends me.  In fact, I save a raw dump of the POST data, serialized in my database, and then I also parse out individual fields to have easy access to those.



Many thanks for your quick and concise response.

My site is c# Just to run over the process I am (if you could point out any error that would be great).

1. The user will navigate to and signup to my site.

2. They are redirected to my payment.aspx with a paypal express checkout button.

3. The user will click this which will send across the CreateRecurringPaymentsProfile to paypal, they will login and accept the recurring profile which is then saved to there profile. (from looking at the API I need to call SetExpressCheckout first is this correct?)

 as detailed here;

From looking at this to get the functionality I want I would set the following;

     INITAMT - this would be zero (as initially taking nothing)
     PROFILESTARTDATE - this would be 30 days from todays date
     PROFILEREFERENCE - do you use this field yourself?

4. In the params sent across to paypal I will include my IPN listener address. (I cant see a field in the API where this would be set)

      4.1 Now will paypal send across a success message to my IPN listener once the user has accepted the profile?
      4.2 How do you normally handle this listener with Would you use a bespoke page like in the link above or some kind of webmethod?
      4.3 Can I send across cancellation restricts with the profile? (i.e. 1 week before is marked as inactive?)

5. Once the user has accepted the recurring profile and the IPN has received back the success I will activate the account.

       5.1 On this success event do I need to verify the IPN number received and store this as the tester for further recurring payment IPN messages?
       5.2 As you mentioned before the start date of the recurring payment will be set to be 30 days after the request is made. So the first 'success' (if this is correct) will be parsed as a seperate request, whereby I will add a '30 days free' payment to the payment table in the db (which will handle whether or not the account is active).
             All additional recurring payments would then be processed a s apayment with all details (and a dump of the raw data) being stored in the db each time a request is sent to the listener.

I hope that make sense. Once again thanks for your help.
Co-Owner / Developer
No, you won't go straight to CRPP when using Express Checkout.

You'll still need to call SetExpressCheckout first, and set those billing agreement parameters like I mentioned.  That will return a token that you append to the end of the redirect URL to PayPal.

The user is then sent to that redirect URL where they login and agree to continue.  That's when they're sent back to the RedirectURL supplied in your SetExpressCheckout request.

There, you can call GetExpressCheckoutDetails to retrieve details about the buyer, including their PayerID, and then you'll finalize everything by passing the token and the payer ID into CreateRecurringPaymentsProfile.

I do use PROFILEREFERNCE, and I pass in my own internal Invoice ID.  That way it'll come back in IPN (as rp_invoice_id) and then I can update my local database records based on that.

With recurring payments you'll need to setup IPN in your PayPal profile.  The NotifyURL parameter won't work for all the future payments on that profile.

I use PHP, so I won't be much help with .NET questions in general.

Once the profile is canceled that's it.  No way to send a "cancel in a week" request, but you could program your own stuff to do that, of course.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.



Many thanks for this help.

OK so after I return to the 'RETURNURL' set in the SetExpressCheckout method

(something like CompletePayment.aspx).

Here I would display some kind of summary page where I would maybe detail the cost when the payment would be made, etc (based on the return from Paypal.)

The user would then click a 'Complete Payment' button which would call the CreateRecurringPaymentsProfile method.

I would then enable the login.

Would all recurring payments then send the IPN to the 'RETURNURL' set in the SetCheckoutExpress? So I would require some kind of listeners on this page to handle the automated requests?
Andrew AngellCo-Owner / Developer

No, in order to use IPN for recurring payments notifications you'll need to set it up in the PayPal account profile.  

With most API requests you can include an IPN URL in the NotifyURL parameter, and I'm pretty sure that would still work with the original CRPP request, however, all payments related to that in the future would only trigger IPN's if it was setup in the PayPal profile.


Hi Angeleye,

So once the recurring payment is set up will Paypal not send some kind of IPN message as to whether the payment was successfully, failed, was cancelled etc? to a listener?
Andrew AngellCo-Owner / Developer

It will, but you have to set up the IPN listener in your PayPal profile.


ah ok i see sorry for being dumb :)

So would it still send out a failed or cancelled event to the listener?

for example if the payment failed would or the user cancelled the recurring payment from their profile?
Andrew AngellCo-Owner / Developer

Yes, you will get an IPN for all events like that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial