繁体   English   中英

asp.net的PayPal IPN沙盒错误

[英]PayPal IPN Sandbox error with asp.net

我对IPN沙箱和ASP.NET 4.0有问题。 我在生产部件中使用的相同代码不适用于SandBox。

引发的错误如下:

异常消息:基础连接已关闭:发送时发生意外错误。

这是代码:

        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);

处理而不是调用付款页面的代码可以正常工作。

我该如何解决?

如果相同的代码在生产站点上有效,但不能在沙盒上运行,则很可能是沙盒环境出现间歇性网络问题。

最近,我已经看到了此问题以及与沙盒相关的问题。 继续重试代码,我相信某些请求会通过,而其他请求会被丢弃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM