Beispiel #1
0
        /// <summary>
        /// 查询合作关系接口
        /// <para>该接口主要为商户提供合作关系列表的查询能力。</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter9_5_3.shtml </para>
        /// </summary>
        /// <param name="data">查询合作关系需要的Data数据</param>
        /// <param name="limit">分页大小<para>query分页大小,最大50。不传默认为20。</para><para>示例值:5</para></param>
        /// <param name="offset">分页页码<para>query分页页码,页码从0开始。</para><para>示例值:10</para></param>
        /// <param name="timeOut">超时时间,单位为ms</param>
        /// <returns></returns>
        public async Task <QueryPartnershipsReturnJson> QueryPartnershipsAsync(QueryPartnershipsRequestData data, ulong limit = 20, ulong offset = 0, int timeOut = Config.TIME_OUT)
        {
            // TODO: 此处序列化Json需测试时候可以换行问题
            var url = ReurnPayApiUrl($"https://api.mch.weixin.qq.com/{{0}}v3/marketing/partnerships?authorized_data={data.authorized_data.ToJson()}&partner={data.partner.ToJson()}&offset={offset}&limit={limit}".UrlEncode());
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);

            return(await tenPayApiRequest.RequestAsync <QueryPartnershipsReturnJson>(url, null, timeOut, ApiRequestMethod.GET));
        }
        public void QueryPartnershipsAsyncTest()
        {
            // 如果还未创建建立合作关系 则建立合作关系
            if (buildPartnershipsResult is null)
            {
                BuildPartnershipsAsyncTest();
            }

            var requestData = new QueryPartnershipsRequestData(buildPartnershipsResult);

            var marketingApis = new MarketingApis();
            var result        = marketingApis.QueryPartnershipsAsync(requestData).GetAwaiter().GetResult();

            Console.WriteLine("微信支付 V3 查询合作关系列表接口结果:" + result.ToJson(true));

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultCode.Success);
            Assert.IsTrue(result.VerifySignSuccess == true);//通过验证
        }