Class: Square::RefundsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/refunds_api.rb

Overview

RefundsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#get_payment_refund(refund_id:) ⇒ GetPaymentRefundResponse Hash

Retrieves a specific refund using the ‘refund_id`. desired `PaymentRefund`.

Parameters:

  • refund_id (String)

    Required parameter: The unique ID for the

Returns:

  • (GetPaymentRefundResponse Hash)

    response from the API call



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/square/api/refunds_api.rb', line 105

def get_payment_refund(refund_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/refunds/{refund_id}',
                                 'default')
               .template_param(new_parameter(refund_id, key: 'refund_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_payment_refunds(begin_time: nil, end_time: nil, sort_order: nil, cursor: nil, location_id: nil, status: nil, source_type: nil, limit: nil) ⇒ ListPaymentRefundsResponse Hash

Retrieves a list of refunds for the account making the request. Results are eventually consistent, and new refunds or changes to refunds might take several seconds to appear. The maximum results per page is 100. time range to retrieve each ‘PaymentRefund` for, in RFC 3339 format. The range is determined using the `created_at` field for each `PaymentRefund`.

Default: The current time minus one year.

range to retrieve each ‘PaymentRefund` for, in RFC 3339 format. The range is determined using the `created_at` field for each `PaymentRefund`.

Default: The current time.

are listed by ‘PaymentRefund.created_at`: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest (default). a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. For more information, see [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination). location supplied. By default, results are returned for all locations associated with the seller. the given status are returned. For a list of refund status values, see [PaymentRefund](entity:PaymentRefund). Default: If omitted, refunds are returned regardless of their status. refunds whose payments have the indicated source type. Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`. For information about these payment source types, see [Take Payments](developer.squareup.com/docs/payments-api/take-payments).

Default: If omitted, refunds are returned regardless of the source

type. to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. If the supplied value is greater than 100, no more than 100 results are returned. Default: 100

Parameters:

  • begin_time (String) (defaults to: nil)

    Optional parameter: Indicates the start of the

  • end_time (String) (defaults to: nil)

    Optional parameter: Indicates the end of the time

  • sort_order (String) (defaults to: nil)

    Optional parameter: The order in which results

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

  • location_id (String) (defaults to: nil)

    Optional parameter: Limit results to the

  • status (String) (defaults to: nil)

    Optional parameter: If provided, only refunds with

  • source_type (String) (defaults to: nil)

    Optional parameter: If provided, only returns

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

Returns:

  • (ListPaymentRefundsResponse Hash)

    response from the API call



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/square/api/refunds_api.rb', line 44

def list_payment_refunds(begin_time: nil,
                         end_time: nil,
                         sort_order: nil,
                         cursor: nil,
                         location_id: nil,
                         status: nil,
                         source_type: nil,
                         limit: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/refunds',
                                 'default')
               .query_param(new_parameter(begin_time, key: 'begin_time'))
               .query_param(new_parameter(end_time, key: 'end_time'))
               .query_param(new_parameter(sort_order, key: 'sort_order'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(location_id, key: 'location_id'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(source_type, key: 'source_type'))
               .query_param(new_parameter(limit, key: 'limit'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#refund_payment(body:) ⇒ RefundPaymentResponse Hash

Refunds a payment. You can refund the entire payment amount or a portion of it. You can use this endpoint to refund a card payment or record a refund of a cash or external payment. For more information, see [Refund Payment](developer.squareup.com/docs/payments-api/refund-payments) . containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (RefundPaymentRequest)

    Required parameter: An object

Returns:

  • (RefundPaymentResponse Hash)

    response from the API call



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/square/api/refunds_api.rb', line 84

def refund_payment(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/refunds',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end