500 INTERNAL_SERVICE_ERROR while Cancel Subscription (.Net Core)
NagarajuRaghava
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Mar-21-2019
11:01 PM
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!
Labels:
- Labels:
-
Payments REST APIs
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Activating a subscription after capturing outstanding_balance will charge the customer again in REST APIs
- Subscriptions API is highly inconsistent in REST APIs
- Know if subscription cancelled due to failed payment in REST APIs
- INVALID RESOURCE ID paypal Cancel Subcription in Sandbox Environment
- How to test Subscription payments in Sandbox Environment