Class: Tikkie::Api::Resources::Payment

Inherits:
Base
  • Object
show all
Defined in:
lib/tikkie/api/resources/payment.rb

Overview

Resource for a Payment.

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #options

Instance Method Summary collapse

Methods inherited from Base

#delete, #load, #loaded?, #save

Constructor Details

#initialize(config, options = {}) ⇒ Payment

Returns a new instance of Payment.



12
13
14
15
16
# File 'lib/tikkie/api/resources/payment.rb', line 12

def initialize(config, options = {})
  @payment_request_token = options.delete(:payment_request_token)
  @payment_token = options.delete(:payment_token)
  super(config, options)
end

Instance Attribute Details

#payment_request_tokenObject (readonly)

Returns the value of attribute payment_request_token.



10
11
12
# File 'lib/tikkie/api/resources/payment.rb', line 10

def payment_request_token
  @payment_request_token
end

Instance Method Details

#amountObject



34
35
36
# File 'lib/tikkie/api/resources/payment.rb', line 34

def amount
  Tikkie::Api::Amount.from_cents(body[:amountInCents]).to_d
end

#counter_party_account_numberObject



30
31
32
# File 'lib/tikkie/api/resources/payment.rb', line 30

def 
  body[:counterPartyAccountNumber]
end

#counter_party_nameObject



26
27
28
# File 'lib/tikkie/api/resources/payment.rb', line 26

def counter_party_name
  body[:counterPartyName]
end

#created_atObject



42
43
44
# File 'lib/tikkie/api/resources/payment.rb', line 42

def created_at
  Time.parse(body[:createdDateTime]) if body[:createdDateTime]
end

#descriptionObject



38
39
40
# File 'lib/tikkie/api/resources/payment.rb', line 38

def description
  body[:description]
end

#payment_tokenObject



18
19
20
# File 'lib/tikkie/api/resources/payment.rb', line 18

def payment_token
  @payment_token || body[:paymentToken]
end

#refundsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/tikkie/api/resources/payment.rb', line 46

def refunds
  @refunds ||= begin
    refunds = []

    if body[:refunds]
      body[:refunds].each do |refund|
        refunds << Tikkie::Api::Resources::Refund.new(config, body: refund)
      end
    end

    refunds
  end
end

#tikkie_idObject



22
23
24
# File 'lib/tikkie/api/resources/payment.rb', line 22

def tikkie_id
  body[:tikkieId]
end