Solved

Reoccuring payments Paypal Express Checkout and IPN payments

Posted on 2014-03-05
9
1,251 Views
Last Modified: 2016-03-24
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?
0
Comment
Question by:flynny
  • 5
  • 4
9 Comments
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 39905959
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.
0
 

Author Comment

by:flynny
ID: 39906011
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.
0
 
LVL 11

Accepted Solution

by:
Andrew Angell earned 500 total points
ID: 39906029
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.
0
 

Author Comment

by:flynny
ID: 39906651
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?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 11

Expert Comment

by:Andrew Angell
ID: 39906853
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.
0
 

Author Comment

by:flynny
ID: 39908861
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?
0
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 39908945
It will, but you have to set up the IPN listener in your PayPal profile.
0
 

Author Comment

by:flynny
ID: 39908954
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?
0
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 39908964
Yes, you will get an IPN for all events like that.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now