PayPal IPN Sandbox - 监听器未向PayPal发送请求 - asp.net

时间:2015-04-21 22:08:53

标签: asp.net paypal paypal-ipn

过去两天试图解决这个问题。我之前已成功使用过多次代码,但现在却失败了。 我在IIS6上使用ASP.NET 4.0。 我正在使用IPN模拟器。这是正在发生的事情。 如果我将模拟器指向我的听众而没有任何代码,我会得到A-OK!

如果我添加以下代码:

    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(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
EM.SendAnyEmail("my@email.com", "String From PayPal ", strRequest);
// I get the above email and life is good

但是当我添加这个位时,它会中断:

 // code breaks Here????
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
EM.SendAnyEmail("my@email.com", "String Back to PayPal ", strRequest);
// I do NOT receive this email and life is not good
streamOut.Close();

StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
EM.SendAnyEmail("my@email.com", "String Response From PayPal ", strResponse);

所以有些事情正在破裂:

    StreamWriter streamOut = new StreamWriter(req.GetRequestStream(),       Encoding.ASCII);
streamOut.Write(strRequest);

但是对于我的生活,我无法看到问题是什么以及"模拟器" 告诉我"由于HTTP错误,我们无法发送IPN"但它没有给我一个错误代码。

以下是服务器的错误消息。

无法为SSL / TLS安全通道建立信任关系。    在System.Net.HttpWebRequest.GetRequestStream

TransportContext&安培;上下文)    在System.Net.HttpWebRequest.GetRequestStream()

根据验证程序,远程证书无效。    在System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken消息, AsyncProtocolRequest asyncRequest,Exception exception)

我事先感谢你的帮助。

干杯, GW

0 个答案:

没有答案