简体   繁体   中英

Unable to connect to PayPal Sandbox to verify message received by IPN listener

I am testing my IPN listener using the IPN simulator. After sending IPN on the IPN simulator, my log shows that my IPN listener receives the IPN but when it sends back the message with cmd=_notify-validate added to it, the sandbox does not respond. The error shown on the IPN simulator is "IPN Delivery Failed:500 Internal Server Error". The following error is met after my listener sends out the message to sandbox: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.0.82.77:443".

When I test my listener with the live PayPal URL, it responds with the "INVALID" message - which shows that my listener is working fine.

After checking with my web hosting company, they advised that the PayPal Sandbox IP was not blocked and that the problem should lie with PayPal sandbox. Please advise if it is possible that PayPal has blocked the source IP and hence is not responding to it. If so, how can I go about unblocking the source IP? Any help is appreciated. Thanks.

I am using sample ASP.NET C# code provided by PayPal for my IPN listener and my log stops at "Sending request to 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);

Try this instead:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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