没有得到IPN的响应
本文关键字:响应 IPN | 更新日期: 2023-09-27 17:53:07
付款成功后,它在成功URL重定向我,但我没有得到IPN的响应。
下面是notifypage.aspx.cs
页面代码:
protected void Page_Load(object sender, EventArgs e)
{
//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(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
//for proxy
//WebProxy proxy = new WebProxy(new Uri("http://url:port#80"));
//req.Proxy = proxy;
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
if (strResponse == "VERIFIED")
{
File.WriteAllText(HttpContext.Current.Server.MapPath("~") + @"'Notify.txt", "Student1111" + Environment.NewLine + "----------------------------------------" + Environment.NewLine);
}
else if (strResponse == "INVALID")
{
File.WriteAllText(HttpContext.Current.Server.MapPath("~") + @"'Notify.txt", "Problem with payment : " + Environment.NewLine + "----------------------------------------" + Environment.NewLine);
}
else
{
File.WriteAllText(HttpContext.Current.Server.MapPath("~") + @"'Notify.txt", "not any" + Environment.NewLine + "----------------------------------------" + Environment.NewLine);
}
}
那么请帮助我如何才能得到IPN的响应?
您应该在这里测试IPN Listner
的工作
Paypal IPN
响应只调用服务器域,如果您在本地主机上尝试它将不会调用您的通知url页面