我正在尝试创建一个页面,其中:
- 1.用户点击一个叫BUY的按钮
- 2.用户被重定向到需要登录支付的paypal页面。
付款后,他将被重定向到另一个页面,其中:
- 1.在页面加载中,我会检查是否支付成功。
我已经这样做了,但它似乎不起作用。 我做了什么?
1.从paypal帐户启用IPN,并将url设置为asp页面。
2.在网站上托管这两个文件(php/asp.net)
3.经过测试,但标签文本没有变为“完成,已付款”,这意味着他无法处理付款。
购买产品的php页面:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="seller@domain.com" />
<input type="hidden" name="item_name" value="Happiness" />
<input type="hidden" name="amount" value="6.52" />
<input type="submit" value="Buy!" />
</form>
asp.net 页面:
protected void Page_Load(object sender, EventArgs e)
{
string strSandbox = "https://www.sandbox.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;
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")
{
Label1.Text = "Done,payment was made.";
}
else if (strResponse == "INVALID")
{
//whatever
}
else
{
//whatever
}
}
我能做些什么?