flynny
asked on
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;
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.
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";
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.
ASKER
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 CreateRecurringPaymentsPro file 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 CreateRecurringPaymentProf ile 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.
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 CreateRecurringPaymentsPro
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 CreateRecurringPaymentProf
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.
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 GetRecurringPaymentsProfil eDetails 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 CreateRecurringPaymentsPro file 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, GetRecurringPaymentsProfil eDetails
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 GetRecurringPaymentsProfil
4) The PROFILEREFERENCE parameter in the CreateRecurringPaymentsPro
5) Again, GetRecurringPaymentsProfil
ASKER
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)?
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)?
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.
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If a profile is canceled you must create a new one. If a profile is suspended you can reactivate it using the ManageRecurringPaymentsPro
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.