Following is the code for CreateRecurringPaymentsProfileCode. The response received is Invalid Token and Error number is 11502. I am not able to figure out the problem which might be happening while creating the recurring profile.
Code:public string CreateRecurringPaymentsProfileCode(string token, string amount, string profileDate, string billingPeriod, string billingFrequency)
{
CallerServices caller = new CallerServices();
IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
// Set up your API credentials, PayPal end point, API operation and version.
profile.APIUsername = APIUsername;
profile.APIPassword = APIPassword;
profile.APISignature = APIPassword;
profile.Environment = "sandbox";
profile.Subject = "Payment";
caller.APIProfile = profile;
NVPCodec encoder = new NVPCodec();
encoder["VERSION"] = "69.0";
// Add request-specific fields to the request.
encoder["METHOD"] = "CreateRecurringPaymentsProfile";
encoder["TOKEN"] = token;
encoder["AMT"] = amount;
encoder["PROFILESTARTDATE"] = profileDate;
encoder["BILLINGPERIOD"] = billingPeriod;
encoder["BILLINGFREQUENCY"] = billingFrequency;
encoder["DESC"] = "EZ Coaching";
encoder["CURRENCYCODE"] = "USD";
encoder["TOTALBILLINGCYCLES"] = "4";
encoder["ACCT"] = "4900864163878723";
encoder["EXPDATE"] = "062017";
encoder["STREET"] = "1 Main St";
encoder["CITY"] = "San Jose";
encoder["STATE"] = "CA";
encoder["ZIP"] = "95131";
encoder["COUNTRYCODE"] = "1";
encoder["SHIPTONAME"] = HttpContext.Current.Session["SHIPTONAME"].ToString();
encoder["SHIPTOSTREET"] = HttpContext.Current.Session["SHIPTOSTREET"].ToString();
encoder["SHIPTOCITY"] = HttpContext.Current.Session["SHIPTOCITY"].ToString();
encoder["SHIPTOSTATE"] = HttpContext.Current.Session["SHIPTOSTATE"].ToString();
encoder["SHIPTOZIP"] = HttpContext.Current.Session["SHIPTOZIP"].ToString();
encoder["L_PAYMENTREQUEST_n_ITEMCATEGORY0"] = "Digital";
encoder["L_PAYMENTREQUEST_n_NAME0"] = "Coaching";
encoder["L_PAYMENTREQUEST_n_AMT0"] = "5.00";
encoder["L_PAYMENTREQUEST_n_QTY0"] = "1";
encoder["EMAIL"] = "abc@def.xyz";
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = HttpCall(pStrrequestforNvp);
// Execute the API operation and obtain the response.
//string pStrrequestforNvp = encoder.Encode();
//string pStresponsenvp = caller.Call("CreateRecurringPaymentsProfile",pStrrequestforNvp);
NVPCodec decoder = new NVPCodec();
decoder.Decode(pStresponsenvp);
return decoder["ACK"].ToLower();
}
The function is called as:
Code:string recAck = test.CreateRecurringPaymentsProfileCode(token, amt, System.DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"), "Day", "30");