Class: Square::Refunds::Client
- Inherits:
-
Object
- Object
- Square::Refunds::Client
- Defined in:
- lib/square/refunds/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Square::Types::GetPaymentRefundResponse
Retrieves a specific refund using the ‘refund_id`.
- #initialize(client:) ⇒ Square::Refunds::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListPaymentRefundsResponse
Retrieves a list of refunds for the account making the request.
-
#refund_payment(request_options: {}, **params) ⇒ Square::Types::RefundPaymentResponse
Refunds a payment.
Constructor Details
#initialize(client:) ⇒ Square::Refunds::Client
7 8 9 |
# File 'lib/square/refunds/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Square::Types::GetPaymentRefundResponse
Retrieves a specific refund using the ‘refund_id`.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/square/refunds/client.rb', line 63 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/refunds/#{params[:refund_id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetPaymentRefundResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListPaymentRefundsResponse
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/square/refunds/client.rb', line 19 def list(request_options: {}, **params) _query_param_names = %w[begin_time end_time sort_order cursor location_id status source_type limit updated_at_begin_time updated_at_end_time sort_field] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/refunds", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListPaymentRefundsResponse.load(_response.body) end raise _response.body end |
#refund_payment(request_options: {}, **params) ⇒ Square::Types::RefundPaymentResponse
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).
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/square/refunds/client.rb', line 45 def refund_payment(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/refunds", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::RefundPaymentResponse.load(_response.body) end raise _response.body end |