我收到此错误,在api-3t.sandbox.paypal.com中调用SetExpressCheckout时,从传输流中收到意外的EOF或0个字节。我使用Asp.net来呼叫api。
这是我的代码:
private static NameValueCollection Submit(string values)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
String.Format("https://{0}/nvp", PayPalSettings.ApiDomain));
request.Method = "POST";
request.ContentLength = values.Length;
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(values);
}
WebResponse webResponse = request.GetResponse();
Stream response = webResponse.GetResponseStream();
using (StreamReader reader = new StreamReader(response))
{
return HttpUtility.ParseQueryString(reader.ReadToEnd());
}
}
当我调用request.GetRequestStream()时会发生错误。
值参数包含: USER =<用户名>& PWD =<密码>& METHOD = SetExpressCheckout& VERSION = 76.0& HDRIMG =< image url>& RETURNURL =< return url>& CANCELURL =<取消URL>&安培; BUTTONSOURCE = PP-ECWizard&安培; SUBJECT =安培; ALLOWNOTE = 0&安培; PAYMENTREQUEST_0_PAYMENTACTION =塞尔&安培; PAYMENTREQUEST_0_AMT = 100安培; PAYMENTREQUEST_0_CURRENCYCODE = AUD&安培; NOSHIPPING = 1&安培; L_PAYMENTREQUEST_0_NAME0 =注册&安培; L_PAYMENTREQUEST_0_DESC0 =注册+详细资料和L_PAYMENTREQUEST_0_QTY0 = 1&安培; L_PAYMENTREQUEST_0_AMT0 = 100
PayPalSettings.ApiDomain = api-3t.sandbox.paypal.com
奇怪的是,如果我使用上面相同的代码并调用live / production paypal api它会起作用。当然使用实时/生产网址和凭据。
此外,如果我发布上述网址( https://api-3t.sandbox.paypal.com/nvp?USER=< username>& PWD =< password>& METHOD = SetExpressCheckout& VERSION = 76.0& HDRIMG =< image URL>&安培; RETURNURL = LT;返回URL>&安培; CANCELURL = LT;取消URL>&安培; BUTTONSOURCE = PP-ECWizard&安培; SUBJECT =安培; ALLOWNOTE = 0&安培; PAYMENTREQUEST_0_PAYMENTACTION =塞尔&安培; PAYMENTREQUEST_0_AMT = 100安培; PAYMENTREQUEST_0_CURRENCYCODE = AUD&安培; NOSHIPPING = 1& L_PAYMENTREQUEST_0_NAME0 =注册& L_PAYMENTREQUEST_0_DESC0 =注册+详细信息& L_PAYMENTREQUEST_0_QTY0 = 1& L_PAYMENTREQUEST_0_AMT0 = 100 )在浏览器中它将返回所需的结果。
非常感谢您的帮助。
谢谢。
答案 0 :(得分:2)
paypal
更改了支持的TLS版本,使版本1.2成为支持的最低版本。
问题是.Net Framework 3.5不支持该版本。 对于高于3.5的框架,您可以添加下一行:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
由于这个问题几乎是在一年前,我不认为微软会对fw 3.5进行更新,所以我建议将你的应用程序迁移到4.5。