content: /*
   * 支付宝开放平台API
   * 支付宝开放平台v3协议文档
   *
   * The version of the OpenAPI document: 2025-08-26
   * 
   *
   * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  
  
  package com.alipay.v3.api;
  
  import com.alipay.v3.ApiCallback;
  import com.alipay.v3.ApiClient;
  import com.alipay.v3.ApiException;
  import com.alipay.v3.ApiResponse;
  import com.alipay.v3.Configuration;
  import com.alipay.v3.Pair;
  import com.alipay.v3.ProgressRequestBody;
  import com.alipay.v3.ProgressResponseBody;
  import com.alipay.v3.util.AlipayLogger;
  import com.alipay.v3.util.model.CustomizedParams;
  
  import com.google.common.base.Strings;
  import com.google.gson.reflect.TypeToken;
  
  import java.io.IOException;
  
  
  import com.alipay.v3.model.AlipayTradeCancelDefaultResponse;
  import com.alipay.v3.model.AlipayTradeCancelModel;
  import com.alipay.v3.model.AlipayTradeCancelResponseModel;
  import com.alipay.v3.model.AlipayTradeCloseDefaultResponse;
  import com.alipay.v3.model.AlipayTradeCloseModel;
  import com.alipay.v3.model.AlipayTradeCloseResponseModel;
  import com.alipay.v3.model.AlipayTradeCreateDefaultResponse;
  import com.alipay.v3.model.AlipayTradeCreateModel;
  import com.alipay.v3.model.AlipayTradeCreateResponseModel;
  import com.alipay.v3.model.AlipayTradePayDefaultResponse;
  import com.alipay.v3.model.AlipayTradePayModel;
  import com.alipay.v3.model.AlipayTradePayResponseModel;
  import com.alipay.v3.model.AlipayTradePrecreateDefaultResponse;
  import com.alipay.v3.model.AlipayTradePrecreateModel;
  import com.alipay.v3.model.AlipayTradePrecreateResponseModel;
  import com.alipay.v3.model.AlipayTradeQueryDefaultResponse;
  import com.alipay.v3.model.AlipayTradeQueryModel;
  import com.alipay.v3.model.AlipayTradeQueryResponseModel;
  import com.alipay.v3.model.AlipayTradeRefundDefaultResponse;
  import com.alipay.v3.model.AlipayTradeRefundModel;
  import com.alipay.v3.model.AlipayTradeRefundResponseModel;
  
  import java.lang.reflect.Type;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import javax.ws.rs.core.GenericType;
  
  public class AlipayTradeApi {
      private ApiClient localVarApiClient;
      private int localHostIndex;
      private String localCustomBaseUrl;
  
      public AlipayTradeApi() {
          this(Configuration.getDefaultApiClient());
      }
  
      public AlipayTradeApi(ApiClient apiClient) {
          this.localVarApiClient = apiClient;
      }
  
      public ApiClient getApiClient() {
          return localVarApiClient;
      }
  
      public void setApiClient(ApiClient apiClient) {
          this.localVarApiClient = apiClient;
      }
  
      public int getHostIndex() {
          return localHostIndex;
      }
  
      public void setHostIndex(int hostIndex) {
          this.localHostIndex = hostIndex;
      }
  
      public String getCustomBaseUrl() {
          return localCustomBaseUrl;
      }
  
      public void setCustomBaseUrl(String customBaseUrl) {
          this.localCustomBaseUrl = customBaseUrl;
      }
  
      /**
       * Build call for cancel
       * @param alipayTradeCancelModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call cancelCall(AlipayTradeCancelModel alipayTradeCancelModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradeCancelModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/cancel";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call cancelValidateBeforeCall(AlipayTradeCancelModel alipayTradeCancelModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = cancelCall(alipayTradeCancelModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易撤销接口
       * 支付交易返回失败或支付系统超时，调用该接口撤销交易。如果此订单用户支付失败，支付宝系统会将此订单关闭；如果用户支付成功，支付宝系统会将此订单资金退还给用户。  注意：只有发生支付系统超时或者支付结果未知时可调用撤销，其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】，没有明确的支付结果再调用【撤销订单API】。
       * @param alipayTradeCancelModel  (optional)
       * @return AlipayTradeCancelResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradeCancelResponseModel cancel(AlipayTradeCancelModel alipayTradeCancelModel) throws ApiException {
          ApiResponse<AlipayTradeCancelResponseModel> localVarResp = cancelWithHttpInfo(alipayTradeCancelModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradeCancelResponseModel cancel(AlipayTradeCancelModel alipayTradeCancelModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradeCancelResponseModel> localVarResp = cancelWithHttpInfo(alipayTradeCancelModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易撤销接口
       * 支付交易返回失败或支付系统超时，调用该接口撤销交易。如果此订单用户支付失败，支付宝系统会将此订单关闭；如果用户支付成功，支付宝系统会将此订单资金退还给用户。  注意：只有发生支付系统超时或者支付结果未知时可调用撤销，其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】，没有明确的支付结果再调用【撤销订单API】。
       * @param alipayTradeCancelModel  (optional)
       * @return ApiResponse&lt;AlipayTradeCancelResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradeCancelResponseModel> cancelWithHttpInfo(AlipayTradeCancelModel alipayTradeCancelModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = cancelValidateBeforeCall(alipayTradeCancelModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradeCancelResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradeCancelDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易撤销接口 (asynchronously)
       * 支付交易返回失败或支付系统超时，调用该接口撤销交易。如果此订单用户支付失败，支付宝系统会将此订单关闭；如果用户支付成功，支付宝系统会将此订单资金退还给用户。  注意：只有发生支付系统超时或者支付结果未知时可调用撤销，其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】，没有明确的支付结果再调用【撤销订单API】。
       * @param alipayTradeCancelModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call cancelAsync(AlipayTradeCancelModel alipayTradeCancelModel, final ApiCallback<AlipayTradeCancelResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = cancelValidateBeforeCall(alipayTradeCancelModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradeCancelResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call cancelAsync(AlipayTradeCancelModel alipayTradeCancelModel, final ApiCallback<AlipayTradeCancelResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = cancelValidateBeforeCall(alipayTradeCancelModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradeCancelResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for close
       * @param alipayTradeCloseModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call closeCall(AlipayTradeCloseModel alipayTradeCloseModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradeCloseModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/close";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call closeValidateBeforeCall(AlipayTradeCloseModel alipayTradeCloseModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = closeCall(alipayTradeCloseModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易关闭接口
       * 用于交易创建后，用户在一定时间内未进行支付，可调用该接口直接将未付款的交易进行关闭。
       * @param alipayTradeCloseModel  (optional)
       * @return AlipayTradeCloseResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradeCloseResponseModel close(AlipayTradeCloseModel alipayTradeCloseModel) throws ApiException {
          ApiResponse<AlipayTradeCloseResponseModel> localVarResp = closeWithHttpInfo(alipayTradeCloseModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradeCloseResponseModel close(AlipayTradeCloseModel alipayTradeCloseModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradeCloseResponseModel> localVarResp = closeWithHttpInfo(alipayTradeCloseModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易关闭接口
       * 用于交易创建后，用户在一定时间内未进行支付，可调用该接口直接将未付款的交易进行关闭。
       * @param alipayTradeCloseModel  (optional)
       * @return ApiResponse&lt;AlipayTradeCloseResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradeCloseResponseModel> closeWithHttpInfo(AlipayTradeCloseModel alipayTradeCloseModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = closeValidateBeforeCall(alipayTradeCloseModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradeCloseResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradeCloseDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易关闭接口 (asynchronously)
       * 用于交易创建后，用户在一定时间内未进行支付，可调用该接口直接将未付款的交易进行关闭。
       * @param alipayTradeCloseModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call closeAsync(AlipayTradeCloseModel alipayTradeCloseModel, final ApiCallback<AlipayTradeCloseResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = closeValidateBeforeCall(alipayTradeCloseModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradeCloseResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call closeAsync(AlipayTradeCloseModel alipayTradeCloseModel, final ApiCallback<AlipayTradeCloseResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = closeValidateBeforeCall(alipayTradeCloseModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradeCloseResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for create
       * @param alipayTradeCreateModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call createCall(AlipayTradeCreateModel alipayTradeCreateModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradeCreateModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/create";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call createValidateBeforeCall(AlipayTradeCreateModel alipayTradeCreateModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = createCall(alipayTradeCreateModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易创建接口
       * 商户通过该接口进行交易的创建下单
       * @param alipayTradeCreateModel  (optional)
       * @return AlipayTradeCreateResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradeCreateResponseModel create(AlipayTradeCreateModel alipayTradeCreateModel) throws ApiException {
          ApiResponse<AlipayTradeCreateResponseModel> localVarResp = createWithHttpInfo(alipayTradeCreateModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradeCreateResponseModel create(AlipayTradeCreateModel alipayTradeCreateModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradeCreateResponseModel> localVarResp = createWithHttpInfo(alipayTradeCreateModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易创建接口
       * 商户通过该接口进行交易的创建下单
       * @param alipayTradeCreateModel  (optional)
       * @return ApiResponse&lt;AlipayTradeCreateResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradeCreateResponseModel> createWithHttpInfo(AlipayTradeCreateModel alipayTradeCreateModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = createValidateBeforeCall(alipayTradeCreateModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradeCreateResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradeCreateDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易创建接口 (asynchronously)
       * 商户通过该接口进行交易的创建下单
       * @param alipayTradeCreateModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call createAsync(AlipayTradeCreateModel alipayTradeCreateModel, final ApiCallback<AlipayTradeCreateResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = createValidateBeforeCall(alipayTradeCreateModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradeCreateResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call createAsync(AlipayTradeCreateModel alipayTradeCreateModel, final ApiCallback<AlipayTradeCreateResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = createValidateBeforeCall(alipayTradeCreateModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradeCreateResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for pay
       * @param alipayTradePayModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call payCall(AlipayTradePayModel alipayTradePayModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradePayModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/pay";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call payValidateBeforeCall(AlipayTradePayModel alipayTradePayModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = payCall(alipayTradePayModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易支付接口
       * 收银员使用扫码设备读取用户手机支付宝“付款码”获取设备（如扫码枪）读取用户手机支付宝的付款码信息后，将二维码或条码信息通过本接口上送至支付宝发起支付。
       * @param alipayTradePayModel  (optional)
       * @return AlipayTradePayResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradePayResponseModel pay(AlipayTradePayModel alipayTradePayModel) throws ApiException {
          ApiResponse<AlipayTradePayResponseModel> localVarResp = payWithHttpInfo(alipayTradePayModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradePayResponseModel pay(AlipayTradePayModel alipayTradePayModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradePayResponseModel> localVarResp = payWithHttpInfo(alipayTradePayModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易支付接口
       * 收银员使用扫码设备读取用户手机支付宝“付款码”获取设备（如扫码枪）读取用户手机支付宝的付款码信息后，将二维码或条码信息通过本接口上送至支付宝发起支付。
       * @param alipayTradePayModel  (optional)
       * @return ApiResponse&lt;AlipayTradePayResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradePayResponseModel> payWithHttpInfo(AlipayTradePayModel alipayTradePayModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = payValidateBeforeCall(alipayTradePayModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradePayResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradePayDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易支付接口 (asynchronously)
       * 收银员使用扫码设备读取用户手机支付宝“付款码”获取设备（如扫码枪）读取用户手机支付宝的付款码信息后，将二维码或条码信息通过本接口上送至支付宝发起支付。
       * @param alipayTradePayModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call payAsync(AlipayTradePayModel alipayTradePayModel, final ApiCallback<AlipayTradePayResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = payValidateBeforeCall(alipayTradePayModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradePayResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call payAsync(AlipayTradePayModel alipayTradePayModel, final ApiCallback<AlipayTradePayResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = payValidateBeforeCall(alipayTradePayModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradePayResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for precreate
       * @param alipayTradePrecreateModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call precreateCall(AlipayTradePrecreateModel alipayTradePrecreateModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradePrecreateModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/precreate";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call precreateValidateBeforeCall(AlipayTradePrecreateModel alipayTradePrecreateModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = precreateCall(alipayTradePrecreateModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单线下交易预创建
       * 收银员通过收银台或商户后台调用支付宝接口，生成二维码后，展示给用户，由用户扫描二维码完成订单支付。
       * @param alipayTradePrecreateModel  (optional)
       * @return AlipayTradePrecreateResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradePrecreateResponseModel precreate(AlipayTradePrecreateModel alipayTradePrecreateModel) throws ApiException {
          ApiResponse<AlipayTradePrecreateResponseModel> localVarResp = precreateWithHttpInfo(alipayTradePrecreateModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradePrecreateResponseModel precreate(AlipayTradePrecreateModel alipayTradePrecreateModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradePrecreateResponseModel> localVarResp = precreateWithHttpInfo(alipayTradePrecreateModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单线下交易预创建
       * 收银员通过收银台或商户后台调用支付宝接口，生成二维码后，展示给用户，由用户扫描二维码完成订单支付。
       * @param alipayTradePrecreateModel  (optional)
       * @return ApiResponse&lt;AlipayTradePrecreateResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradePrecreateResponseModel> precreateWithHttpInfo(AlipayTradePrecreateModel alipayTradePrecreateModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = precreateValidateBeforeCall(alipayTradePrecreateModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradePrecreateResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradePrecreateDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单线下交易预创建 (asynchronously)
       * 收银员通过收银台或商户后台调用支付宝接口，生成二维码后，展示给用户，由用户扫描二维码完成订单支付。
       * @param alipayTradePrecreateModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call precreateAsync(AlipayTradePrecreateModel alipayTradePrecreateModel, final ApiCallback<AlipayTradePrecreateResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = precreateValidateBeforeCall(alipayTradePrecreateModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradePrecreateResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call precreateAsync(AlipayTradePrecreateModel alipayTradePrecreateModel, final ApiCallback<AlipayTradePrecreateResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = precreateValidateBeforeCall(alipayTradePrecreateModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradePrecreateResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for query
       * @param alipayTradeQueryModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call queryCall(AlipayTradeQueryModel alipayTradeQueryModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradeQueryModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/query";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call queryValidateBeforeCall(AlipayTradeQueryModel alipayTradeQueryModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = queryCall(alipayTradeQueryModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易查询
       * 该接口提供所有支付宝支付订单的查询，商户可以通过该接口主动查询订单状态，完成下一步的业务逻辑。  需要调用查询接口的情况：  当商户后台、网络、服务器等出现异常，商户系统最终未接收到支付通知；  调用支付接口后，返回系统错误或未知交易状态情况；  调用alipay.trade.pay，返回INPROCESS的状态；  调用alipay.trade.cancel之前，需确认支付状态；
       * @param alipayTradeQueryModel  (optional)
       * @return AlipayTradeQueryResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradeQueryResponseModel query(AlipayTradeQueryModel alipayTradeQueryModel) throws ApiException {
          ApiResponse<AlipayTradeQueryResponseModel> localVarResp = queryWithHttpInfo(alipayTradeQueryModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradeQueryResponseModel query(AlipayTradeQueryModel alipayTradeQueryModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradeQueryResponseModel> localVarResp = queryWithHttpInfo(alipayTradeQueryModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易查询
       * 该接口提供所有支付宝支付订单的查询，商户可以通过该接口主动查询订单状态，完成下一步的业务逻辑。  需要调用查询接口的情况：  当商户后台、网络、服务器等出现异常，商户系统最终未接收到支付通知；  调用支付接口后，返回系统错误或未知交易状态情况；  调用alipay.trade.pay，返回INPROCESS的状态；  调用alipay.trade.cancel之前，需确认支付状态；
       * @param alipayTradeQueryModel  (optional)
       * @return ApiResponse&lt;AlipayTradeQueryResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradeQueryResponseModel> queryWithHttpInfo(AlipayTradeQueryModel alipayTradeQueryModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = queryValidateBeforeCall(alipayTradeQueryModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradeQueryResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradeQueryDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易查询 (asynchronously)
       * 该接口提供所有支付宝支付订单的查询，商户可以通过该接口主动查询订单状态，完成下一步的业务逻辑。  需要调用查询接口的情况：  当商户后台、网络、服务器等出现异常，商户系统最终未接收到支付通知；  调用支付接口后，返回系统错误或未知交易状态情况；  调用alipay.trade.pay，返回INPROCESS的状态；  调用alipay.trade.cancel之前，需确认支付状态；
       * @param alipayTradeQueryModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call queryAsync(AlipayTradeQueryModel alipayTradeQueryModel, final ApiCallback<AlipayTradeQueryResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = queryValidateBeforeCall(alipayTradeQueryModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradeQueryResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call queryAsync(AlipayTradeQueryModel alipayTradeQueryModel, final ApiCallback<AlipayTradeQueryResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = queryValidateBeforeCall(alipayTradeQueryModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradeQueryResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
      /**
       * Build call for refund
       * @param alipayTradeRefundModel  (optional)
       * @param _callback Callback for upload/download progress
       * @param customizedParams
       * @return Call to execute
       * @throws ApiException If fail to serialize the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public okhttp3.Call refundCall(AlipayTradeRefundModel alipayTradeRefundModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          String basePath = null;
          // Operation Servers
          String[] localBasePaths = new String[] {  };
  
          // Determine Base Path to Use
          if (localCustomBaseUrl != null){
              basePath = localCustomBaseUrl;
          } else if ( localBasePaths.length > 0 ) {
              basePath = localBasePaths[localHostIndex];
          } else {
              basePath = null;
          }
  
          Object localVarPostBody = (customizedParams != null && !Strings.isNullOrEmpty(customizedParams.getBodyContent()))
                  ? customizedParams.getBodyContent() : alipayTradeRefundModel;
  
          // create path and map variables
          String localVarPath = "/v3/alipay/trade/refund";
  
          List<Pair> localVarQueryParams = new ArrayList<Pair>();
          List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
          Map<String, String> localVarHeaderParams = new HashMap<String, String>();
          Map<String, String> localVarCookieParams = new HashMap<String, String>();
          Map<String, Object> localVarFormParams = new HashMap<String, Object>();
  
          final String[] localVarAccepts = {
              "application/json"
          };
          final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
          if (localVarAccept != null) {
              localVarHeaderParams.put("Accept", localVarAccept);
          }
  
          final String[] localVarContentTypes = {
              "application/json"
          };
          final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
          if (localVarContentType != null) {
              localVarHeaderParams.put("Content-Type", localVarContentType);
          }
  
          if (customizedParams != null) {
              //额外query参数
              if (customizedParams.getQueryParams() != null && customizedParams.getQueryParams().size() > 0) {
                  for (Map.Entry<String, String> entry : customizedParams.getQueryParams().entrySet()) {
                      localVarQueryParams.addAll(localVarApiClient.parameterToPair(entry.getKey(), entry.getValue()));
                  }
              }
  
              if (!Strings.isNullOrEmpty(customizedParams.getAppAuthToken())) {
                  localVarHeaderParams.put("alipay-app-auth-token", customizedParams.getAppAuthToken());
              }
  
              //额外非全局header参数
              if (customizedParams.getHeaderParams() != null && customizedParams.getHeaderParams().size() > 0) {
                  localVarHeaderParams.putAll(customizedParams.getHeaderParams());
              }
          }
  
          String[] localVarAuthNames = new String[] {  };
          return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
      }
  
      @SuppressWarnings("rawtypes")
      private okhttp3.Call refundValidateBeforeCall(AlipayTradeRefundModel alipayTradeRefundModel, final ApiCallback _callback, CustomizedParams customizedParams) throws ApiException {
          
  
          okhttp3.Call localVarCall = refundCall(alipayTradeRefundModel, _callback, customizedParams);
          return localVarCall;
  
      }
  
      /**
       * 统一收单交易退款接口
       * 当交易发生之后一段时间内，由于买家或者卖家的原因需要退款时，卖家可以通过退款接口将支付款退还给买家，支付宝将在收到退款请求并且验证成功之后，按照退款规则将支付款按原路退到买家帐号上。 交易超过约定时间（签约时设置的可退款时间）的订单无法进行退款。  支付宝退款支持单笔交易分多次退款，多次退款需要提交原支付订单的订单号和设置不同的退款请求号。一笔退款失败后重新提交，要保证重试时退款请求号不能变更，防止该笔交易重复退款。  同一笔交易累计提交的退款金额不能超过原始交易总金额。
       * @param alipayTradeRefundModel  (optional)
       * @return AlipayTradeRefundResponseModel
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public AlipayTradeRefundResponseModel refund(AlipayTradeRefundModel alipayTradeRefundModel) throws ApiException {
          ApiResponse<AlipayTradeRefundResponseModel> localVarResp = refundWithHttpInfo(alipayTradeRefundModel, null);
          return localVarResp.getData();
      }
  
      public AlipayTradeRefundResponseModel refund(AlipayTradeRefundModel alipayTradeRefundModel, CustomizedParams customizedParams) throws ApiException {
          ApiResponse<AlipayTradeRefundResponseModel> localVarResp = refundWithHttpInfo(alipayTradeRefundModel, customizedParams);
          return localVarResp.getData();
      }
  
      /**
       * 统一收单交易退款接口
       * 当交易发生之后一段时间内，由于买家或者卖家的原因需要退款时，卖家可以通过退款接口将支付款退还给买家，支付宝将在收到退款请求并且验证成功之后，按照退款规则将支付款按原路退到买家帐号上。 交易超过约定时间（签约时设置的可退款时间）的订单无法进行退款。  支付宝退款支持单笔交易分多次退款，多次退款需要提交原支付订单的订单号和设置不同的退款请求号。一笔退款失败后重新提交，要保证重试时退款请求号不能变更，防止该笔交易重复退款。  同一笔交易累计提交的退款金额不能超过原始交易总金额。
       * @param alipayTradeRefundModel  (optional)
       * @return ApiResponse&lt;AlipayTradeRefundResponseModel&gt;
       * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       */
      public ApiResponse<AlipayTradeRefundResponseModel> refundWithHttpInfo(AlipayTradeRefundModel alipayTradeRefundModel, CustomizedParams customizedParams) throws ApiException {
          okhttp3.Call localVarCall = refundValidateBeforeCall(alipayTradeRefundModel, null, customizedParams);
          try {
              Type localVarReturnType = new TypeToken<AlipayTradeRefundResponseModel>(){}.getType();
              return localVarApiClient.execute(localVarCall, localVarReturnType);
          } catch (ApiException e) {
              try {
                  e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<AlipayTradeRefundDefaultResponse>(){}.getType()));
              } catch (Exception ex) {
                  AlipayLogger.logBizWarn(ex);
              }
              throw e;
          }
      }
  
      /**
       * 统一收单交易退款接口 (asynchronously)
       * 当交易发生之后一段时间内，由于买家或者卖家的原因需要退款时，卖家可以通过退款接口将支付款退还给买家，支付宝将在收到退款请求并且验证成功之后，按照退款规则将支付款按原路退到买家帐号上。 交易超过约定时间（签约时设置的可退款时间）的订单无法进行退款。  支付宝退款支持单笔交易分多次退款，多次退款需要提交原支付订单的订单号和设置不同的退款请求号。一笔退款失败后重新提交，要保证重试时退款请求号不能变更，防止该笔交易重复退款。  同一笔交易累计提交的退款金额不能超过原始交易总金额。
       * @param alipayTradeRefundModel  (optional)
       * @param _callback The callback to be executed when the API call finishes
       * @return The request call
       * @throws ApiException If fail to process the API call, e.g. serializing the request body object
       * @http.response.details
       <table summary="Response Details" border="1">
          <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
          <tr><td> 200 </td><td> common response </td><td>  -  </td></tr>
          <tr><td> 0 </td><td> 请求失败 </td><td>  -  </td></tr>
       </table>
       * @deprecated
       */
      @Deprecated
      public okhttp3.Call refundAsync(AlipayTradeRefundModel alipayTradeRefundModel, final ApiCallback<AlipayTradeRefundResponseModel> _callback) throws ApiException {
  
          okhttp3.Call localVarCall = refundValidateBeforeCall(alipayTradeRefundModel, _callback, null);
          Type localVarReturnType = new TypeToken<AlipayTradeRefundResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  
      @Deprecated
      public okhttp3.Call refundAsync(AlipayTradeRefundModel alipayTradeRefundModel, final ApiCallback<AlipayTradeRefundResponseModel> _callback, CustomizedParams customizedParams) throws ApiException {
  
          okhttp3.Call localVarCall = refundValidateBeforeCall(alipayTradeRefundModel, _callback, customizedParams);
          Type localVarReturnType = new TypeToken<AlipayTradeRefundResponseModel>(){}.getType();
          localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
          return localVarCall;
      }
  }
  