public void WxNotify() { Notify notify = new Notify(this.HttpContext); WxPayData notifyData = notify.GetNotifyData(); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); Response.Write(res.ToXml()); Response.End(); } string transaction_id = notifyData.GetValue("transaction_id").ToString(); var model = IPayOrderService.Find(transaction_id); if (model == null || model.State != PayState.WaitPay) { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); Response.Write(res.ToXml()); Response.End(); } //查询订单,判断订单真实性 if (!QueryOrder(transaction_id)) { IPayOrderService.FailedPayOrder(transaction_id); //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); Response.Write(res.ToXml()); Response.End(); } //查询订单成功 else { WxPayData res = new WxPayData(); var result = IPayOrderService.SuccessPayOrder(transaction_id, transaction_id); if (result.Result) { res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); } else { res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单修改失败"); } Response.Write(res.ToXml()); Response.End(); } }
public ActionResult Scan(string orderId) { var model = IPayOrderService.Find(orderId); if (model != null) { if (model.State == PayState.WaitPay) { var obj = OrderQuery.Run("", orderId); if (obj.GetValue("trade_state").ToString() == "SUCCESS") { model.State = PayState.Success; IPayOrderService.SuccessPayOrder(orderId, obj.GetValue("transaction_id").ToString()); } } } return(DataErorrJResult()); }
///// <summary> ///// 删除 ///// </summary> ///// <param name="ids"></param> ///// <returns></returns> //public ActionResult Confirm(string ID,string VoucherThum,string VoucherNO, PayCode Type) //{ // var model = IPayOrderService.Find(ID); // if (model != null&&model.State==PayState.WaitPay) // { // model.State = PayState.Success; // model.VoucherNO = VoucherNO; // model.VoucherThum = VoucherThum; // model.Type = Type; // var result = IPayOrderService.Update(model); // if (result > 0) // { // JResult(IPayOrderService.SuccessPayOrder(ID, VoucherNO)); // } // } // return DataErorrJResult(); //} /// <summary> /// 查找实体 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Find(string ID) { var model = IPayOrderService.Find(ID); //if (model != null) //{ // model.PriceList = IPayOrderPriceService.GetListByPayOrderID(ID); //} return(JResult(model)); }