我对IPN Sandbox和ASP.NET 4.0有问题。我用于生产零件的相同代码不适用于沙箱。
提出的错误如下:
异常消息:基础连接已关闭:发送到发送。
发生了意外错误。这是代码:
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
string strResponse_copy = strRequest; //Save a copy of the initial info sent by PayPal
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
该错误在线上升高
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
交易代码而不是调用付款页面正常工作。
我该如何修复?
如果同一代码在生产站点上起作用,而不是沙箱,则很可能是与沙盒环境的间歇性网络问题。
我最近看到了与沙盒有关的问题。继续重试代码,我相信某些请求将会通过,而其他请求将被删除。