Exemplo n.º 1
0
        public void CreateUniqueThresholdActivityAsyncTest()
        {
            var key          = TenPayHelper.GetRegisterKey(Config.SenparcWeixinSetting);
            var TenPayV3Info = TenPayV3InfoCollection.Data[key];

            // 如果还未创建支付有礼活动 则建立支付有礼活动
            if (createUniqueThresholdActivityResult is null)
            {
                CreateUniqueThresholdActivityAsyncTest();
            }

            // TODO:流水号?这样是否有效?
            var out_request_no = string.Format("{0}{1}{2}", TenPayV3Info.MchId /*10位*/, SystemTime.Now.ToString("yyyyMMddHHmmss"), TenPayV3Util.BuildRandomStr(6));

            //TODO: 此接口测试依赖商户券接口和图片上传接口
            var activity_base_info = new CreateUniqueThresholdActivityRequestData.Activity_Base_Info("Senparc支付有礼单元测试活动", "活动副标题", "TODO:仅支持通过《图片上传API》接口获取的图片URL地址", null, new TenpayDateTime(DateTime.Now), new TenpayDateTime(DateTime.Now.AddHours(2)), null, out_request_no, "OFF_LINE_PAY", null, null);
            var award_send_rule    = new CreateUniqueThresholdActivityRequestData.Award_Send_Rule(100, "SINGLE_COUPON", "BUSIFAVOR", new CreateUniqueThresholdActivityRequestData.Award_Send_Rule.Award_List[] { new(createBusifavorStockResult.stock_id, "TODO:原始图", "TODO:缩略图") }, "IN_SEVICE_COUPON_MERCHANT", null);
        /// <summary>
        /// 创建全场满额送活动接口
        /// <para>商户可以创建满额送活动,用户支付后送全场券,提升交易额。</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter9_7_2.shtml </para>
        /// </summary>
        /// <param name="data">微信支付需要POST的Data数据</param>
        /// <param name="timeOut">超时时间,单位为ms </param>
        /// <returns></returns>
        public async Task <CreateUniqueThresholdActivityReturnJson> CreateUniqueThresholdActivityAsync(CreateUniqueThresholdActivityRequestData data, int timeOut = Config.TIME_OUT)
        {
            var url = ReurnPayApiUrl($"https://api.mch.weixin.qq.com/{{0}}v3/marketing/paygiftactivity/unique-threshold-activity");
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);

            return(await tenPayApiRequest.RequestAsync <CreateUniqueThresholdActivityReturnJson>(url, data, timeOut));
        }