Solved

Paypal Subscription API Questions RecurringPaymentProfile

Posted on 2014-04-23
7
583 Views
Last Modified: 2016-03-24
Hi,

I am offering a subscription service for which I sign people up through paypal.

Now initially when they signup they will get 30 days free and after that it will be a monthly fee.

Initially I cann GetExpressCheckout passing the following fields;

        NVPCodec encoder = new NVPCodec();
        encoder["METHOD"] = "SetExpressCheckout";
        encoder["RETURNURL"] = returnURL;
        encoder["CANCELURL"] = cancelURL;
        encoder["BRANDNAME"] = "My Subcription";
        encoder["PAYMENTREQUEST_0_AMT"] = amt;
        encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt;
        encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
        encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "GBP";
        encoder["L_BILLINGTYPE0"] = "RecurringPayments";
        encoder["L_BILLINGAGREEMENTDESCRIPTION0"] = "Monthly Subcription";
[code]

Redirect to paypal for the user to login and accept the terms;

they are returned back to my site where I then call

GetCheckoutDetails to get the users details and save these to a db.

I then call CreateRecurringPaymentProfile to set up the recurring payment a month later (i.e. after the 30 days)

[code]
        NVPCodec encoder = new NVPCodec();
        encoder["METHOD"] = "CreateRecurringPaymentsProfile";
        encoder["TOKEN"] = token;
        encoder["EMAIL"] = payerEmail;
        encoder["PROFILESTARTDATE"] = startdate.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
        encoder["BILLINGFREQUENCY"] = "12";
        encoder["BILLINGPERIOD"] = "Month";
        encoder["AMT"] = "19.99";
        encoder["DESC"] = "Monthly Subcription";

Open in new window


now my question is how do I handle if the user;

a. cancels the subscription.

b. the subscription requires renewal (i.e. after 12 months).

Am I required to call the process again from the beginning? (i.e. ExpressCheckout, etc).
Or will the IPN automatically renew?

I have a listner that will catch any IPN Requests from Paypal, and log them to a database.
0
Comment
Question by:flynny
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 40018270
You will get IPN's for all the recurring actions, so you can process things accordingly based on the txn_type.

If a profile is canceled you must create a new one.  If a profile is suspended you can reactivate it using the ManageRecurringPaymentsProfileStatus API.  

If it's about to expire you can send them email notifications from the IPN script and provide a link to setup a new profile.  Depending on timing, you may then need to cancel out their existing one so the new one takes over, but again, this can all be done through the API.
0
 

Author Comment

by:flynny
ID: 40019851
Hi Andrew,

Many thanks for your reponse.

Ok, so I have could you confirm the following cases please?

New User Signup
1. A user signs up for the first time and will get the first month free. So I would;
    a. Call GetExpressCheckout with 0.00.
    b. Redirect to paypal for the login and confirmation.
    c. On return to my site I would then call Get CheckoutDetails to get the customer details and save to the db.
    d. Call CreateRecurringPaymentsProfile to create the yearly recurring payment of 19.99. (with the start date being 1 month from now.)

User Subscription Renewal
2. when the 12th and final payment the user will need to renew. Will an IPN be sent for this? and Can I automatically then simply call CreateRecurringPaymentProfile again to create the new profile, or will the customer be required to confirm manually?

As realistically I would like the subscription to be renewed unless they say otherwise so that the service remains uninterupted.

User Cancel
3. A user cancels there paypal recurring payment and attempts to login.
    a. An cancel IPN would be sent which I would capture and store on the DB.
    b. When the user logs in I would check for this and if present, then show the account as being locked.
    c. I would then request that the be redirected to create a new recurringpaymentprofile.
    (In this case would I need to call GetExpressCheckout etc again?)

General Question
4. How can I create an invoice number for each recurring payment? or will each recurring payment have the same invoice number as I send from the initial call to GetExpressCheckout?
5. How would you test for an account being active as opposed to being suspended, cancelled or out of subscription? As I store all my details in a 'payment' table I am looking at storing all IPN details here. I would then pull back the latest row on the particular user and perform a check on the txn_type?

then if cancelled I can flag the account as cancelled, suspended etc? Does this seem a good way to go about it?

Sorry about all the questions. It seems a very powerful API and I want to ensure I implement it correctly first time.

Thanks in advance,

Matt.
0
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 40020134
1)  The first step is SetExpressCheckout (Not GetExpressCheckout) but otherwise, yes.

2)  If a new profile needs to be created the user would have to go through checkout again to authenticate and approve the new profile.  It sounds like maybe you'd be better not setting and end date..??  Just leave it open-ended so that the user has to cancel the profile for it to end.  

3)  You're correct about the IPN getting sent and that you can update your database.  I like to make a call to GetRecurringPaymentsProfileDetails to see the current status of the profile any time somebody logs in to my system.  Based on the current status you can send them to different landing pages.

4)  The PROFILEREFERENCE parameter in the CreateRecurringPaymentsProfile request is where you would include your own custom invoice ID.  Any IPN related to that profile in the future would include an rp_invoice_id parameter with that same value in it.  

5)  Again, GetRecurringPaymentsProfileDetails
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:flynny
ID: 40020207
Andrew,

Thanks for bearing with me on this.

Is there not a limit on how long the recurring profile can be. From what I read on the api the maximum length it can be is 12 months? What should I do at the end of this (or am I wrong)?
0
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 40020255
The maximum length of a billing cycle could only be 12 months, but if you just set TOTALBILLINGCYCLES to 0 it will create a profile that is active until canceled.
0
 

Author Comment

by:flynny
ID: 40027067
Hi,

thanks for that, how would this be changed in the future, for example if the subscription cost changed?

would I need to cancel all profiles and request new?
0
 
LVL 11

Accepted Solution

by:
Andrew Angell earned 500 total points
ID: 40028145
You can use the UpdateRecurringPaymentsProfile API to update the profile, but there are some limitations depending on how the profile was setup.

If the profile was created through Express Checkout you can only increase the amount by 20% every 180 days.  

If the profile was created through Payments Pro, though, you could increase it at any time without limitation.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

E-commerce is quite a gambling world, and you should never entrust your business to a lucky chance. In order to outrun your competitors in a race to attract as many customers as possible, you need to have a well thought-out strategy under your belt.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

23 Experts available now in Live!

Get 1:1 Help Now