成功付款後,它重定向我的成功URL,但我沒有得到IPN的迴應。沒有得到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在商家的賬戶,並添加了IPN的網址? – IrishChieftain