private async Task <UnionPayDictionary> GetParametersAsync(HttpRequest request)
        {
            var parameters = new UnionPayDictionary();
            var form       = await request.ReadFormAsync();

            foreach (var iter in form)
            {
                parameters.Add(iter.Key, iter.Value);
            }
            return(parameters);
        }
        public async Task <T> ExecuteAsync <T>(IUnionPayRequest <T> request) where T : UnionPayResponse
        {
            var version = string.Empty;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                version = request.GetApiVersion();
            }
            else
            {
                version = Options.Version;
            }

            var merId = Options.MerId;

            if (Options.TestMode && (request is UnionPayForm05_7_FileTransferRequest || request is UnionPayForm_6_6_FileTransferRequest))
            {
                merId = "700000000000001";
            }

            var txtParams = new UnionPayDictionary(request.GetParameters())
            {
                { VERSION, version },
                { ENCODING, Options.Encoding },
                { SIGNMETHOD, Options.SignMethod },
                { ACCESSTYPE, Options.AccessType },
                { MERID, merId },
            };

            if (request.HasEncryptCertId())
            {
                txtParams.Add(ENCRYPTCERTID, EncryptCertificate.certId);
            }

            UnionPaySignature.Sign(txtParams, SignCertificate.certId, SignCertificate.key, Options.SecureKey);

            var query = HttpClientEx.BuildQuery(txtParams);

            Logger?.LogTrace(0, "Request:{query}", query);

            var body = await Client.DoPostAsync(request.GetRequestUrl(Options.TestMode), query);

            Logger?.LogTrace(1, "Response:{content}", body);

            var dic = ParseQueryString(body);

            if (string.IsNullOrEmpty(body))
            {
                throw new Exception("sign check fail: Body is Empty!");
            }

            var ifValidateCNName = !Options.TestMode;

            if (!UnionPaySignature.Validate(dic, RootCertificate.cert, MiddleCertificate.cert, Options.SecureKey, ifValidateCNName))
            {
                throw new Exception("sign check fail: check Sign and Data Fail!");
            }

            var parser = new UnionPayDictionaryParser <T>();
            var rsp    = parser.Parse(dic);

            rsp.Body = body;
            return(rsp);
        }