【发布时间】:2016-05-27 08:50:12
【问题描述】:
我正在使用用 asp.net,c# 编码的 IIS 服务器的 IPN Samulator,但我遇到错误“未发送 IPN,未验证握手。”。我的托管服务器使用纯 http 并且不支持 ssl。我的测试网址是http://realestate.owncircles.com/ipn.aspx。
还有代码:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// receive PayPal ipn data
// extract ipn data into a string
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
// append PayPal verification code to end of string
strRequest += "&cmd=_notify-validate";
// create an HttpRequest channel to perform handshake with PayPal
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings["paypalIPN"].ToString());
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = strRequest.Length;
// send data back to PayPal to request verification
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
// receive response from PayPal
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
// if PayPal response is successful / verified
if (strResponse.Equals("VERIFIED"))
{
}
【问题讨论】:
-
这是您使用的全部代码还是其中的一部分?
-
另外,您使用的是哪种交易类型,所以我可以尝试复制您的问题\或解决它
-
更进一步,你看过这个链接developer.paypal.com/webapps/developer/docs/classic/ipn/… 并查看了故障排除者吗?
标签: c# asp.net paypal-ipn