gpt4 book ai didi

c# - asp.net 的 PayPal IPN 沙箱错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:24:39 25 4
gpt4 key购买 nike

我在使用 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);

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

我该如何解决?

最佳答案

如果相同的代码在生产站点上运行,但在 Sandbox 上不起作用,则很可能是 Sandbox 环境的间歇性网络问题。

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

关于c# - asp.net 的 PayPal IPN 沙箱错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37828580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com