2013-04-10 135 views
1

收到我测试使用模拟器IPN IPN我的听众消息。在IPN模拟器上发送IPN后,我的日志显示我的IPN侦听器接收到IPN,但当它发回带有cmd = _notify-validate的消息时,沙箱不响应。 IPN模拟器上显示的错误是“IPN传送失败:500内部服务器错误”。我的听众发出的消息后,沙箱满足以下错误:“连接尝试失败,因为连接的方没有正确一段时间后响应或已建立的连接失败,因为连接的主机未能响应173.0.82.77:443 ”。这表明我的听众是工作的罚款 -无法连接到贝宝沙箱核实IPN监听

当我测试用活贝宝URL监听器,它与“无效”的消息作出响应。

与我的网络托管公司检查后,他们告知,贝宝沙箱IP没有被阻挡,而这个问题应在于贝宝沙箱。请告知PayPal是否有可能阻止源IP并因此未对其做出响应。如果是这样,我该如何去解锁源IP?任何帮助表示赞赏。谢谢。

我使用贝宝我的IPN监听器提供样品ASP.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); 

回答

0

试试这个:

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;