我正在使用我的 asp 页面中集成的 paypal ipn,当我使用沙盒 url 时,一切正常,当我使用 ipn 访问页面时,页面正常加载,没有任何错误,但是当我改变了在 ipn 进程中发布 url,现在当我在浏览器中打开页面时,出现以下错误:
你调用的对象是空的。
我很担心和困惑......如果有人会付款,ipn页面会工作吗?这个错误是因为当我加载它时,它会尝试将数据发布到贝宝,但由于没有数据......它告诉我对象引用......
protected void Page_Load(object sender, EventArgs e)
{
string postUrl = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(postUrl);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
string ipnPost = strRequest;
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
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")
{
//some checking
}
else if (strResponse == "INVALID")
{
//some code
}
else
{
}
}