Class: Square::Terminal::Refunds::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/square/terminal/refunds/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::Terminal::Refunds::Client



8
9
10
# File 'lib/square/terminal/refunds/client.rb', line 8

def initialize(client:)
  @client = client
end

Instance Method Details

#cancel(request_options: {}, **params) ⇒ Square::Types::CancelTerminalRefundResponse

Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it.



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/square/terminal/refunds/client.rb', line 68

def cancel(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/refunds/#{params[:terminal_refund_id]}/cancel"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CancelTerminalRefundResponse.load(_response.body)
  end

  raise _response.body
end

#create(request_options: {}, **params) ⇒ Square::Types::CreateTerminalRefundResponse

Creates a request to refund an Interac payment completed on a Square Terminal. Refunds for Interac payments on a Square Terminal are supported only for Interac debit cards in Canada. Other refunds for Terminal payments should use the Refunds API. For more information, see [Refunds API](api:Refunds).



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/square/terminal/refunds/client.rb', line 15

def create(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/refunds",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CreateTerminalRefundResponse.load(_response.body)
  end

  raise _response.body
end

#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalRefundResponse

Retrieves an Interac Terminal refund object by ID. Terminal refund objects are available for 30 days.



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/square/terminal/refunds/client.rb', line 51

def get(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/terminals/refunds/#{params[:terminal_refund_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetTerminalRefundResponse.load(_response.body)
  end

  raise _response.body
end

#search(request_options: {}, **params) ⇒ Square::Types::SearchTerminalRefundsResponse

Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/square/terminal/refunds/client.rb', line 33

def search(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/refunds/search",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::SearchTerminalRefundsResponse.load(_response.body)
  end

  raise _response.body
end