Thought I would ask here as there is a question on the x forums (posted May 7) but it doesn't seem to be answered yet.
I'm using PHP here and as a test to get the token and process the transaction here is my code:
$nvps = array();
$nvps["VERSION"] = "69.0";
$nvps["METHOD"] = "SetExpressCheckout";
$nvps["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
$nvps["PAYMENTREQUEST_0_AMT"] = "1.00";
$nvps["PAYMENTREQUEST_0_CURRENCYCODE"] = "GBP";
$nvps["PAYMENTREQUEST_0_ITEMAMT"] = "1.00";
$nvps["L_BILLINGTYPE0"] = 'RecurringPayments';
$nvps["L_BILLINGAGREEMENTDESCRIPTION0"] = "the subscription";
$nvps["L_PAYMENTREQUEST_0_NUMBER0"] = 1;
$nvps["L_PAYMENTREQUEST_0_NAME0"]= "subscription";
$nvps["L_PAYMENTREQUEST_0开发者_运维问答_AMT0"]= 1.00;
$nvps["L_PAYMENTREQUEST_0_QTY0"]= 1;
$nvps["L_PAYMENTREQUEST_0_ITEMCATEGORY0"] = "Digital";
$nvps["REQCONFIRMSHIPPING"] = "0";
$nvps["NOSHIPPING"] = "1";
I get a response back fine, and in this response is the usual stuff:
TOKEN = EC-87478432UK0557216
BILLINGAGREEMENTACCEPTEDSTATUS = 1
CHECKOUTSTATUS = PaymentActionNotInitiated
I then change the response to then be sent back to paypal. Here I think I need to create the profile:
$response["METHOD"] = "CreateRecurringPaymentsProfile";
$response["PROFILESTARTDATE"] = "2011-7-7T0:0:0";
$response["BILLINGPERIOD"] = "Month";
$response["BILLINGFREQUENCY"] = "4";
$response = RunAPICall($response); // Send the API call to PayPal.
But then I get this:
TIMESTAMP = 2011-07-07T21:29:15Z
CORRELATIONID = 59260374116e4
ACK = Failure
VERSION = 69.0
BUILD = 1907759
L_ERRORCODE0 = 11581
L_SHORTMESSAGE0 = Invalid Data
L_LONGMESSAGE0 = Profile description is invalid
L_SEVERITYCODE0 = Error
An error occurred.
My last attempt (before giving up) was this:
$nvps = array();
$nvps["VERSION"] = "69.0";
$nvps["METHOD"] = "CreateRecurringPaymentsProfile";
$nvps["TOKEN"] = $response["TOKEN"];
$nvps["paymentType"] = urlencode('Authorization');
$nvps["RETURNURL"] = $script_url . "/modules/paypal/success.inc.php";
$nvps["CANCELURL"] = $script_url . "/modules/paypal/failure.inc.php";
$nvps["paymentAmount"] = urlencode("1.00");
$nvps["currencyID"] = urlencode("GBP"); // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
$nvps["startDate"] = urlencode("2011-07-08T00:00:00");
$nvps["billingPeriod"] = urlencode("Month"); // or "Day", "Week", "SemiMonth", "Year"
$nvps["billingFreq"] = urlencode("12");
$response = RunAPICall($nvps); // Send the API call to PayPal.
I get this now:
TIMESTAMP = 2011-07-08T11:07:33Z
CORRELATIONID = 1e97153fed038
ACK = Failure
L_ERRORCODE0 = 10001
L_SHORTMESSAGE0 = Internal Error
L_LONGMESSAGE0 = Timeout processing request
An error occurred.
Not very helpful......
So has else done this? I would appreciate some guidence!
Please note, I think this is different from setting up recurring subscriptions normally (although I may be wrong).
I got help from one of the support staff on the forum.
I needed to up my version from 69 to 74.0 and use these params:
$nvps["PROFILESTARTDATE"] = "2011-07-08T17:40:00Z";
$nvps["BILLINGPERIOD"] = "Month";
$nvps["BILLINGFREQUENCY"] = "1";
$nvps["AMT"] = "1.00";
$nvps["CURRENCYCODE"] = "GBP";
$nvps["DESC"] = "the+subscription";
Which then yields...
PROFILEID = I-762SUW9D8VVF
PROFILESTATUS = ActiveProfile
TIMESTAMP = 2011-07-08T16:50:55Z
CORRELATIONID = 880f95195604f
ACK = Success
VERSION = 74.0
BUILD = 1907759
So all is well for me :)
精彩评论