src/main/java/com/squareup/connect/api/PaymentsApi.java
public CompleteResponse<CancelPaymentByIdempotencyKeyResponse>cancelPaymentByIdempotencyKeyWithHttpInfo(CancelPaymentByIdempotencyKeyRequest body) throws ApiException {
    Object localVarPostBody = body;
    
    // verify the required parameter 'body' is set
    if (body == null) {
      throw new ApiException(400, "Missing the required parameter 'body' when calling cancelPaymentByIdempotencyKey");
    }
    
    // create path and map variables
    String localVarPath = "/v2/payments/cancel";

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();
    localVarHeaderParams.put("Square-Version", "2019-11-20");

    
    
    final String[] localVarAccepts = {
      "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
      "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[] { "oauth2" };

    GenericType<CancelPaymentByIdempotencyKeyResponse> localVarReturnType = new GenericType<CancelPaymentByIdempotencyKeyResponse>() {};
    return (CompleteResponse<CancelPaymentByIdempotencyKeyResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  }
/**
   * CancelPaymentByIdempotencyKey
   * Cancels (voids) a payment identified by the idempotency key that is specified in the request.   Use this method when status of a CreatePayment request is unknown.  For example, after you send a CreatePayment  request a network error occurs and you don&#39;t get a response. In this case, you can direct  Square to cancel the payment using this endpoint. In the request, you provide the same idempotency  key that you provided in your CreatePayment request you want  to cancel. After cancelling the  payment, you can submit your CreatePayment request again.  Note that if no payment with the specified idempotency key is found, no action is taken, the end  point returns successfully.
   * @param body An object containing the fields to POST for the request.  See the corresponding object definition for field details. (required)
   * @return CompleteResponse<CancelPaymentByIdempotencyKeyResponse>
   * @throws ApiException if fails to make API call
   */
CancelPaymentByIdempotencyKey
Cancels (voids) a payment identified by the idempotency key that is specified in the request.   Use this method when status of a CreatePayment request is unknown.  For example, after you send a CreatePayment  request a network error occurs and you don't get a response. In this case, you can direct  Square to cancel the payment using this endpoint. In the request, you provide the same idempotency  key that you provided in your CreatePayment request you want  to cancel. After cancelling the  payment, you can submit your CreatePayment request again.  Note that if no payment with the specified idempotency key is found, no action is taken, the end  point returns successfully.
@param body An object containing the fields to POST for the request.  See the corresponding object definition for field details. (required)
@return CompleteResponse
@throws ApiException if fails to make API call
CancelPaymentByIdempotencyKey Cancels ( voids ) a payment identified by the idempotency key that is specified in the request . Use this method when status of a CreatePayment request is unknown . For example after you send a CreatePayment request a network error occurs and you don ' t get a response . In this case you can direct Square to cancel the payment using this endpoint . In the request you provide the same idempotency key that you provided in your CreatePayment request you want to cancel . After cancelling the payment you can submit your CreatePayment request again . Note that if no payment with the specified idempotency key is found no action is taken the end point returns successfully . @param body An object containing the fields to POST for the request . See the corresponding object definition for field details . ( required ) @return CompleteResponse @throws ApiException if fails to make API call
public CompleteResponse<CancelPaymentByIdempotencyKeyResponse>cancelPaymentByIdempotencyKeyWithHttpInfo(CancelPaymentByIdempotencyKeyRequest body) throws ApiException {
    Object localVarPostBody = body;
    if (body == null) {
      throw new ApiException(400, "Missing the required parameter 'body' when calling cancelPaymentByIdempotencyKey");
    }
    String localVarPath = "/v2/payments/cancel";
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();
    localVarHeaderParams.put("Square-Version", "2019-11-20");
    final String[] localVarAccepts = {
      "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    final String[] localVarContentTypes = {
      "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    String[] localVarAuthNames = new String[] { "oauth2" };
    GenericType<CancelPaymentByIdempotencyKeyResponse> localVarReturnType = new GenericType<CancelPaymentByIdempotencyKeyResponse>() {};
    return (CompleteResponse<CancelPaymentByIdempotencyKeyResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  }
public CompleteResponse < CancelPaymentByIdempotencyKeyResponse > cancelPaymentByIdempotencyKeyWithHttpInfo ( CancelPaymentByIdempotencyKeyRequest body ) throws ApiException { Object localVarPostBody = body ; if ( body == null ) { throw new ApiException ( 400 , "Missing the required parameter 'body' when calling cancelPaymentByIdempotencyKey" ) ; } String localVarPath = "/v2/payments/cancel" ; List < Pair > localVarQueryParams = new ArrayList < Pair > ( ) ; Map < String , String > localVarHeaderParams = new HashMap < String , String > ( ) ; Map < String , Object > localVarFormParams = new HashMap < String , Object > ( ) ; localVarHeaderParams . put ( "Square-Version" , "2019-11-20" ) ; final String [ ] localVarAccepts = { "application/json" } ; final String localVarAccept = apiClient . selectHeaderAccept ( localVarAccepts ) ; final String [ ] localVarContentTypes = { "application/json" } ; final String localVarContentType = apiClient . selectHeaderContentType ( localVarContentTypes ) ; String [ ] localVarAuthNames = new String [ ] { "oauth2" } ; GenericType < CancelPaymentByIdempotencyKeyResponse > localVarReturnType = new GenericType < CancelPaymentByIdempotencyKeyResponse > ( ) { } ; return ( CompleteResponse < CancelPaymentByIdempotencyKeyResponse > ) apiClient . invokeAPI ( localVarPath , "POST" , localVarQueryParams , localVarPostBody , localVarHeaderParams , localVarFormParams , localVarAccept , localVarContentType , localVarAuthNames , localVarReturnType ) ; }
CancelPaymentByIdempotencyKey
 Cancels (voids) a payment identified by the idempotency key that is specified in the request.
CancelPaymentByIdempotencyKey Cancels ( voids ) a payment identified by the idempotency key that is specified in the request .
// verify the required parameter 'body' is set // create path and map variables // query params