示例#1
0
        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();
            }
        }
示例#2
0
        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());
        }