Example #1
0
        public async Task <ActionResult> WxpayNotifyUrl()
        {
            var             loger   = LogManager.GetLogger("Wxpay");
            HttpContextBase context = HttpContext;

            OSharp.Web.Mvc.Pay.WxPay.WxPayData notifyData = new OSharp.Web.Mvc.Pay.WxPay.Notify(context).GetNotifyData();
            loger.Error("notifyData:{0}", notifyData);
            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                return(ReturnWxContent("FAIL", "支付结果中微信订单号不存在"));
            }
            //查询订单,判断订单真实性
            string transactionId = notifyData.GetValue("transaction_id").ToString();

            loger.Error("transactionId:{0}", transactionId);
            if (!QueryWxOrder(transactionId))
            {
                //若订单查询失败,则立即返回结果给微信支付后台
                return(ReturnWxContent("FAIL", "订单查询失败"));
            }
            //查询订单成功
            else
            {
                string orderNo = notifyData.GetValue("out_trade_no").ToString();
                //OperationResult result = await OrderContract.PayOrder(orderNo, transactionId, PayType.微信);
                //return result.Successed ? ReturnWxContent("SUCCESS", "OK") : ReturnWxContent("FAIL", "平台业务处理失败");
                return(ReturnWxContent("SUCCESS", "OK"));
            }
        }
Example #2
0
        public async Task<ActionResult> WxNotifyUrl()
        {
            var loger = LogManager.GetLogger("Alipay");
            HttpContextBase context = HttpContext;
            WxPayData notifyData = new Notify(context).GetNotifyData();

            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                loger.Error(GetType().ToString(), "The Pay result is error : " + res.ToXml());
                return Content(res.ToXml());
            }

            string transactionId = notifyData.GetValue("transaction_id").ToString();

            //查询订单,判断订单真实性
            if (!QueryWxOrder(transactionId))
            {
                //若订单查询失败,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "订单查询失败");
                loger.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                return Content(res.ToXml());
            }
            //查询订单成功
            else
            {
                string orderNo = notifyData.GetValue("out_trade_no").ToString();
                //await OrderContract.PayOrder(orderNo, PayType.微信);

                WxPayData res = new WxPayData();
                res.SetValue("return_code", "SUCCESS");
                res.SetValue("return_msg", "OK");
                loger.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                return Content(res.ToXml());
            }
        }