Class: Tikkie::Api::Resources::PaymentRequest
- Inherits:
-
Base
- Object
- Base
- Tikkie::Api::Resources::PaymentRequest
show all
- Defined in:
- lib/tikkie/api/resources/payment_request.rb
Overview
Resource for a Payment Request.
Constant Summary
collapse
- STATUS_OPEN =
"OPEN"
- STATUS_CLOSED =
"CLOSED"
- STATUS_EXPIRED =
"EXPIRED"
- STATUS_MAX_YIELDED_REACHED =
"MAX_YIELD_REACHED"
- STATUS_MAX_SUCCESSFUL_PAYMENTS_REACHED =
"MAX_SUCCESSFUL_PAYMENTS_REACHED"
Instance Attribute Summary
Attributes inherited from Base
#config, #options
Instance Method Summary
collapse
Methods inherited from Base
#delete, #load, #loaded?, #save
Constructor Details
#initialize(config, options = {}) ⇒ PaymentRequest
Returns a new instance of PaymentRequest.
16
17
18
19
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 16
def initialize(config, options = {})
@payment_request_token = options.delete(:payment_request_token)
super(config, options)
end
|
Instance Method Details
#amount ⇒ Object
29
30
31
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 29
def amount
Tikkie::Api::Amount.from_cents(body[:amountInCents]).to_d
end
|
#closed? ⇒ Boolean
57
58
59
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 57
def closed?
status == STATUS_CLOSED
end
|
#created_at ⇒ Object
41
42
43
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 41
def created_at
Time.parse(body[:createdDateTime]) if body[:createdDateTime]
end
|
#description ⇒ Object
33
34
35
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 33
def description
body[:description]
end
|
#expired? ⇒ Boolean
61
62
63
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 61
def expired?
status == STATUS_EXPIRED
end
|
#expiry_date ⇒ Object
45
46
47
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 45
def expiry_date
Date.parse(body[:expiryDate]) if body[:expiryDate]
end
|
#number_of_payments ⇒ Object
65
66
67
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 65
def number_of_payments
body[:numberOfPayments]
end
|
#open? ⇒ Boolean
53
54
55
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 53
def open?
status == STATUS_OPEN
end
|
#payment_request_token ⇒ Object
21
22
23
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 21
def payment_request_token
@payment_request_token || body[:paymentRequestToken]
end
|
#payments ⇒ Object
73
74
75
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 73
def payments
@payments ||= Tikkie::Api::Resources::Payments.new(config, payment_request_token: payment_request_token)
end
|
#reference_id ⇒ Object
37
38
39
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 37
def reference_id
body[:referenceId]
end
|
#status ⇒ Object
49
50
51
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 49
def status
body[:status]
end
|
#total_amount_paid ⇒ Object
69
70
71
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 69
def total_amount_paid
Tikkie::Api::Amount.from_cents(body[:totalAmountPaidInCents]).to_d
end
|
#url ⇒ Object
25
26
27
|
# File 'lib/tikkie/api/resources/payment_request.rb', line 25
def url
body[:url]
end
|