lib/square/api/payments_api.rb
# Completes (captures) a payment.
# By default, payments are set to complete immediately after they are
# created.
# You can use this endpoint to complete a payment with the APPROVED
# `status`.
# @param [String] payment_id Required parameter: The unique ID identifying
# the payment to be completed.
# @param [CompletePaymentRequest] body Required parameter: An object
# containing the fields to POST for the request.  See the corresponding
# object definition for field details.
# @return [CompletePaymentResponse Hash] response from the API call
Completes (captures) a payment.
By default, payments are set to complete immediately after they are
created.
You can use this endpoint to complete a payment with the APPROVED
`status`.
Completes ( captures ) a payment . By default payments are set to complete immediately after they are created . You can use this endpoint to complete a payment with the APPROVED ` status ` .
def complete_payment(payment_id:,
                         body:)
      _query_builder = config.get_base_uri
      _query_builder << '/v2/payments/{payment_id}/complete'
      _query_builder = APIHelper.append_url_with_template_parameters(
        _query_builder,
        'payment_id' => { 'value' => payment_id, 'encode' => true }
      )
      _query_url = APIHelper.clean_url _query_builder
      _headers = {
        'accept' => 'application/json',
        'content-type' => 'application/json; charset=utf-8'
      }
      _request = config.http_client.post(
        _query_url,
        headers: _headers,
        parameters: body.to_json
      )
      OAuth2.apply(config, _request)
      _response = execute_request(_request)
      decoded = APIHelper.json_deserialize(_response.raw_body)
      _errors = APIHelper.map_response(decoded, ['errors'])
      ApiResponse.new(
        _response, data: decoded, errors: _errors
      )
    end
def complete_payment ( payment_id : , body : ) _query_builder = config . get_base_uri _query_builder << '/v2/payments/{payment_id}/complete' _query_builder = APIHelper . append_url_with_template_parameters ( _query_builder , 'payment_id' => { 'value' => payment_id , 'encode' => true } ) _query_url = APIHelper . clean_url _query_builder _headers = { 'accept' => 'application/json' , 'content-type' => 'application/json; charset=utf-8' } _request = config . http_client . post ( _query_url , headers : _headers , parameters : body . to_json ) OAuth2 . apply ( config , _request ) _response = execute_request ( _request ) decoded = APIHelper . json_deserialize ( _response . raw_body ) _errors = APIHelper . map_response ( decoded , [ 'errors' ] ) ApiResponse . new ( _response , data : decoded , errors : _errors ) end
Completes (captures) a payment.
Completes ( captures ) a payment .
# Prepare query url. # Prepare headers. # Prepare and execute HttpRequest. # Return appropriate response type.
response from the API call
response from the API call
CompletePaymentResponse Hash
payment_id
<not_specific>
body
<not_specific>
<not_specific>
body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
body Required parameter : An object containing the fields to POST for the request . See the corresponding object definition for field details .