验证IPN时,IPN响应为空

时间:2013-05-23 09:22:22

标签: c# paypal paypal-ipn

根据此paypal document,我们在使用IPN后将消息发回Paypal,然后我们回来: -

PayPal will then send one single-word message, VERIFIED, if the message is valid; otherwise, it will send another single-word message, INVALID.

然而,我一次又一次地注意到即使付款成功,回复也可能是空白的。有没有人注意到这个?

我要验证的代码是: -

var req = (HttpWebRequest)WebRequest.Create(Settings.PayPalPaymentUrl);

//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);
strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;

//Send the request to PayPal and get the response
var streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
var streamIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = streamIn.ReadToEnd();
streamIn.Close();

99%的案例我都会回来VERIFIED,但我们时不时会看到一条空信息。

1 个答案:

答案 0 :(得分:1)

如果有人直接访问该页面,而不是被PayPal命中,那么你会得到一个空白的回复,那是发生了什么?