付款成功后,它会将我重定向到成功网址,但我没有收到来自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回复?
答案 0 :(得分:0)
您应该测试IPN Listner
此处
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNTesting/
答案 1 :(得分:-1)
Paypal IPN
响应仅调用服务器域,如果您在本地主机上尝试它,则不会调用您的通知网址页。