Class: Cardgate::Refund

Inherits:
Object
  • Object
show all
Defined in:
lib/cardgate/refund.rb

Direct Known Subclasses

Creditcard::Refund, Ideal::Refund

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Refund

Returns a new instance of Refund.



7
8
9
10
11
# File 'lib/cardgate/refund.rb', line 7

def initialize(attributes = {})
  attributes.each do |k,v|
    send("#{k}=", v)
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/cardgate/refund.rb', line 5

def amount
  @amount
end

#reasonObject

Returns the value of attribute reason.



5
6
7
# File 'lib/cardgate/refund.rb', line 5

def reason
  @reason
end

#referenced_transaction_idObject

Returns the value of attribute referenced_transaction_id.



5
6
7
# File 'lib/cardgate/refund.rb', line 5

def referenced_transaction_id
  @referenced_transaction_id
end

#site_idObject

Returns the value of attribute site_id.



5
6
7
# File 'lib/cardgate/refund.rb', line 5

def site_id
  @site_id
end

Instance Method Details

#api_refund_endpointObject



42
43
44
# File 'lib/cardgate/refund.rb', line 42

def api_refund_endpoint
  "/rest/v1/#{provider}/refund/"
end

#default_paramsObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/cardgate/refund.rb', line 13

def default_params
  {
    refund: {
      site_id: @site_id,
      referenced_transaction_id: @referenced_transaction_id,
      amount: @amount,
      reason: @reason
    }
  }
end

#initiateObject



32
33
34
35
36
# File 'lib/cardgate/refund.rb', line 32

def initiate
  @response ||= response

  self
end

#paramsObject



24
25
26
# File 'lib/cardgate/refund.rb', line 24

def params
  default_params.deep_merge!(refund_params)
end

#refund_paramsObject



28
29
30
# File 'lib/cardgate/refund.rb', line 28

def refund_params
  {}
end

#transaction_idObject



38
39
40
# File 'lib/cardgate/refund.rb', line 38

def transaction_id
  @response.body['refund']['transaction_id']
end