Implementing PayPal Subscriptions: Subscriptions via PayPal Payment standard. Cancel Subscriptions via PayPal API (Without SDK). I am facing issues while cancelling the Subscription/Recurring Payment via PayPal API. I was able to get the AccessToken via the API. Below is my code for cancelling subscriptions: string url = "https://api.sandbox.paypal.com/v1/payments/billing-agreements/" + mySubscriberId + "/cancel";
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Accept = "application/json";
webRequest.Headers.Add("Authorization: Bearer " + myPaypalAccessToken);
var request = ("note=" + myCancelNote);
byte[] req_bytes = Encoding.ASCII.GetBytes(request);
webRequest.ContentLength = req_bytes.Length;
Stream strm = webRequest.GetRequestStream();
strm.Write(req_bytes, 0, req_bytes.Length);
strm.Close();
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
using (Stream respStr = resp.GetResponseStream())
{
using (StreamReader reader = new StreamReader(respStr, Encoding.UTF8))
{
string jsonString = await reader.ReadToEndAsync();
reader.Close();
}
} I get the following response everytime: {
"name": "INTERNAL_SERVICE_ERROR",
"message": "An internal service error occurred.",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR",
"debug_id": "c121fd139b91b"
} Can someone assure me if i am on the right track & what might be the cause for the issue. Thanks!
... View more