我有一个用于试用的贝宝沙箱帐户一个 aspx 页面:sampleprocess.aspx
在 Merchant A/c 中,页面 在付款完成后被重定向到http://www.Hostsite.com/member/samplepaypal.aspx 。
在 samplepaypal.aspx.cs 页面加载:
protected void Page_Load(object sender, EventArgs e)
{
//string tx = Request.QueryString["tx"];
//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#"));
//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")
{
lblmsg.Text = "Verified";
//check the payment_status is Completed
//check that txn_id has not been previously processed
//check that receiver_email is your Primary PayPal email
//check that payment_amount/payment_currency are correct
//process payment
}
else if (strResponse == "INVALID")
{
lblmsg.Text = "Not Verified";
//log for manual investigation
}
else
{
lblmsg.Text = "IPN Logged";
//log response/ipn data for manual investigation
}
}
在这里我得到结果“无效”!有什么问题请纠正错误。从贝宝发回http://www.Hostsite.com/member/samplepaypal.aspx页面后,它显示:
http://111.111.111.111/member/samplepaypal.aspx?tx=8L903541KW5338647&st=Pending&amt=100.00&cc=USD&**cm=&item_number=&**sig=QRmNHFf5%2fAH3io9Tn2kj%2fuicu3gpAuMew701OvazfkCdN3jSR5tmFoX3OUPbQlZGoj2PY7vI%2fP1dH84g1CEzSG9NhjnLbjuAFFHyENVsBjKb1dVvK1nZe3FJfElZt11qPfggMOPu8%2bUhDwHekJvNAcXkjLQV01vAjN1y%2fZs1rJw%3d
这些 cm 和 item_number 是什么是空白的!如何获得“有效”响应。
帮助表示赞赏..!