src/main/java/com/squareup/connect/api/OrdersApi.java
public CompleteResponse<PayOrderResponse>payOrderWithHttpInfo(String orderId, PayOrderRequest body) throws ApiException {
    Object localVarPostBody = body;
    
    // verify the required parameter 'orderId' is set
    if (orderId == null) {
      throw new ApiException(400, "Missing the required parameter 'orderId' when calling payOrder");
    }
    
    // verify the required parameter 'body' is set
    if (body == null) {
      throw new ApiException(400, "Missing the required parameter 'body' when calling payOrder");
    }
    
    // create path and map variables
    String localVarPath = "/v2/orders/{order_id}/pay"
      .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));

    // 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<PayOrderResponse> localVarReturnType = new GenericType<PayOrderResponse>() {};
    return (CompleteResponse<PayOrderResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  }
/**
   * PayOrder
   * Pay for an [order](#type-order) using one or more approved [payments](#type-payment), or settle an order with a total of &#x60;0&#x60;.  The total of the &#x60;payment_ids&#x60; listed in the request must be equal to the order total. Orders with a total amount of &#x60;0&#x60; can be marked as paid by specifying an empty array of &#x60;payment_ids&#x60; in the request.  To be used with PayOrder, a payment must:  - Reference the order by specifying the &#x60;order_id&#x60; when [creating the payment](#endpoint-payments-createpayment). Any approved payments that reference the same &#x60;order_id&#x60; not specified in the &#x60;payment_ids&#x60; will be canceled. - Be approved with [delayed capture](/payments-api/take-payments#delayed-capture). Using a delayed capture payment with PayOrder will complete the approved payment.  Learn how to [pay for orders with a single payment using the Payments API](/orders-api/pay-for-orders).
   * @param orderId The ID of the order being paid. (required)
   * @param body An object containing the fields to POST for the request.  See the corresponding object definition for field details. (required)
   * @return CompleteResponse<PayOrderResponse>
   * @throws ApiException if fails to make API call
   */
PayOrder
Pay for an [order](#type-order) using one or more approved [payments](#type-payment), or settle an order with a total of `0`.  The total of the `payment_ids` listed in the request must be equal to the order total. Orders with a total amount of `0` can be marked as paid by specifying an empty array of `payment_ids` in the request.  To be used with PayOrder, a payment must:  - Reference the order by specifying the `order_id` when [creating the payment](#endpoint-payments-createpayment). Any approved payments that reference the same `order_id` not specified in the `payment_ids` will be canceled. - Be approved with [delayed capture](/payments-api/take-payments#delayed-capture). Using a delayed capture payment with PayOrder will complete the approved payment.  Learn how to [pay for orders with a single payment using the Payments API](/orders-api/pay-for-orders).
@param orderId The ID of the order being paid. (required)
@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
PayOrder Pay for an [ order ] ( #type - order ) using one or more approved [ payments ] ( #type - payment ) or settle an order with a total of ` 0 ` . The total of the ` payment_ids ` listed in the request must be equal to the order total . Orders with a total amount of ` 0 ` can be marked as paid by specifying an empty array of ` payment_ids ` in the request . To be used with PayOrder a payment must : - Reference the order by specifying the ` order_id ` when [ creating the payment ] ( #endpoint - payments - createpayment ) . Any approved payments that reference the same ` order_id ` not specified in the ` payment_ids ` will be canceled . - Be approved with [ delayed capture ] ( / payments - api / take - payments#delayed - capture ) . Using a delayed capture payment with PayOrder will complete the approved payment . Learn how to [ pay for orders with a single payment using the Payments API ] ( / orders - api / pay - for - orders ) . @param orderId The ID of the order being paid . ( required ) @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<PayOrderResponse>payOrderWithHttpInfo(String orderId, PayOrderRequest body) throws ApiException {
    Object localVarPostBody = body;
    if (orderId == null) {
      throw new ApiException(400, "Missing the required parameter 'orderId' when calling payOrder");
    }
    if (body == null) {
      throw new ApiException(400, "Missing the required parameter 'body' when calling payOrder");
    }
    String localVarPath = "/v2/orders/{order_id}/pay"
      .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
    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<PayOrderResponse> localVarReturnType = new GenericType<PayOrderResponse>() {};
    return (CompleteResponse<PayOrderResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  }
public CompleteResponse < PayOrderResponse > payOrderWithHttpInfo ( String orderId , PayOrderRequest body ) throws ApiException { Object localVarPostBody = body ; if ( orderId == null ) { throw new ApiException ( 400 , "Missing the required parameter 'orderId' when calling payOrder" ) ; } if ( body == null ) { throw new ApiException ( 400 , "Missing the required parameter 'body' when calling payOrder" ) ; } String localVarPath = "/v2/orders/{order_id}/pay" . replaceAll ( "\\{" + "order_id" + "\\}" , apiClient . escapeString ( orderId . toString ( ) ) ) ; 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 < PayOrderResponse > localVarReturnType = new GenericType < PayOrderResponse > ( ) { } ; return ( CompleteResponse < PayOrderResponse > ) apiClient . invokeAPI ( localVarPath , "POST" , localVarQueryParams , localVarPostBody , localVarHeaderParams , localVarFormParams , localVarAccept , localVarContentType , localVarAuthNames , localVarReturnType ) ; }
PayOrder
 Pay for an [order](#type-order) using one or more approved [payments](#type-payment), or settle an order with a total of &#x60;0&#x60;.
PayOrder Pay for an [ order ] ( #type - order ) using one or more approved [ payments ] ( #type - payment ) or settle an order with a total of &#x60 ; 0&#x60 ; .
// verify the required parameter 'orderId' is set // verify the required parameter 'body' is set // create path and map variables // query params