Creating a redirect to Paypal

jwcarlton
Contributor
Contributor

I'm new to the board and didn't see a section for development questions, so I apologize if this is the wrong section.

 

I'm working on something like a shopping cart, for a subscription- based service that uses the regular (free) Paypal account. The thing is, the visitor can subscribe to multiple things, and pause / cancel existing subscriptions, so I need to make the form to Paypal intuitive enough to make these allowances. 

 

I would also like for all payments to be done on the same day (1st of the month), and prorate the current month if necessary. I figured that this would be done by PHP on my end, though.

 

I'm looking at the variables listed here:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=dev...

 

Here's what I think will work, but I'm not sure if I understand several of these variables. Can you guys glance over this and see if you think I'm following the right path? I made noted above each section on how I think each variable works, so please let me know if I'm wrong.

 

FWIW, this is in PHP, but it's not really a PHP question; I just need to know if my logic is sound, not the coding behind it.

 

// is this variable necessary? 

$cmd = "xclick-subscriptions";

 

// Go ahead and set default subscription rate
$a3 = 30;     // $30.00

 

$business = [my email];

 

// This is an id that I generated earlier
$item_number = $_GET['subscription_id'];

 

$item_name = "Subscription Title";
$currency_code = "USD";

 

// Prorate
$today_date = date("j");
$days_of_month = date("t");

 

$prorate = 1 - ($today_date / $days_of_month);

$a1 = $a3 * $prorate; 

 

$a1 = round($a1, 2); 

$p1 = $days_of_month - $today_date; 

$t1 = "D";

 

// Subscription variables
// (does this mean that it will go for 2 years?)
// (and that I can't go past the 2 years?)
$p3 = 24;
$t3 = "M";

 

// make it recurring
$src=1;

 

// Recurring times? I'm not sure what this means,

// or if it can be different than $p3? 
$srt = 24;

 

// reattempt failed payment, but how do I get it to reattempt

// after, say, 5 days? 
$sra = 1;

 

// remove text box and prompt
$no_note = 1;

 

// does this mean that their current subscription will be updated,

// and they'll only be billed once regardless of how many

// subscriptions they create? I hope so.
$modify = 1;

 

$return = urlencode("$home/subscribe/?q=success");
$cancel_return = urlencode("$home/subscribe/?q=nosubmit");

 

// Then, redirect the user to:

$redirect = "https://www.paypal.com/cgi-bin/webscr?";
  $redirect .= "cmd=$cmd&";
  $redirect .= "business=$business&";
  $redirect .= "item_number=$item_number&";
  $redirect .= "item_name=$item_name&";
  $redirect .= "currency_code=$currency_code&";
  $redirect .= "a1=$a1&";
  $redirect .= "p1=$p1&";
  $redirect .= "t1=$t1&";
  $redirect .= "a3=$a3&";
  $redirect .= "p3=$p3&";
  $redirect .= "t3=$t3&";
  $redirect .= "src=$src&";
  $redirect .= "srt=$srt&";
  $redirect .= "sra=$sra&";
  $redirect .= "no_note=$no_note&";
  $redirect .= "modify=$modify&";
  $redirect .= "return=$return&";

  $redirect .= "cancel_return=$cancel_return";

 

Assuming that this is all correct, then the next question is, what variable do I need to send for a customer to pause / end an existing subscription? Or more likely, if he has, say, 4 subscriptions, and wants to pause 1 of them for a month?

 

TIA,

 

Jason

Login to Me Too
6 REPLIES 6

PayPal_RobG
PayPal Employee
PayPal Employee

Hi Jason

 

I'm Robert and I work at PayPal Merchant Technical Services (https://www.paypal.com/mts/)

 

