Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 667
  • Last Modified:

Paypal Subscription API Questions RecurringPaymentProfile

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
flynny
Asked:
flynny
  • 4
  • 3
1 Solution
 
Andrew AngellCo-Owner / DeveloperCommented:
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
 
flynnyAuthor Commented:
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
 
Andrew AngellCo-Owner / DeveloperCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
flynnyAuthor Commented:
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
 
Andrew AngellCo-Owner / DeveloperCommented:
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
 
flynnyAuthor Commented:
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
 
Andrew AngellCo-Owner / DeveloperCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now