我正在尝试为PayPal IPN编写自己的ASP.NET C#处理程序页面。
我已经跟踪了我在网上找到的一些样本,但没有成功。
我似乎在第一步失败:捕获从PayPal发送到处理程序页面的即时付款通知(IPN)数据。
我有一个网页:PayPalIPNHandler.aspx.cs,在Page_Load中我有以下内容:
protected void Page_Load(object sender, EventArgs e)
{
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
}
我使用一些示例数据来测试处理程序页面:
/sitename/PayPalIPNHandler.aspx?mc_gross=0.01&protection_eligibility=Eligible&address_status=confirmed&item_number1=&payer_id=pid&tax=0.00&address_street=23%20The%20Street&payment_date=12:38: 53%20Jan%2010%202012%20PST&安培; PAYMENT_STATUS =完成&安培;字符集=窗口1252&安培; address_zip = IP4%204LP&安培; mc_shipping = 0.00&安培; mc_handling = 0.00&安培;如first_name =约翰&安培; mc_fee = 0.01&安培; address_country_code = GB&安培; ADDRESS_NAME =约翰%20Smith&放大器; notify_version = 3.4&放;定制=安培; payer_status =未经验证和放大器; business=x@googlemail.com& ADDRESS_COUNTRY =联合%20Kingdom和放大器; num_cart_items = 1&安培; mc_handling1 = 0.00和放大器; ADDRESS_CITY =伊普斯维奇和放大器; verify_sign =验证和放大器; payer_email=x@gmail.com& mc_shipping1 = 0.00&安培; txn_id = 1&安培; payment_type =即时&安培;姓氏=史密斯&安培; ADDRESS_STATE =沙福&安培; item_name1 =安培; receiver_email=x@googlemail.com& payment_fee =安培;数量1 = 1&安培; receiver_id = W&安培; txn_type =购物&安培; mc_gross_1 = 0.01&安培; mc_currency = GBP&安培; residence_coun尝试= GB&安培; transaction_subject =购物%20Cart&安培; payment_gross =安培; ipn_track_id = BU4
但是,ContentLength似乎总是0,而strRequest是“”
我显然犯了一个非常愚蠢的错误,但我看不出我做错了什么。
请帮忙。
亲切的问候
沃尔特
答案 0 :(得分:1)
HTTP GET请求的内容将始终为空 - 它仅对POST(以及PUT和可能的DELETE)请求发送内容有效。根据您的评论,我说您需要查看
Request.ServerVariables["QUERY_STRING"]