无法连接到PayPal沙箱来验证IPN监听器收到的消息

本文关键字:监听器 IPN 验证 消息 连接 PayPal | 更新日期: 2023-09-27 18:08:19

我正在使用IPN模拟器测试我的IPN侦听器。在IPN模拟器上发送IPN后,我的日志显示我的IPN侦听器接收到IPN,但是当它发送回添加了cmd=_notify-validate的消息时,沙箱没有响应。IPN模拟器显示的错误是"IPN Delivery Failed:500 Internal Server error"。在我的监听器向沙箱发送消息后,遇到以下错误:"连接尝试失败,因为被连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机未能响应173.0.82.77:443"。

当我用实时PayPal URL测试我的监听器时,它会响应"无效"消息-这表明我的监听器工作正常。

在与我的网络托管公司核实后,他们建议PayPal沙盒IP没有被封锁,问题应该出在PayPal沙盒上。请告知是否有可能PayPal已经封锁了源IP,因此没有回应它。如果是,我该如何解除对源IP的封锁?任何帮助都是感激的。谢谢。

我正在使用示例ASP。PayPal为我的IPN监听器提供了。NET c#代码,我的日志停在"向PayPal发送请求…"。

SSLogger.logger.Info("IPN Invoked");
//Post back to either sandbox or live
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);   //get request values
string strRequest = "cmd=_notify-validate&" + Encoding.ASCII.GetString(param);
//set request values
req.ContentLength = strRequest.Length;
SSLogger.logger.Info("sb: " + Encoding.ASCII.GetString(param));
SSLogger.logger.Info("strRequest: " + strRequest);
//Send the request to PayPal and get the response
SSLogger.logger.Info("Sending request to PayPal...");
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
SSLogger.logger.Info("Request sent out to PayPal.");
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
SSLogger.logger.Info("Response from PayPal received.");
SSLogger.logger.Info(strResponse);

无法连接到PayPal沙箱来验证IPN监听器收到的消息

试试这个:

req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;