/// <summary>
        /// 获取资金对账单
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">传入的参数是null</exception>
        /// <exception cref="WeChatPayException">调用微信接口失败时返回的错误信息</exception>
        public async Task <OrderTable> GetFundBillAsync(QueryFundBillRequest parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }
            parameter.AppId = _appId;
            parameter.MchId = _mchId;
            parameter.Sign  = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey);
            string url    = "https://api.mch.weixin.qq.com/pay/downloadfundflow";
            string body   = XmlSerializeHelper.ObjectToXmlString(parameter);
            string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(),
                                                             body, "xml/text");

            if (result.Contains("error_code"))
            {
                var xml = new XmlDocument();
                xml.Load(result);
                var nodes = xml.FirstChild;
                throw new WeChatApiException(nodes["error_code"].InnerText,
                                             nodes["return_msg"].InnerText, "下载对账单");
            }

            return(new OrderTable(result));
        }
Beispiel #2
0
        public async Task GetFundBill()
        {
            string nonce     = Caster.WeChat.Common.Helper.GetNonceStr(32);
            string date      = "20200224";
            var    parameter = new QueryFundBillRequest
            {
                Date        = date,
                Nonce       = nonce,
                AccountType = "Basic"
            };
            var result = await _web.PayService.GetFundBillAsync(parameter);

            Assert.True(result != null, "result!=null");
        }