Exemple #1
0
        /// <summary>
        /// 异步调用“提交付款码支付”的微信支付接口。
        /// <para>
        ///     REF: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
        /// </para>
        /// </summary>
        /// <param name="httpClient"></param>
        /// <param name="requestData">请求参数。</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static async Task <WxpayApiResult <PayMicropayResponseData> > ExecutePayMicropayAsync(this WxpayApiClient httpClient, PayMicropayRequestData requestData, CancellationToken cancellationToken = default)
        {
            if (requestData == null)
            {
                throw new ArgumentNullException(nameof(requestData));
            }

            IHttpRequest request = httpClient.Create(HttpMethods.POST)
                                   .AddUrlSegment("pay", "unifiedorder")
                                   .SetBody(WxpayHelper.SerializeRequestParameter(requestData, httpClient.ApiConfig.AppID, httpClient.ApiConfig.MerchantID, httpClient.ApiConfig.ApiKey, httpClient.ApiConfig.SignType));
            IHttpResponse response = await httpClient.ExecuteAsync(request, cancellationToken);

            return(await response.ReadAsWxpayApiResultAsync <PayMicropayResponseData>());
        }
Exemple #2
0
        /// <summary>
        /// 异步调用“发放裂变红包”的微信支付接口,该接口需使用证书。
        /// <para>
        ///     REF: https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
        /// </para>
        /// </summary>
        /// <param name="httpClient"></param>
        /// <param name="requestData">请求参数。</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static async Task <WxpayApiResult <MmpaymkttransfersSendGroupRedPackResponseData> > ExecuteMmpaymkttransfersSendGroupRedPackAsync(this WxpayApiClient httpClient, MmpaymkttransfersSendGroupRedPackRequestData requestData, CancellationToken cancellationToken = default)
        {
            if (requestData == null)
            {
                throw new ArgumentNullException(nameof(requestData));
            }

            IHttpRequest request = httpClient.Create(HttpMethods.POST)
                                   .AddUrlSegment("mmpaymkttransfers", "sendgroupredpack")
                                   .SetBody(WxpayHelper.SerializeRequestParameter(requestData, httpClient.ApiConfig.AppID, httpClient.ApiConfig.MerchantID, httpClient.ApiConfig.ApiKey, httpClient.ApiConfig.SignType));
            IHttpResponse response = await httpClient.ExecuteAsync(request, cancellationToken);

            return(await response.ReadAsWxpayApiResultAsync <MmpaymkttransfersSendGroupRedPackResponseData>());
        }