实施贝宝订阅:
我在通过PayPal API取消订阅/定期付款时遇到问题。我能够通过API获得AccessToken。以下是我取消订阅的代码:
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();
}
}
我每次都会收到以下答复:
“名称”:“ INTERNAL_SERVICE_ERROR”, “ message”:“发生内部服务错误。”, “ information_link”:“ https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR”, “ debug_id”:“ c121fd139b91b”
有人可以向我保证,如果我走的路正确,可能是问题的原因。谢谢!