Esempio n. 1
0
        public async Task <T> ExecuteAsync <T>(IKdniaoRequest <T> request, KdniaoOptions options) where T : KdniaoResponse
        {
            OptionsValidate.Confirm(options);

            var dataSign = Encrypt.Compute(request.GetRequestData(), options.AppKey, "UTF-8");
            var param    = new KdniaoDictionary(request.GetParameters())
            {
                { "EBusinessID", options.EBusinessID },
                { "DataSign", HttpUtility.UrlEncode(dataSign, Encoding.UTF8) },
            };
            var reqUrl = options.IsSandBox == false?request.GetNotifyUrl() : request.GetSandBoxNotifyUrl();

            var form     = new FormUrlEncodedContent(param);
            var client   = _httpClientFactory.CreateClient(nameof(KdniaoClient));
            var response = await client.PostAsync(reqUrl, form);

            var result = await response.Content.ReadAsStringAsync();

            return(JsonUtil.Deserialize <T>(result));
        }