-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.rb
101 lines (78 loc) · 1.88 KB
/
payment.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# frozen_string_literal: true
require 'bigdecimal'
module Kentaa
module Api
module Resources
class Payment < Resource
def object_key
"Payment_#{id}"
end
def site
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end
def site_id
data[:site_id]
end
def currency
data[:currency]
end
def amount
BigDecimal(data[:amount])
end
def invoicenumber
data[:invoicenumber]
end
def payment_method
data[:payment_method]
end
def payment_status
data[:payment_status]
end
def transaction_id
data[:transaction_id]
end
def payment_id
data[:payment_id]
end
def account_iban
data[:account_iban]
end
def account_bic
data[:account_bic]
end
def account_name
data[:account_name]
end
def description
data[:description]
end
def donations
@donations ||= begin
donations = []
if data[:donations]
data[:donations].each do |donation|
donations << Kentaa::Api::Resources::Donation.new(config, data: donation, options: options)
end
end
donations
end
end
def orders
@orders ||= begin
orders = []
if data[:orders]
data[:orders].each do |order|
orders << Kentaa::Api::Resources::Order.new(config, data: order, options: options)
end
end
orders
end
end
private
def load_resource
request.get("/payments/#{id}", options)
end
end
end
end
end