Esempio n. 1
0
        /// <summary>
        /// 获得订单笔数,配合BCPayQueryByCondition使用,使用查询订单时一样的参数
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static int BCPayQueryCount(BCQueryBillParameter para)
        {
            string payQueryUrl = BCPrivateUtil.getHost() + BCConstants.version + BCConstants.billsCountURL;

            string paraString = preparePayQueryByConditionParameters(para);

            try
            {
                string url = payQueryUrl + "?para=" + HttpUtility.UrlEncode(paraString, Encoding.UTF8);
                HttpWebResponse response = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout);
                string respString = BCPrivateUtil.GetResponseString(response);
                return handleQueryCountResult(respString);
            }
            catch (Exception e)
            {
                var ex = new BCException(e.Message);
                throw ex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 支付订单查询
        /// </summary>
        /// <param name="channel">渠道类型
        ///     选填
        ///     可以通过enum BCPay.QueryChannel获取
        ///     channel的参数值含义:
        ///     WX_APP:       微信手机APP支付
        ///     WX_NATIVE:    微信公众号二维码支付
        ///     WX_JSAPI:     微信公众号支付
        ///     ALI_APP:      支付宝APP支付
        ///     ALI_WEB:      支付宝网页支付 
        ///     ALI_QRCODE:   支付宝内嵌二维码支付
        ///     UN_APP:       银联APP支付
        ///     UN_WEB:       银联网页支付
        ///     JD_WAP:       京东wap支付
        ///     JD_WEB:       京东web支付
        ///     YEE_WAP:      易宝wap支付 
        ///     YEE_WEB:      易宝web支付
        ///     KUAIQIAN_WAP: 快钱wap支付
        ///     KUAIQIAN_WEB: 快钱web支付
        ///     注意:不传channel也能查询的前提是保证所有渠道所有订单号不同,如果出现两个订单号重复,会报错提示传入channel进行区分
        /// </param>
        /// <param name="billNo">商户订单号
        /// </param>
        /// <param name="startTime">起始时间
        ///     毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取
        ///     选填
        /// </param>
        /// <param name="endTime">结束时间
        ///     毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取
        ///     选填
        /// </param>
        /// <param name="spayResult">订单状态
        ///     订单是否成功,null为全部返回,true只返回成功订单,false只返回失败订单
        ///     选填
        /// </param>
        /// <param name="needDetail">是否需要返回渠道详细信息
        ///     决定是否需要返回渠道的回调信息,true为需要
        ///     选填
        /// </param>
        /// <param name="skip">查询起始位置
        ///     默认为0。设置为10表示忽略满足条件的前10条数据
        ///     选填
        /// </param>
        /// <param name="limit">查询的条数
        ///     默认为10,最大为50。设置为10表示只返回满足条件的10条数据
        ///     选填
        /// </param>
        /// <returns></returns>
        public static List<BCBill> BCPayQueryByCondition(BCQueryBillParameter para)
        {
            Random random = new Random();
            string payQueryUrl = "";
            if (!BCCache.Instance.testMode)
            {
                payQueryUrl = BCPrivateUtil.getHost() + BCConstants.version + BCConstants.billsURL;
            }
            else
            {
                payQueryUrl = BCPrivateUtil.getHost() + BCConstants.version + BCConstants.billsTestURL;
            }

            string paraString = preparePayQueryByConditionParameters(para);

            try
            {
                string url = payQueryUrl + "?para=" + HttpUtility.UrlEncode(paraString, Encoding.UTF8);
                HttpWebResponse response = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout);
                string respString = BCPrivateUtil.GetResponseString(response);
                return handlePayQueryByConditionResult(respString, para.needDetail);
            }
            catch(Exception e)
            {
                var ex = new BCException(e.Message);
                throw ex;
            }
        }
Esempio n. 3
0
        public void preparePayQueryByConditionParametersTest()
        {
            BeeCloud.registerApp("c5d1cba1-5e3f-4ba0-941d-9b0a371fe719", "39a7a518-9ac8-4a9e-87bc-7885f33cf18c", "e14ae2db-608c-4f8b-b863-c8c18953eef2", null);

            BCQueryBillParameter para = new BCQueryBillParameter();
            para.channel = "ALI";
            para.startTime = 1000000000000;
            para.endTime = 1000000000001;
            para.needDetail = true;
            para.result = true;
            para.skip = 10;
            para.limit = 50;

            string paraString = "\"channel\":\"ALI\",\"bill_no\":null,\"start_time\":1000000000000,\"end_time\":1000000000001,\"skip\":10,\"spay_result\":true,\"need_detail\":true,\"limit\":50}";
            string actual = BCPay.preparePayQueryByConditionParameters(para);
            Assert.IsTrue(actual.Contains(paraString));
        }
Esempio n. 4
0
        ///准备订单查询参数
        public static string preparePayQueryByConditionParameters(BCQueryBillParameter para)
        {
            long timestamp = BCUtil.GetTimeStamp(DateTime.Now);

            JsonData data = new JsonData();
            data["app_id"] = BCCache.Instance.appId;
            if (!BCCache.Instance.testMode)
            {
                data["app_sign"] = BCPrivateUtil.getAppSignature(BCCache.Instance.appId, BCCache.Instance.appSecret, timestamp.ToString());
            }
            else
            {
                data["app_sign"] = BCPrivateUtil.getAppSignatureByTestSecret(timestamp.ToString());
            }
            data["timestamp"] = timestamp;
            data["channel"] = para.channel;
            data["bill_no"] = para.billNo;
            data["start_time"] = para.startTime;
            data["end_time"] = para.endTime;
            data["skip"] = para.skip;
            data["spay_result"] = para.result;
            data["need_detail"] = para.needDetail;
            data["limit"] = para.limit;

            string paraString = data.ToJson();
            return paraString;
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.Form["querytype"];
            if (type == "aliquery")
            {
                typeChannel = "Ali";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "Ali" + "</span><br/>");

                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "ALI";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "wxquery")
            {
                typeChannel = "WX";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "WX" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "WX";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "unionquery")
            {
                typeChannel = "UN";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "UN" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "UN";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "jdquery")
            {
                typeChannel = "JD";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "JD" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "JD";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "ybquery")
            {
                typeChannel = "YEE";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "YEE" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "YEE";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "kqquery")
            {
                typeChannel = "KUAIQIAN";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "KUAIQIAN" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "KUAIQIAN";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            if (type == "beepay")
            {
                typeChannel = "BC_GATEWAY";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "BC_GATEWAY" + "</span><br/>");
                try
                {
                    BCQueryBillParameter para = new BCQueryBillParameter();
                    para.channel = "BC_GATEWAY";
                    para.limit = 50;
                    bills = BCPay.BCPayQueryByCondition(para);
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            this.bind();
        }