示例#1
0
        public AlipaySystemOauthTokenResponse GetToken(string code)
        {
            Dictionary <string, object> runtime_ = new Dictionary <string, object>()
            {
                { "connectTimeout", 15000 },
                { "readTimeout", 15000 },
                { "retry", new Dictionary <string, int?>()
                  {
                      { "maxAttempts", 0 },
                  } },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    Dictionary <string, string> systemParams = new Dictionary <string, string>()
                    {
                        { "method", "alipay.system.oauth.token" },
                        { "app_id", _getConfig("appId") },
                        { "timestamp", _getTimestamp() },
                        { "format", "json" },
                        { "version", "1.0" },
                        { "alipay_sdk", _getSdkVersion() },
                        { "charset", "UTF-8" },
                        { "sign_type", _getConfig("signType") },
                        { "app_cert_sn", _getMerchantCertSN() },
                        { "alipay_root_cert_sn", _getAlipayRootCertSN() },
                    };
                    Dictionary <string, object> bizParams = new Dictionary <string, object>()
                    {
                    };
                    Dictionary <string, string> textParams = new Dictionary <string, string>()
                    {
                        { "grant_type", "authorization_code" },
                        { "code", code },
                    };
                    request_.Protocol = _getConfig("protocol");
                    request_.Method   = "POST";
                    request_.Pathname = "/gateway.do";
                    request_.Headers  = new Dictionary <string, string>()
                    {
                        { "host", _getConfig("gatewayHost") },
                        { "content-type", "application/x-www-form-urlencoded;charset=utf-8" },
                    };
                    request_.Query = TeaConverter.merge <string>(
                        new Dictionary <string, string>()
                    {
                        { "sign", _sign(systemParams, bizParams, textParams) },
                    },
                        systemParams,
                        textParams
                        );
                    request_.Body = TeaCore.BytesReadable(_toUrlEncodedRequestBody(bizParams));
                    _lastRequest  = request_;
                    TeaResponse response_ = TeaCore.DoAction(request_, runtime_);

                    Dictionary <string, object> respMap = _readAsJson(response_, "alipay.system.oauth.token");
                    if (_isCertMode())
                    {
                        if (_verify(respMap, _extractAlipayPublicKey(_getAlipayCertSN(respMap))))
                        {
                            return(TeaModel.ToObject <AlipaySystemOauthTokenResponse>(_toRespModel(respMap)));
                        }
                    }
                    else
                    {
                        if (_verify(respMap, _getConfig("alipayPublicKey")))
                        {
                            return(TeaModel.ToObject <AlipaySystemOauthTokenResponse>(_toRespModel(respMap)));
                        }
                    }
                    throw new TeaException(new Dictionary <string, string>()
                    {
                        { "message", "验签失败,请检查支付宝公钥设置是否正确。" },
                    });
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }
示例#2
0
        /**
         * Encapsulate the request and invoke the network
         * @param action api name
         * @param protocol http or https
         * @param method e.g. GET
         * @param pathname pathname of every api
         * @param request which contains request params
         * @param runtime which controls some details of call api, such as retry times
         * @return the response
         */
        public Dictionary <string, object> DoRequest(string version, string action, string protocol, string method, string pathname, Dictionary <string, object> request, Dictionary <string, string> headers, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime)
        {
            Dictionary <string, object> runtime_ = new Dictionary <string, object>
            {
                { "timeouted", "retry" },
                { "readTimeout", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.ReadTimeout, _readTimeout) },
                { "connectTimeout", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.ConnectTimeout, _connectTimeout) },
                { "httpProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.HttpProxy, _httpProxy) },
                { "httpsProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.HttpsProxy, _httpsProxy) },
                { "noProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.NoProxy, _noProxy) },
                { "maxIdleConns", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.MaxIdleConns, _maxIdleConns) },
                { "maxIdleTimeMillis", _maxIdleTimeMillis },
                { "keepAliveDurationMillis", _keepAliveDurationMillis },
                { "maxRequests", _maxRequests },
                { "maxRequestsPerHost", _maxRequestsPerHost },
                { "retry", new Dictionary <string, object>
                  {
                      { "retryable", runtime.Autoretry },
                      { "maxAttempts", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.MaxAttempts, 3) },
                  } },
                { "backoff", new Dictionary <string, object>
                  {
                      { "policy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.BackoffPolicy, "no") },
                      { "period", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.BackoffPeriod, 1) },
                  } },
                { "ignoreSSL", runtime.IgnoreSSL },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    request_.Protocol = AlibabaCloud.TeaUtil.Common.DefaultString(_protocol, protocol);
                    request_.Method   = method;
                    request_.Pathname = pathname;
                    request_.Query    = new Dictionary <string, string>
                    {
                        { "method", action },
                        { "version", version },
                        { "sign_type", "HmacSHA1" },
                        { "req_time", AntChain.AlipayUtil.AntchainUtils.GetTimestamp() },
                        { "req_msg_id", AntChain.AlipayUtil.AntchainUtils.GetNonce() },
                        { "access_key", _accessKeyId },
                        { "base_sdk_version", "TeaSDK-2.0" },
                        { "sdk_version", "1.1.6" },
                    };
                    if (!AlibabaCloud.TeaUtil.Common.Empty(_securityToken))
                    {
                        request_.Query["security_token"] = _securityToken;
                    }
                    request_.Headers = TeaConverter.merge <string>
                                       (
                        new Dictionary <string, string>()
                    {
                        { "host", AlibabaCloud.TeaUtil.Common.DefaultString(_endpoint, "openapi.antchain.antgroup.com") },
                        { "user-agent", AlibabaCloud.TeaUtil.Common.GetUserAgent(_userAgent) },
                    },
                        headers
                                       );
                    Dictionary <string, object> tmp = AlibabaCloud.TeaUtil.Common.AnyifyMapValue(AlibabaCloud.Commons.Common.Query(request));
                    request_.Body = TeaCore.BytesReadable(AlibabaCloud.TeaUtil.Common.ToFormString(tmp));
                    request_.Headers["content-type"] = "application/x-www-form-urlencoded";
                    Dictionary <string, string> signedParam = TeaConverter.merge <string>
                                                              (
                        request_.Query,
                        AlibabaCloud.Commons.Common.Query(request)
                                                              );
                    request_.Query["sign"] = AntChain.AlipayUtil.AntchainUtils.GetSignature(signedParam, _accessKeySecret);
                    _lastRequest           = request_;
                    TeaResponse response_ = TeaCore.DoAction(request_, runtime_);

                    string raw = AlibabaCloud.TeaUtil.Common.ReadAsString(response_.Body);
                    object obj = AlibabaCloud.TeaUtil.Common.ParseJSON(raw);
                    Dictionary <string, object> res  = AlibabaCloud.TeaUtil.Common.AssertAsMap(obj);
                    Dictionary <string, object> resp = AlibabaCloud.TeaUtil.Common.AssertAsMap(res.Get("response"));
                    if (AntChain.AlipayUtil.AntchainUtils.HasError(raw, _accessKeySecret))
                    {
                        throw new TeaException(new Dictionary <string, object>
                        {
                            { "message", resp.Get("result_msg") },
                            { "data", resp },
                            { "code", resp.Get("result_code") },
                        });
                    }
                    return(resp);
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }
示例#3
0
        public AlipayOfflineMaterialImageUploadResponse Upload(string imageName, string imageFilePath)
        {
            Dictionary <string, object> runtime_ = new Dictionary <string, object>()
            {
                { "connectTimeout", 100000 },
                { "readTimeout", 100000 },
                { "retry", new Dictionary <string, int?>()
                  {
                      { "maxAttempts", 0 },
                  } },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    Dictionary <string, string> systemParams = new Dictionary <string, string>()
                    {
                        { "method", "alipay.offline.material.image.upload" },
                        { "app_id", _getConfig("appId") },
                        { "timestamp", _getTimestamp() },
                        { "format", "json" },
                        { "version", "1.0" },
                        { "alipay_sdk", _getSdkVersion() },
                        { "charset", "UTF-8" },
                        { "sign_type", _getConfig("signType") },
                        { "app_cert_sn", _getMerchantCertSN() },
                        { "alipay_root_cert_sn", _getAlipayRootCertSN() },
                    };
                    Dictionary <string, object> bizParams = new Dictionary <string, object>()
                    {
                    };
                    Dictionary <string, string> textParams = new Dictionary <string, string>()
                    {
                        { "image_type", "jpg" },
                        { "image_name", imageName },
                    };
                    Dictionary <string, string> fileParams = new Dictionary <string, string>()
                    {
                        { "image_content", imageFilePath },
                    };
                    string boundary = _getRandomBoundary();
                    request_.Protocol = _getConfig("protocol");
                    request_.Method   = "POST";
                    request_.Pathname = "/gateway.do";
                    request_.Headers  = new Dictionary <string, string>()
                    {
                        { "host", _getConfig("gatewayHost") },
                        { "content-type", _concatStr("multipart/form-data;charset=utf-8;boundary=", boundary) },
                    };
                    request_.Query = TeaConverter.merge <string>(
                        new Dictionary <string, string>()
                    {
                        { "sign", _sign(systemParams, bizParams, textParams) },
                    },
                        systemParams
                        );
                    request_.Body = _toMultipartRequestBody(textParams, fileParams, boundary);
                    _lastRequest  = request_;
                    TeaResponse response_ = TeaCore.DoAction(request_, runtime_);

                    Dictionary <string, object> respMap = _readAsJson(response_, "alipay.offline.material.image.upload");
                    if (_isCertMode())
                    {
                        if (_verify(respMap, _extractAlipayPublicKey(_getAlipayCertSN(respMap))))
                        {
                            return(TeaModel.ToObject <AlipayOfflineMaterialImageUploadResponse>(_toRespModel(respMap)));
                        }
                    }
                    else
                    {
                        if (_verify(respMap, _getConfig("alipayPublicKey")))
                        {
                            return(TeaModel.ToObject <AlipayOfflineMaterialImageUploadResponse>(_toRespModel(respMap)));
                        }
                    }
                    throw new TeaException(new Dictionary <string, string>()
                    {
                        { "message", "验签失败,请检查支付宝公钥设置是否正确。" },
                    });
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }
示例#4
0
文件: Client.cs 项目: aliyun/tea-roa
        /**
         * Encapsulate the request and invoke the network
         * @param version product version
         * @param protocol http or https
         * @param method e.g. GET
         * @param authType when authType is Anonymous, the signature will not be calculate
         * @param pathname pathname of every api
         * @param query which contains request params
         * @param headers request headers
         * @param body content of request
         * @param runtime which controls some details of call api, such as retry times
         * @return the response
         */
        public async Task <Dictionary <string, object> > DoRequestWithFormAsync(string version, string protocol, string method, string authType, string pathname, Dictionary <string, string> query, Dictionary <string, string> headers, Dictionary <string, object> body, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime)
        {
            Dictionary <string, object> runtime_ = new Dictionary <string, object>
            {
                { "timeouted", "retry" },
                { "readTimeout", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.ReadTimeout, _readTimeout) },
                { "connectTimeout", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.ConnectTimeout, _connectTimeout) },
                { "httpProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.HttpProxy, _httpProxy) },
                { "httpsProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.HttpsProxy, _httpsProxy) },
                { "noProxy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.NoProxy, _noProxy) },
                { "maxIdleConns", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.MaxIdleConns, _maxIdleConns) },
                { "retry", new Dictionary <string, object>
                  {
                      { "retryable", runtime.Autoretry },
                      { "maxAttempts", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.MaxAttempts, 3) },
                  } },
                { "backoff", new Dictionary <string, object>
                  {
                      { "policy", AlibabaCloud.TeaUtil.Common.DefaultString(runtime.BackoffPolicy, "no") },
                      { "period", AlibabaCloud.TeaUtil.Common.DefaultNumber(runtime.BackoffPeriod, 1) },
                  } },
                { "ignoreSSL", runtime.IgnoreSSL },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    request_.Protocol = AlibabaCloud.TeaUtil.Common.DefaultString(_protocol, protocol);
                    request_.Method   = method;
                    request_.Pathname = pathname;
                    request_.Headers  = TeaConverter.merge <string>
                                        (
                        new Dictionary <string, string>()
                    {
                        { "date", AlibabaCloud.TeaUtil.Common.GetDateUTCString() },
                        { "host", _endpointHost },
                        { "accept", "application/json" },
                        { "x-acs-signature-nonce", AlibabaCloud.TeaUtil.Common.GetNonce() },
                        { "x-acs-signature-method", "HMAC-SHA1" },
                        { "x-acs-signature-version", "1.0" },
                        { "x-acs-version", version },
                        { "user-agent", AlibabaCloud.TeaUtil.Common.GetUserAgent(_userAgent) },
                    },
                        headers
                                        );
                    if (!AlibabaCloud.TeaUtil.Common.IsUnset(body))
                    {
                        request_.Body = TeaCore.BytesReadable(AlibabaCloud.ROAUtil.Common.ToForm(body));
                        request_.Headers["content-type"] = "application/x-www-form-urlencoded";
                    }
                    if (!AlibabaCloud.TeaUtil.Common.IsUnset(query))
                    {
                        request_.Query = query;
                    }
                    if (!AlibabaCloud.TeaUtil.Common.EqualString(authType, "Anonymous"))
                    {
                        string accessKeyId = await this._credential.GetAccessKeyIdAsync();

                        string accessKeySecret = await this._credential.GetAccessKeySecretAsync();

                        string securityToken = await this._credential.GetSecurityTokenAsync();

                        if (!AlibabaCloud.TeaUtil.Common.Empty(securityToken))
                        {
                            request_.Headers["x-acs-accesskey-id"]   = accessKeyId;
                            request_.Headers["x-acs-security-token"] = securityToken;
                        }
                        string stringToSign = AlibabaCloud.ROAUtil.Common.GetStringToSign(request_);
                        request_.Headers["authorization"] = "acs " + accessKeyId + ":" + AlibabaCloud.ROAUtil.Common.GetSignature(stringToSign, accessKeySecret);
                    }
                    _lastRequest = request_;
                    TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);

                    if (AlibabaCloud.TeaUtil.Common.EqualNumber(response_.StatusCode, 204))
                    {
                        return(new Dictionary <string, object>
                        {
                            { "headers", response_.Headers },
                        });
                    }
                    object result = AlibabaCloud.TeaUtil.Common.ReadAsJSON(response_.Body);
                    if (AlibabaCloud.TeaUtil.Common.Is4xx(response_.StatusCode) || AlibabaCloud.TeaUtil.Common.Is5xx(response_.StatusCode))
                    {
                        Dictionary <string, object> err = AlibabaCloud.TeaUtil.Common.AssertAsMap(result);
                        throw new TeaException(new Dictionary <string, object>
                        {
                            { "code", Client.DefaultAny(err.Get("Code"), err.Get("code")) + "Error" },
                            { "message", "code: " + response_.StatusCode + ", " + Client.DefaultAny(err.Get("Message"), err.Get("message")) + " requestid: " + Client.DefaultAny(err.Get("RequestId"), err.Get("requestId")) },
                            { "data", err },
                        });
                    }
                    return(new Dictionary <string, object>
                    {
                        { "headers", response_.Headers },
                        { "body", result },
                    });
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }
示例#5
0
        public AlipayOpenAppMiniTemplatemessageSendResponse Send(string toUserId, string formId, string userTemplateId, string page, string data)
        {
            Dictionary <string, object> runtime_ = new Dictionary <string, object>
            {
                { "ignoreSSL", this._kernel.GetConfig("ignoreSSL") },
                { "httpProxy", this._kernel.GetConfig("httpProxy") },
                { "connectTimeout", 15000 },
                { "readTimeout", 15000 },
                { "retry", new Dictionary <string, int?>
                  {
                      { "maxAttempts", 0 },
                  } },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    Dictionary <string, string> systemParams = new Dictionary <string, string>
                    {
                        { "method", "alipay.open.app.mini.templatemessage.send" },
                        { "app_id", this._kernel.GetConfig("appId") },
                        { "timestamp", this._kernel.GetTimestamp() },
                        { "format", "json" },
                        { "version", "1.0" },
                        { "alipay_sdk", this._kernel.GetSdkVersion() },
                        { "charset", "UTF-8" },
                        { "sign_type", this._kernel.GetConfig("signType") },
                        { "app_cert_sn", this._kernel.GetMerchantCertSN() },
                        { "alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN() },
                    };
                    Dictionary <string, object> bizParams = new Dictionary <string, object>
                    {
                        { "to_user_id", toUserId },
                        { "form_id", formId },
                        { "user_template_id", userTemplateId },
                        { "page", page },
                        { "data", data },
                    };
                    Dictionary <string, string> textParams = new Dictionary <string, string>()
                    {
                    };
                    request_.Protocol = this._kernel.GetConfig("protocol");
                    request_.Method   = "POST";
                    request_.Pathname = "/gateway.do";
                    request_.Headers  = new Dictionary <string, string>
                    {
                        { "host", this._kernel.GetConfig("gatewayHost") },
                        { "content-type", "application/x-www-form-urlencoded;charset=utf-8" },
                    };
                    request_.Query = this._kernel.SortMap(TeaConverter.merge <string>
                                                          (
                                                              new Dictionary <string, string>()
                    {
                        { "sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey")) },
                    },
                                                              systemParams,
                                                              textParams
                                                          ));
                    request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
                    _lastRequest  = request_;
                    TeaResponse response_ = TeaCore.DoAction(request_, runtime_);

                    Dictionary <string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.open.app.mini.templatemessage.send");
                    if (this._kernel.IsCertMode())
                    {
                        if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
                        {
                            return(TeaModel.ToObject <AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap)));
                        }
                    }
                    else
                    {
                        if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
                        {
                            return(TeaModel.ToObject <AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap)));
                        }
                    }
                    throw new TeaException(new Dictionary <string, string>
                    {
                        { "message", "验签失败,请检查支付宝公钥设置是否正确。" },
                    });
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }
示例#6
0
        public async Task <AlipayTradeCreateResponse> CreateAsync(string subject, string outTradeNo, string totalAmount, string buyerId, HuabeiConfig extendParams)
        {
            extendParams.Validate();
            Dictionary <string, object> runtime_ = new Dictionary <string, object>
            {
                { "ignoreSSL", this._kernel.GetConfig("ignoreSSL") },
                { "httpProxy", this._kernel.GetConfig("httpProxy") },
                { "connectTimeout", 15000 },
                { "readTimeout", 15000 },
                { "retry", new Dictionary <string, int?>
                  {
                      { "maxAttempts", 0 },
                  } },
            };

            TeaRequest _lastRequest   = null;
            Exception  _lastException = null;
            long       _now           = System.DateTime.Now.Millisecond;
            int        _retryTimes    = 0;

            while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now))
            {
                if (_retryTimes > 0)
                {
                    int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
                    if (backoffTime > 0)
                    {
                        TeaCore.Sleep(backoffTime);
                    }
                }
                _retryTimes = _retryTimes + 1;
                try
                {
                    TeaRequest request_ = new TeaRequest();
                    Dictionary <string, string> systemParams = new Dictionary <string, string>
                    {
                        { "method", "alipay.trade.create" },
                        { "app_id", this._kernel.GetConfig("appId") },
                        { "timestamp", this._kernel.GetTimestamp() },
                        { "format", "json" },
                        { "version", "1.0" },
                        { "alipay_sdk", this._kernel.GetSdkVersion() },
                        { "charset", "UTF-8" },
                        { "sign_type", this._kernel.GetConfig("signType") },
                        { "app_cert_sn", this._kernel.GetMerchantCertSN() },
                        { "alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN() },
                    };
                    Dictionary <string, object> bizParams = new Dictionary <string, object>
                    {
                        { "subject", subject },
                        { "out_trade_no", outTradeNo },
                        { "total_amount", totalAmount },
                        { "buyer_id", buyerId },
                        { "extend_params", extendParams },
                    };
                    Dictionary <string, string> textParams = new Dictionary <string, string>()
                    {
                    };
                    request_.Protocol = this._kernel.GetConfig("protocol");
                    request_.Method   = "POST";
                    request_.Pathname = "/gateway.do";
                    request_.Headers  = new Dictionary <string, string>
                    {
                        { "host", this._kernel.GetConfig("gatewayHost") },
                        { "content-type", "application/x-www-form-urlencoded;charset=utf-8" },
                    };
                    request_.Query = this._kernel.SortMap(TeaConverter.merge <string>
                                                          (
                                                              new Dictionary <string, string>()
                    {
                        { "sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey")) },
                    },
                                                              systemParams,
                                                              textParams
                                                          ));
                    request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
                    _lastRequest  = request_;
                    TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);

                    Dictionary <string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.create");

                    if (this._kernel.IsCertMode())
                    {
                        if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
                        {
                            return(TeaModel.ToObject <AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap)));
                        }
                    }
                    else
                    {
                        if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
                        {
                            return(TeaModel.ToObject <AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap)));
                        }
                    }
                    throw new TeaException(new Dictionary <string, string>
                    {
                        { "message", "验签失败,请检查支付宝公钥设置是否正确。" },
                    });
                }
                catch (Exception e)
                {
                    if (TeaCore.IsRetryable(e))
                    {
                        _lastException = e;
                        continue;
                    }
                    throw e;
                }
            }

            throw new TeaUnretryableException(_lastRequest, _lastException);
        }