protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { AlipayNotify aliNotify = new AlipayNotify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult) //验证成功 { if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS") // 判断支付状态TRADE_FINISHED(文档中有枚举表可以参考) { //更新数据库的订单语句 string orderNumber = RequestHelper.GetForm <string>("out_trade_no"); OrderInfo order = OrderBLL.ReadOrderByNumber(orderNumber, 0); if (order.ID > 0) { if (order.OrderStatus == (int)OrderStatus.WaitPay) { order.OrderStatus = (int)OrderStatus.WaitCheck; OrderBLL.UpdateOrder(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderID = order.ID; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户支付宝在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.AddOrderAction(orderAction); } } //else //{ // UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRechargeByNumber(orderNumber, 0); // if (userRecharge.ID > 0 && userRecharge.IsFinish == (int)BoolType.False) // { // userRecharge.IsFinish = (int)BoolType.True; // UserRechargeBLL.UpdateUserRecharge(userRecharge); // //账户记录 // string note = "支付宝在线冲值:" + userRecharge.Number; // UserAccountRecordBLL.AddUserAccountRecord(userRecharge.Money, 0, note, userRecharge.UserID, userRecharge.UserName); // } //} } Response.Write("success"); //请不要修改或删除 } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { AlipayNotify aliNotify = new AlipayNotify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS") { //更新数据库的订单语句 message = "成功付款"; string orderNumber = RequestHelper.GetQueryString <string>("out_trade_no"); OrderInfo order = OrderBLL.ReadOrderByNumber(orderNumber, 0); if (order.ID > 0) { if (order.OrderStatus == (int)OrderStatus.WaitPay) { order.OrderStatus = (int)OrderStatus.WaitCheck; OrderBLL.UpdateOrder(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderID = order.ID; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户支付宝在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.AddOrderAction(orderAction); message = "您已经成功支付订单:" + orderNumber; } } //else //{ // UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRechargeByNumber(orderNumber, 0); // if (userRecharge.ID > 0 && userRecharge.IsFinish == (int)BoolType.False) // { // userRecharge.IsFinish = (int)BoolType.True; // UserRechargeBLL.UpdateUserRecharge(userRecharge); // //账户记录 // string note = "支付宝在线冲值:" + userRecharge.Number; // UserAccountRecordBLL.AddUserAccountRecord(userRecharge.Money, 0, note, userRecharge.UserID, userRecharge.UserName); // message = "您的冲值已经成功完成"; // } //} ResponseHelper.Redirect("PrePaidCourse.aspx"); } else { Response.Write("trade_status=" + Request.QueryString["trade_status"]); } } else//验证失败 { Response.Write("验证失败"); } } else { Response.Write("无返回参数"); } }