I really wanted to do this myself but after almost a week of reading Paypal's documentations about their services and APIs and addon services, I quit. I need help.
I have a website which will have a monthly subscription of three different packages and I would like to use PayPal's Hosted Pages. Now, I'm facing a few problems.
First, their documentation is so damn confusing that I still don't understand it exactly what they offer and what do I need. So, any help would be greatly appreciated. Currently I have Payments Advanced with Recurring Billing addon and Hosted Checkout Page set up. My first problem is that when I make an API call to get a SecureTokenID, I get response 1 (User authentication failed), but the login details are correct, I checked multiple times.
Here is my code for making this call:
/* - build NVP to be sent to paypal - */
$post['PARTNER']='paypal';
$post['VENDOR']='*';
$post['USER']='*';
$post['PWD']='*';
$post['TRXTYPE']='S';
$post['AMT']='5';
$post['CREATESECURETOKEN']='Y';
$post['SECURETOKENID']=md5(time().rand().time());
$post['MODE']='TEST';
$url='https://pilot-payflowpro.paypal.com';
/* - do cURL request to PayPal's API - */
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
// I know, inhere should be a certificate and it will be in final version
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
// curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10); // 3 seconds to connect
// curl_setopt ($ch, CURLOPT_TIMEOUT, 10); // 10 seconds to complete
$output = curl_exec($ch);
if(curl_errno($ch)){
echo'error:' . curl_error($ch);
}
curl_close($ch);
Second problem is, where exactly can I enter a custom variable field, which will represent a database entry, so I will know from IPN which user has subscribed/unsubscribed?
Third, is it possible to set the subscription options in PayPal Manager interface, or must I sent the subscription details on every single transaction?
Fourth, am I going this the right way?? From their website and docs, I understood that I need a Payments Advanced and Recurring Billing, nothing more. Requirement is that the user can't leave the website, so I want to use a Hosted Checkout Page.
EDIT: I solved first and second (this is the second time I figured it out myself after I posted a question over here :)), but I would need help with third and fourth point.
Also I have additional question. Can Recurring Billing be suspended for users's selected period?