Website Payments Standard subsciptions (what you're looking at using) does not support a certain start date. WPS Subscriptions start on the day the buyer subscribes to them. You could dynamically alter a trial period to work around this, but it's far from ideal.

 

Ideally, you'd want to use Express Checkout with Recurring Payments, which has a PROFILESTARTDATE parameter (the date you wish the recurring payments profile to start on).

See https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECRecurringP... for further information.

 

Note: Express Checkout works through our API's and includes a redirect to the PayPal site for the buyer to agree to the recurring payment. Buyers need a PayPal account in order to sign up for a recurring payment. Express Checkout (and Express Checkout with Recurring Payments) is available pretty much globally, and has no monthly charges.

 

We're currently updating our developer portal, but check https://www.x.com/ after the 29th of August, where you'll find a wealth of information on developer information, documentation, sample code as well as SDK's to aid in integrating PayPal.

 

Hope this was useful.

----
For technical assistance with PayPal merchant product offerings, please file a ticket at https://www.paypal.com/mts/
Login to Me Too

jwcarlton
Contributor
Contributor

Hi Robert,

 

Thanks for your reply. I looked through the variables for Express Checkout, though, and don't really see anything that I think would benefit this system above the Standard. A modified start date isn't really critical for this.

 

I do have a Business account, though, if it matters. I didn't realize that before.

 

Here were the other questions, though:

 

1. If I set p3=24, and t3=M, and src=1, am I correct that this will set the subscription to 2 years? Is that the maximum amount of time allowable?

 

2. Is srt different from p3? The description was vague, and it seems like I'll have to make it equal to p3, regardless.

 

3. When I set sra=1, I understand that it will reattempt a failed charge. But when? Can it be set to try again after 5 days?

 

4. When I set modify=1, am I correct that this will update their subscriptions so that they will be charged once, regardless of how many subscriptions they have?

 

5. Prorating the first month as a "trial" is no problem, really, and I believe this would get everybody recurring on the 1st of the month. But what about when I need to prorate the last month? Is there a way to do that?

 

For example, someone chooses a subscription from Aug 12 to November 18. I can set up the "trial" for the first month at 0.61 of the rate for 19 days, and then Sept and Oct will be the regular rate. But then for November, I need them to be invoiced for 0.4 of the rate for 12 days.

 

6. If a customer wants to pause or end a subscription early, how do I send that to Paypal? Or will I have to log in to my Paypal account and end it manually?

 

Thanks again,

 

Jason

Login to Me Too

PayPal_RobG
PayPal Employee
PayPal Employee

Hi Jason,

 

1. This means the subscription will re-bill every 24 months.

2. Yes, this defines how many times a subscription will re-bill. E.g. srt=3 will run the 24 months subscription 3 times.

3. There are incremental re-attempt dates. From the top of my head it's 1 day after the first failed attempt and 3 days after the second failed attempt.

4. No, see https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_subscr...

5. You can submit three time ranges to us; a1/p1/t1, a2/p2/t2 and a3/p3/t3 so that should be possible, assuming you'd use a2/p2/t2 for the 'main' subscription.

6. You can offer an 'Unsubscribe' button. See here: https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_subscr...

----
For technical assistance with PayPal merchant product offerings, please file a ticket at https://www.paypal.com/mts/
Login to Me Too

jwcarlton
Contributor
Contributor

Thanks for the reply, Rob. Just a couple more questions, for clarification.

 

2. If I set p3=24, t3=m, and src=3, then are you saying that this would invoice them for 72 months instead of 24?

 

4. OK, not a tragedy, I guess. It just means that, if they have 50 subscriptions, then they'll see 50 charges on the 1st of the month, right?

 

6. Can I change expiration dates and/or cancel a subscriber in my Business Paypal account? I don't see an option for it, but I don't actually have any recurring payments set up right now, either.

 

Similarly, if I've already set a3/p3/t3 to prorate for the last month and they want to change their expiration date to an earlier or later time, can I change that for them in my Paypal account? If so, where/how?

Login to Me Too

jwcarlton
Contributor
Contributor

While we're on the subject...

 

5. You can submit three time ranges to us; a1/p1/t1, a2/p2/t2 and a3/p3/t3 so that should be possible, assuming you'd use a2/p2/t2 for the 'main' subscription.

 

Per your advice (#5 above), I'm submitting 3 ranges to you (a1/a2/a3, etc), and wanting a1 to be a prorated 1st month, a2 to be several recurring months, and a3 to be a prorated ending month.

 

Let's assume a start date of Jun 12, 2011, and an end date of Nov 23, 2011. Am I correct that it would be like this?

 

// Regular subscription = $30

 

// Set to recurring 

src=1

 

// Prorate 1st month, June

a1=18

p1=18

t1=D

 

// Skip first and last month, so charge full amount for 4 months (July - Oct)

a2=30

p2=4

t2=M

 

// Prorate last month, November

a3=23

p3=23

t3=D

 

 

Login to Me Too

jwcarlton
Contributor
Contributor

Per your (Rob's) previous advice, and assuming I understand it correctly, I'm submitting these variables:

 

a1=1.94

p1=2

t1=D

 

a2=30

p2=2

t2=M

 

a3=18

p3=19

t3=D

 

This is supposed to cover Aug 23 through Nov 12. It's supposed to prorate the first month to $1.94, then charge 2 months at $30, then prorate the 4th month to $18.

 

But the Paypal invoice is showing:

 

$18.00 USD for each 19 days

 

And it's trying to charge $18, instead of the appropriate $1.94.

 

How do I correct this?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.