protected override string OnNotify(System.Web.HttpContext context) { var handler = new ResponseHandler(context); handler.setKey(key); if (handler.isTenpaySign()) { ///通知id string notify_id = handler.getParameter("notify_id"); //通过通知ID查询,确保通知来至财富通 //创建查询请求 RequestHandler queryReq = new RequestHandler(context); queryReq.init(); queryReq.setKey(key); queryReq.setGateUrl("https://gw.tenpay.com/gateway/verifynotifyid.xml"); queryReq.setParameter("partner", bargainor_id); queryReq.setParameter("notify_id", notify_id); //通信对象 TenpayHttpClient httpClient = new TenpayHttpClient(); httpClient.setTimeOut(5); //设置请求内容 httpClient.setReqContent(queryReq.getRequestURL()); if (httpClient.call()) { //设置结果参数 ClientResponseHandler queryRes = new ClientResponseHandler(); queryRes.setContent(httpClient.getResContent()); queryRes.setKey(key); //判断签名及结果 //只有签名正确,retcode为0,trade_state为0才是支付成功 if (queryRes.isTenpaySign() && queryRes.getParameter("retcode") == "0" && queryRes.getParameter("trade_state") == "0" && queryRes.getParameter("trade_mode") == "1") { string out_trade_no = queryRes.getParameter("out_trade_no"); //财富通订单号 string transaction_id = queryRes.getParameter("transaction_id"); //金额,以分为单位 string total_fee = queryRes.getParameter("total_fee"); IPayHistory order = OnlinePayBusiness.Instance.GetOrder(out_trade_no, ThisCompanyType); if (order == null) { CoreHelper.EventLog.Log(string.Format("在线支付确认时找不到订单{0} 订单号{1}", ThisCompanyType, out_trade_no), true); //context.Response.Write("fail"); return "fail"; } order.spBillno = transaction_id; decimal fee = Convert.ToDecimal(total_fee); lock (thisLock) { Confirm(order, GetType(), fee / 100); } //context.Response.Write("success"); return "success"; } } } //context.Response.Write("fail"); return "fail"; }