Link to home
Start Free TrialLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Reoccuring payments Paypal Express Checkout and IPN payments

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

http://www.codeproject.com/Tips/84538/Setting-up-PayPal-Instant-Payment-Notification-IPN

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

https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/#example_req_resp

would you recommend most of these be captured in the database?
Avatar of Andrew Angell
Andrew Angell
Flag of United States of America image

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.
Avatar of flynny

ASKER

Angeleye,

Many thanks for your quick and concise response.

My site is c# asp.net. 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;

https://developer.paypal.com/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/

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 asp.net. 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.
ASKER CERTIFIED SOLUTION
Avatar of Andrew Angell
Andrew Angell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flynny

ASKER

Angeleye,

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?
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.
Avatar of flynny

ASKER

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?
It will, but you have to set up the IPN listener in your PayPal profile.
Avatar of flynny

ASKER

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?
Yes, you will get an IPN for all events like that.