OrderQuery() public static method

public static OrderQuery ( WxPayData inputObj, int timeOut = 6 ) : WxPayData
inputObj WxPayData
timeOut int
return WxPayData
Ejemplo n.º 1
0
        public static WxPayData OrdeQquery(string orderno)
        {
            WxPayData data = new WxPayData();

            data.SetValue("out_trade_no", orderno);
            return(WxPayApi.OrderQuery(data));
        }
Ejemplo n.º 2
0
        //查询订单
        public static string QueryOrder(string transaction_id = "", string out_trade_no = "")
        {
            Log.Info("QueryOrder", "Query out_trade_no is paied or transaction_id is valid  transaction_id: " + transaction_id + ", out_trade_no:" + out_trade_no);

            WxPayData data = new WxPayData();

            if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
            {
                data.SetValue("transaction_id", transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去查单
            {
                data.SetValue("out_trade_no", out_trade_no);
            }

            WxPayData res = WxPayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据

            if (res.GetValue("return_code").ToString() == "SUCCESS" &&
                res.GetValue("result_code").ToString() == "SUCCESS" && res.GetValue("trade_state").ToString() == "SUCCESS")
            {
                return("SUCCESS");
            }
            else
            {
                return("FAIL");
            }
        }
Ejemplo n.º 3
0
        //查询订单
        private bool QueryOrder(string transaction_id)
        {
            WXReturnResultModel models = new WXReturnResultModel();
            WxPayData           req    = new WxPayData();

            req.SetValue("transaction_id", transaction_id);
            WxPayData res = WxPayApi.OrderQuery(req);

            if (res.GetValue("return_code").ToString() == "SUCCESS" && res.GetValue("result_code").ToString() == "SUCCESS")
            {
                models.openid         = res.GetValue("openid").ToString();
                models.trade_type     = res.GetValue("trade_type").ToString();
                models.bank_type      = res.GetValue("bank_type").ToString();
                models.total_fee      = res.GetValue("total_fee").ToString();
                models.fee_type       = res.GetValue("fee_type").ToString();
                models.transaction_id = res.GetValue("transaction_id").ToString();
                models.out_trade_no   = res.GetValue("out_trade_no").ToString();
                models.is_subscribe   = res.GetValue("is_subscribe").ToString();
                models.time_end       = res.GetValue("time_end").ToString();

                new WXReturnDal().AddWXReturnInfo(models);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(serial))
            {
                //交易流水与支付接口
                Song.Entities.MoneyAccount moneyAccount = Business.Do <IAccounts>().MoneySingle(serial);
                Song.Entities.PayInterface payInterface = Business.Do <IPayInterface>().PaySingle(moneyAccount.Pai_ID);
                total_fee = (int)(moneyAccount.Ma_Money * 100);
                //商户id与支付密钥
                string appid = payInterface.Pai_ParterID;      //绑定支付的APPID(必须配置)
                WeiSha.Common.CustomConfig config = CustomConfig.Load(payInterface.Pai_Config);
                string mchid  = config["MCHID"].Value.String;  //商户id
                string paykey = config["Paykey"].Value.String; //支付密钥
                //
                WxPayData data = new WxPayData();
                data.SetValue("out_trade_no", serial);                              //商户订单号
                WxPayData result = WxPayApi.OrderQuery(data, appid, mchid, paykey); //提交订单查询请求给API,接收返回数据

                Log.Info("OrderQuery", "订单查询结果GET, result : " + result.ToXml());
                string state = result.GetValue("trade_state").ToString();
                if (state == "SUCCESS")
                {
                    //付款方与收款方(商户id)
                    moneyAccount.Ma_Buyer  = result.GetValue("attach").ToString();
                    moneyAccount.Ma_Seller = result.GetValue("mch_id").ToString();
                    Business.Do <IAccounts>().MoneyConfirm(moneyAccount);
                    lbError.Visible  = false;
                    lbSucess.Visible = true;
                }
                else
                {
                    lbError.Visible  = true;
                    lbSucess.Visible = false;
                }
            }
            else
            {
                //接收来自微信支付中心的异步请求
                ResultNotify resultNotify = new ResultNotify(this);
                //resultNotify.ProcessNotify();
                //获取结果
                WxPayData notifyData   = resultNotify.GetNotifyData();
                string    out_trade_no = notifyData.GetValue("out_trade_no").ToString();
                Log.Info(this.GetType().ToString(), "商户流水号 : " + out_trade_no);
                if (!string.IsNullOrWhiteSpace(out_trade_no))
                {
                    Song.Entities.MoneyAccount maccount = Business.Do <IAccounts>().MoneySingle(out_trade_no);
                    if (maccount != null)
                    {
                        //付款方与收款方(商户id)
                        maccount.Ma_Buyer  = notifyData.GetValue("attach").ToString();
                        maccount.Ma_Seller = notifyData.GetValue("mch_id").ToString();
                        Business.Do <IAccounts>().MoneyConfirm(maccount);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //查询订单
        private bool QueryOrder(string transaction_id)
        {
            WxPayData req = new WxPayData();

            req.SetValue("transaction_id", transaction_id);
            WxPayData res      = WxPayApi.OrderQuery(req);
            var       isSucces = res.GetValue("return_code").ToString() == "SUCCESS" && res.GetValue("result_code").ToString() == "SUCCESS";

            return(isSucces);
        }
Ejemplo n.º 6
0
        /***
         * 订单查询完整业务流程逻辑
         * @param transaction_id 微信订单号(优先使用)
         * @param out_trade_no 商户订单号
         * @return 订单查询结果(xml格式)
         */
        public static WxPayData Run(string transaction_id, string out_trade_no)
        {
            WxPayData data = new WxPayData();

            if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
            {
                data.SetValue("transaction_id", transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去查单
            {
                data.SetValue("out_trade_no", out_trade_no);
            }

            return(WxPayApi.OrderQuery(data));//提交订单查询请求给API,接收返回数据
        }
Ejemplo n.º 7
0
        //查询订单
        private bool QueryOrder(string transaction_id)
        {
            WxPayData req = new WxPayData();

            req.SetValue("transaction_id", transaction_id);
            WxPayData res = WxPayApi.OrderQuery(req);

            if (res.GetValue("return_code").ToString() == "SUCCESS" && res.GetValue("result_code").ToString() == "SUCCESS")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        //查询订单
        private async System.Threading.Tasks.Task <bool> QueryOrderAsync(string transaction_id)
        {
            WxPayData req = new WxPayData();

            req.SetValue("transaction_id", transaction_id);
            WxPayData res = await WxPayApi.OrderQuery(req);

            if (res.GetValue("return_code").ToString() == "SUCCESS" &&
                res.GetValue("result_code").ToString() == "SUCCESS")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        //查询订单
        private string QueryOrdertime(string transaction_id, int tid)
        {
            WxPayData req = new WxPayData();

            req.SetValue("transaction_id", transaction_id);
            WxPayData res = WxPayApi.OrderQuery(req, tid);

            if (res.GetValue("return_code").ToString() == "SUCCESS" &&
                res.GetValue("result_code").ToString() == "SUCCESS")
            {
                return(res.GetValue("time_end").ToString());
            }
            else
            {
                return("null");
            }
        }
Ejemplo n.º 10
0
        /***
         * 订单查询完整业务流程逻辑
         * @param transaction_id 微信订单号(优先使用)
         * @param out_trade_no 商户订单号
         * @return 订单查询结果(xml格式)
         */
        public static string Run(string transaction_id, string out_trade_no)
        {
            Log.Info("OrderQuery", "OrderQuery is processing...");

            WxPayData data = new WxPayData();

            if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
            {
                data.SetValue("transaction_id", transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去查单
            {
                data.SetValue("out_trade_no", out_trade_no);
            }

            WxPayData result = WxPayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据

            Log.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
            return(result.ToPrintStr());
        }
Ejemplo n.º 11
0
        /**
         *
         * 查询订单情况
         * @param string out_trade_no  商户订单号
         * @param int succCode         查询订单结果:0表示订单不成功,1表示订单成功,2表示继续查询
         * @return 订单查询接口返回的数据,参见协议接口
         */
        public static WxPayData Query(string out_trade_no, out int succCode, string AppId = "", string MacId = "", string key = "")
        {
            WxPayData queryOrderInput = new WxPayData();

            queryOrderInput.SetValue("out_trade_no", out_trade_no);
            WxPayData result = WxPayApi.OrderQuery(queryOrderInput, 20, AppId, MacId, key);

            if (result.GetValue("return_code").ToString() == "SUCCESS" &&
                result.GetValue("result_code").ToString() == "SUCCESS")
            {
                //支付成功
                if (result.GetValue("trade_state") != null && result.GetValue("trade_state").ToString() == "SUCCESS")
                {
                    succCode = 1;
                    return(result);
                }
                //用户支付中,需要继续查询
                else if (result.GetValue("trade_state") != null && result.GetValue("trade_state").ToString() == "USERPAYING")
                {
                    succCode = 2;
                    return(result);
                }
                else if (result.GetValue("trade_state") != null && result.GetValue("trade_state").ToString() == "NOTPAY")
                {
                    succCode = 3;
                    return(result);
                }
            }

            //如果返回错误码为“此交易订单号不存在”则直接认定失败
            if (result.GetValue("err_code") != null && result.GetValue("err_code").ToString() == "ORDERNOTEXIST")
            {
                succCode = 0;
            }
            else
            {
                //如果是系统错误,则后续继续
                succCode = 2;
            }
            return(result);
        }
Ejemplo n.º 12
0
        /**
         *
         * 查询订单情况
         * @param string out_trade_no  商户订单号
         * @param int succCode         查询订单结果:0表示订单不成功,1表示订单成功,2表示继续查询
         * @return 订单查询接口返回的数据,参见协议接口
         */
        public static WxPayData Query(WeiXinPayConfig weiXinPayConfig, string out_trade_no, out int succCode)
        {
            WxPayData queryOrderInput = new WxPayData();

            queryOrderInput.SetValue("out_trade_no", out_trade_no);
            WxPayData result = WxPayApi.OrderQuery(weiXinPayConfig, queryOrderInput);

            if (result.GetValue("return_code").ToString() == "SUCCESS" &&
                result.GetValue("result_code").ToString() == "SUCCESS")
            {
                //支付成功
                if (result.GetValue("trade_state").ToString() == "SUCCESS")
                {
                    succCode = 1;
                    return(result);
                }
                //用户支付中,需要继续查询
                else if (result.GetValue("trade_state").ToString() == "USERPAYING")
                {
                    succCode = 2;
                    return(result);
                }
            }

            //如果返回错误码为“此交易订单号不存在”则直接认定失败
            if (result.GetValue("err_code").ToString() == "ORDERNOTEXIST")
            {
                succCode = 0;
            }
            else
            {
                //如果是系统错误,则后续继续
                succCode = 2;
            }
            return(result);
        }