processout 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +52 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Dockerfile +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Makefile +4 -0
- data/README.md +12 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/processout/activity.rb +206 -0
- data/lib/processout/addon.rb +401 -0
- data/lib/processout/alternative_merchant_certificate.rb +115 -0
- data/lib/processout/api_request.rb +295 -0
- data/lib/processout/api_version.rb +92 -0
- data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
- data/lib/processout/balance.rb +92 -0
- data/lib/processout/balances.rb +111 -0
- data/lib/processout/card.rb +503 -0
- data/lib/processout/card_information.rb +164 -0
- data/lib/processout/coupon.rb +352 -0
- data/lib/processout/customer.rb +755 -0
- data/lib/processout/customer_action.rb +81 -0
- data/lib/processout/discount.rb +360 -0
- data/lib/processout/dunning_action.rb +81 -0
- data/lib/processout/errors/authentication_error.rb +9 -0
- data/lib/processout/errors/generic_error.rb +9 -0
- data/lib/processout/errors/internal_error.rb +9 -0
- data/lib/processout/errors/notfound_error.rb +9 -0
- data/lib/processout/errors/validation_error.rb +9 -0
- data/lib/processout/event.rb +237 -0
- data/lib/processout/gateway.rb +210 -0
- data/lib/processout/gateway_configuration.rb +346 -0
- data/lib/processout/gateway_request.rb +26 -0
- data/lib/processout/invoice.rb +984 -0
- data/lib/processout/invoice_detail.rb +235 -0
- data/lib/processout/invoice_device.rb +92 -0
- data/lib/processout/invoice_external_fraud_tools.rb +70 -0
- data/lib/processout/invoice_risk.rb +81 -0
- data/lib/processout/invoice_shipping.rb +202 -0
- data/lib/processout/invoice_tax.rb +81 -0
- data/lib/processout/networking/request.rb +102 -0
- data/lib/processout/networking/response.rb +67 -0
- data/lib/processout/payment_data_network_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_request.rb +103 -0
- data/lib/processout/payout.rb +379 -0
- data/lib/processout/payout_item.rb +238 -0
- data/lib/processout/plan.rb +368 -0
- data/lib/processout/product.rb +368 -0
- data/lib/processout/project.rb +353 -0
- data/lib/processout/refund.rb +277 -0
- data/lib/processout/subscription.rb +910 -0
- data/lib/processout/three_ds.rb +158 -0
- data/lib/processout/token.rb +493 -0
- data/lib/processout/transaction.rb +905 -0
- data/lib/processout/transaction_operation.rb +418 -0
- data/lib/processout/version.rb +3 -0
- data/lib/processout/webhook.rb +237 -0
- data/lib/processout/webhook_endpoint.rb +149 -0
- data/lib/processout.rb +263 -0
- data/processout.gemspec +26 -0
- metadata +66 -3
@@ -0,0 +1,158 @@
|
|
1
|
+
# The content of this file was automatically generated
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "processout/networking/request"
|
6
|
+
require "processout/networking/response"
|
7
|
+
|
8
|
+
module ProcessOut
|
9
|
+
class ThreeDS
|
10
|
+
|
11
|
+
attr_reader :version
|
12
|
+
attr_reader :status
|
13
|
+
attr_reader :fingerprinted
|
14
|
+
attr_reader :challenged
|
15
|
+
attr_reader :ares_trans_status
|
16
|
+
attr_reader :cres_trans_status
|
17
|
+
attr_reader :ds_trans_id
|
18
|
+
attr_reader :fingerprint_completion_indicator
|
19
|
+
attr_reader :server_trans_id
|
20
|
+
|
21
|
+
|
22
|
+
def version=(val)
|
23
|
+
@version = val
|
24
|
+
end
|
25
|
+
|
26
|
+
def status=(val)
|
27
|
+
@status = val
|
28
|
+
end
|
29
|
+
|
30
|
+
def fingerprinted=(val)
|
31
|
+
@fingerprinted = val
|
32
|
+
end
|
33
|
+
|
34
|
+
def challenged=(val)
|
35
|
+
@challenged = val
|
36
|
+
end
|
37
|
+
|
38
|
+
def ares_trans_status=(val)
|
39
|
+
@ares_trans_status = val
|
40
|
+
end
|
41
|
+
|
42
|
+
def cres_trans_status=(val)
|
43
|
+
@cres_trans_status = val
|
44
|
+
end
|
45
|
+
|
46
|
+
def ds_trans_id=(val)
|
47
|
+
@ds_trans_id = val
|
48
|
+
end
|
49
|
+
|
50
|
+
def fingerprint_completion_indicator=(val)
|
51
|
+
@fingerprint_completion_indicator = val
|
52
|
+
end
|
53
|
+
|
54
|
+
def server_trans_id=(val)
|
55
|
+
@server_trans_id = val
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# Initializes the ThreeDS object
|
60
|
+
# Params:
|
61
|
+
# +client+:: +ProcessOut+ client instance
|
62
|
+
# +data+:: data that can be used to fill the object
|
63
|
+
def initialize(client, data = {})
|
64
|
+
@client = client
|
65
|
+
|
66
|
+
self.version = data.fetch(:version, nil)
|
67
|
+
self.status = data.fetch(:status, nil)
|
68
|
+
self.fingerprinted = data.fetch(:fingerprinted, nil)
|
69
|
+
self.challenged = data.fetch(:challenged, nil)
|
70
|
+
self.ares_trans_status = data.fetch(:ares_trans_status, nil)
|
71
|
+
self.cres_trans_status = data.fetch(:cres_trans_status, nil)
|
72
|
+
self.ds_trans_id = data.fetch(:ds_trans_id, nil)
|
73
|
+
self.fingerprint_completion_indicator = data.fetch(:fingerprint_completion_indicator, nil)
|
74
|
+
self.server_trans_id = data.fetch(:server_trans_id, nil)
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# Create a new ThreeDS using the current client
|
79
|
+
def new(data = {})
|
80
|
+
ThreeDS.new(@client, data)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Overrides the JSON marshaller to only send the fields we want
|
84
|
+
def to_json(options)
|
85
|
+
{
|
86
|
+
"version": self.version,
|
87
|
+
"status": self.status,
|
88
|
+
"fingerprinted": self.fingerprinted,
|
89
|
+
"challenged": self.challenged,
|
90
|
+
"ares_trans_status": self.ares_trans_status,
|
91
|
+
"cres_trans_status": self.cres_trans_status,
|
92
|
+
"ds_trans_id": self.ds_trans_id,
|
93
|
+
"fingerprint_completion_indicator": self.fingerprint_completion_indicator,
|
94
|
+
"server_trans_id": self.server_trans_id,
|
95
|
+
}.to_json
|
96
|
+
end
|
97
|
+
|
98
|
+
# Fills the object with data coming from the API
|
99
|
+
# Params:
|
100
|
+
# +data+:: +Hash+ of data coming from the API
|
101
|
+
def fill_with_data(data)
|
102
|
+
if data.nil?
|
103
|
+
return self
|
104
|
+
end
|
105
|
+
if data.include? "version"
|
106
|
+
self.version = data["version"]
|
107
|
+
end
|
108
|
+
if data.include? "status"
|
109
|
+
self.status = data["status"]
|
110
|
+
end
|
111
|
+
if data.include? "fingerprinted"
|
112
|
+
self.fingerprinted = data["fingerprinted"]
|
113
|
+
end
|
114
|
+
if data.include? "challenged"
|
115
|
+
self.challenged = data["challenged"]
|
116
|
+
end
|
117
|
+
if data.include? "ares_trans_status"
|
118
|
+
self.ares_trans_status = data["ares_trans_status"]
|
119
|
+
end
|
120
|
+
if data.include? "cres_trans_status"
|
121
|
+
self.cres_trans_status = data["cres_trans_status"]
|
122
|
+
end
|
123
|
+
if data.include? "ds_trans_id"
|
124
|
+
self.ds_trans_id = data["ds_trans_id"]
|
125
|
+
end
|
126
|
+
if data.include? "fingerprint_completion_indicator"
|
127
|
+
self.fingerprint_completion_indicator = data["fingerprint_completion_indicator"]
|
128
|
+
end
|
129
|
+
if data.include? "server_trans_id"
|
130
|
+
self.server_trans_id = data["server_trans_id"]
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Prefills the object with the data passed as parameters
|
137
|
+
# Params:
|
138
|
+
# +data+:: +Hash+ of data
|
139
|
+
def prefill(data)
|
140
|
+
if data.nil?
|
141
|
+
return self
|
142
|
+
end
|
143
|
+
self.version = data.fetch(:version, self.version)
|
144
|
+
self.status = data.fetch(:status, self.status)
|
145
|
+
self.fingerprinted = data.fetch(:fingerprinted, self.fingerprinted)
|
146
|
+
self.challenged = data.fetch(:challenged, self.challenged)
|
147
|
+
self.ares_trans_status = data.fetch(:ares_trans_status, self.ares_trans_status)
|
148
|
+
self.cres_trans_status = data.fetch(:cres_trans_status, self.cres_trans_status)
|
149
|
+
self.ds_trans_id = data.fetch(:ds_trans_id, self.ds_trans_id)
|
150
|
+
self.fingerprint_completion_indicator = data.fetch(:fingerprint_completion_indicator, self.fingerprint_completion_indicator)
|
151
|
+
self.server_trans_id = data.fetch(:server_trans_id, self.server_trans_id)
|
152
|
+
|
153
|
+
self
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,493 @@
|
|
1
|
+
# The content of this file was automatically generated
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "processout/networking/request"
|
6
|
+
require "processout/networking/response"
|
7
|
+
|
8
|
+
module ProcessOut
|
9
|
+
class Token
|
10
|
+
|
11
|
+
attr_reader :id
|
12
|
+
attr_reader :customer
|
13
|
+
attr_reader :customer_id
|
14
|
+
attr_reader :gateway_configuration
|
15
|
+
attr_reader :gateway_configuration_id
|
16
|
+
attr_reader :card
|
17
|
+
attr_reader :card_id
|
18
|
+
attr_reader :type
|
19
|
+
attr_reader :metadata
|
20
|
+
attr_reader :is_subscription_only
|
21
|
+
attr_reader :is_default
|
22
|
+
attr_reader :return_url
|
23
|
+
attr_reader :cancel_url
|
24
|
+
attr_reader :summary
|
25
|
+
attr_reader :is_chargeable
|
26
|
+
attr_reader :created_at
|
27
|
+
attr_reader :description
|
28
|
+
attr_reader :invoice
|
29
|
+
attr_reader :invoice_id
|
30
|
+
attr_reader :manual_invoice_cancellation
|
31
|
+
attr_reader :verification_status
|
32
|
+
attr_reader :can_get_balance
|
33
|
+
|
34
|
+
|
35
|
+
def id=(val)
|
36
|
+
@id = val
|
37
|
+
end
|
38
|
+
|
39
|
+
def customer=(val)
|
40
|
+
if val.nil?
|
41
|
+
@customer = val
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
if val.instance_of? Customer
|
46
|
+
@customer = val
|
47
|
+
else
|
48
|
+
obj = Customer.new(@client)
|
49
|
+
obj.fill_with_data(val)
|
50
|
+
@customer = obj
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def customer_id=(val)
|
56
|
+
@customer_id = val
|
57
|
+
end
|
58
|
+
|
59
|
+
def gateway_configuration=(val)
|
60
|
+
if val.nil?
|
61
|
+
@gateway_configuration = val
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
if val.instance_of? GatewayConfiguration
|
66
|
+
@gateway_configuration = val
|
67
|
+
else
|
68
|
+
obj = GatewayConfiguration.new(@client)
|
69
|
+
obj.fill_with_data(val)
|
70
|
+
@gateway_configuration = obj
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def gateway_configuration_id=(val)
|
76
|
+
@gateway_configuration_id = val
|
77
|
+
end
|
78
|
+
|
79
|
+
def card=(val)
|
80
|
+
if val.nil?
|
81
|
+
@card = val
|
82
|
+
return
|
83
|
+
end
|
84
|
+
|
85
|
+
if val.instance_of? Card
|
86
|
+
@card = val
|
87
|
+
else
|
88
|
+
obj = Card.new(@client)
|
89
|
+
obj.fill_with_data(val)
|
90
|
+
@card = obj
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def card_id=(val)
|
96
|
+
@card_id = val
|
97
|
+
end
|
98
|
+
|
99
|
+
def type=(val)
|
100
|
+
@type = val
|
101
|
+
end
|
102
|
+
|
103
|
+
def metadata=(val)
|
104
|
+
@metadata = val
|
105
|
+
end
|
106
|
+
|
107
|
+
def is_subscription_only=(val)
|
108
|
+
@is_subscription_only = val
|
109
|
+
end
|
110
|
+
|
111
|
+
def is_default=(val)
|
112
|
+
@is_default = val
|
113
|
+
end
|
114
|
+
|
115
|
+
def return_url=(val)
|
116
|
+
@return_url = val
|
117
|
+
end
|
118
|
+
|
119
|
+
def cancel_url=(val)
|
120
|
+
@cancel_url = val
|
121
|
+
end
|
122
|
+
|
123
|
+
def summary=(val)
|
124
|
+
@summary = val
|
125
|
+
end
|
126
|
+
|
127
|
+
def is_chargeable=(val)
|
128
|
+
@is_chargeable = val
|
129
|
+
end
|
130
|
+
|
131
|
+
def created_at=(val)
|
132
|
+
@created_at = val
|
133
|
+
end
|
134
|
+
|
135
|
+
def description=(val)
|
136
|
+
@description = val
|
137
|
+
end
|
138
|
+
|
139
|
+
def invoice=(val)
|
140
|
+
if val.nil?
|
141
|
+
@invoice = val
|
142
|
+
return
|
143
|
+
end
|
144
|
+
|
145
|
+
if val.instance_of? Invoice
|
146
|
+
@invoice = val
|
147
|
+
else
|
148
|
+
obj = Invoice.new(@client)
|
149
|
+
obj.fill_with_data(val)
|
150
|
+
@invoice = obj
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
def invoice_id=(val)
|
156
|
+
@invoice_id = val
|
157
|
+
end
|
158
|
+
|
159
|
+
def manual_invoice_cancellation=(val)
|
160
|
+
@manual_invoice_cancellation = val
|
161
|
+
end
|
162
|
+
|
163
|
+
def verification_status=(val)
|
164
|
+
@verification_status = val
|
165
|
+
end
|
166
|
+
|
167
|
+
def can_get_balance=(val)
|
168
|
+
@can_get_balance = val
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
# Initializes the Token object
|
173
|
+
# Params:
|
174
|
+
# +client+:: +ProcessOut+ client instance
|
175
|
+
# +data+:: data that can be used to fill the object
|
176
|
+
def initialize(client, data = {})
|
177
|
+
@client = client
|
178
|
+
|
179
|
+
self.id = data.fetch(:id, nil)
|
180
|
+
self.customer = data.fetch(:customer, nil)
|
181
|
+
self.customer_id = data.fetch(:customer_id, nil)
|
182
|
+
self.gateway_configuration = data.fetch(:gateway_configuration, nil)
|
183
|
+
self.gateway_configuration_id = data.fetch(:gateway_configuration_id, nil)
|
184
|
+
self.card = data.fetch(:card, nil)
|
185
|
+
self.card_id = data.fetch(:card_id, nil)
|
186
|
+
self.type = data.fetch(:type, nil)
|
187
|
+
self.metadata = data.fetch(:metadata, nil)
|
188
|
+
self.is_subscription_only = data.fetch(:is_subscription_only, nil)
|
189
|
+
self.is_default = data.fetch(:is_default, nil)
|
190
|
+
self.return_url = data.fetch(:return_url, nil)
|
191
|
+
self.cancel_url = data.fetch(:cancel_url, nil)
|
192
|
+
self.summary = data.fetch(:summary, nil)
|
193
|
+
self.is_chargeable = data.fetch(:is_chargeable, nil)
|
194
|
+
self.created_at = data.fetch(:created_at, nil)
|
195
|
+
self.description = data.fetch(:description, nil)
|
196
|
+
self.invoice = data.fetch(:invoice, nil)
|
197
|
+
self.invoice_id = data.fetch(:invoice_id, nil)
|
198
|
+
self.manual_invoice_cancellation = data.fetch(:manual_invoice_cancellation, nil)
|
199
|
+
self.verification_status = data.fetch(:verification_status, nil)
|
200
|
+
self.can_get_balance = data.fetch(:can_get_balance, nil)
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
# Create a new Token using the current client
|
205
|
+
def new(data = {})
|
206
|
+
Token.new(@client, data)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Overrides the JSON marshaller to only send the fields we want
|
210
|
+
def to_json(options)
|
211
|
+
{
|
212
|
+
"id": self.id,
|
213
|
+
"customer": self.customer,
|
214
|
+
"customer_id": self.customer_id,
|
215
|
+
"gateway_configuration": self.gateway_configuration,
|
216
|
+
"gateway_configuration_id": self.gateway_configuration_id,
|
217
|
+
"card": self.card,
|
218
|
+
"card_id": self.card_id,
|
219
|
+
"type": self.type,
|
220
|
+
"metadata": self.metadata,
|
221
|
+
"is_subscription_only": self.is_subscription_only,
|
222
|
+
"is_default": self.is_default,
|
223
|
+
"return_url": self.return_url,
|
224
|
+
"cancel_url": self.cancel_url,
|
225
|
+
"summary": self.summary,
|
226
|
+
"is_chargeable": self.is_chargeable,
|
227
|
+
"created_at": self.created_at,
|
228
|
+
"description": self.description,
|
229
|
+
"invoice": self.invoice,
|
230
|
+
"invoice_id": self.invoice_id,
|
231
|
+
"manual_invoice_cancellation": self.manual_invoice_cancellation,
|
232
|
+
"verification_status": self.verification_status,
|
233
|
+
"can_get_balance": self.can_get_balance,
|
234
|
+
}.to_json
|
235
|
+
end
|
236
|
+
|
237
|
+
# Fills the object with data coming from the API
|
238
|
+
# Params:
|
239
|
+
# +data+:: +Hash+ of data coming from the API
|
240
|
+
def fill_with_data(data)
|
241
|
+
if data.nil?
|
242
|
+
return self
|
243
|
+
end
|
244
|
+
if data.include? "id"
|
245
|
+
self.id = data["id"]
|
246
|
+
end
|
247
|
+
if data.include? "customer"
|
248
|
+
self.customer = data["customer"]
|
249
|
+
end
|
250
|
+
if data.include? "customer_id"
|
251
|
+
self.customer_id = data["customer_id"]
|
252
|
+
end
|
253
|
+
if data.include? "gateway_configuration"
|
254
|
+
self.gateway_configuration = data["gateway_configuration"]
|
255
|
+
end
|
256
|
+
if data.include? "gateway_configuration_id"
|
257
|
+
self.gateway_configuration_id = data["gateway_configuration_id"]
|
258
|
+
end
|
259
|
+
if data.include? "card"
|
260
|
+
self.card = data["card"]
|
261
|
+
end
|
262
|
+
if data.include? "card_id"
|
263
|
+
self.card_id = data["card_id"]
|
264
|
+
end
|
265
|
+
if data.include? "type"
|
266
|
+
self.type = data["type"]
|
267
|
+
end
|
268
|
+
if data.include? "metadata"
|
269
|
+
self.metadata = data["metadata"]
|
270
|
+
end
|
271
|
+
if data.include? "is_subscription_only"
|
272
|
+
self.is_subscription_only = data["is_subscription_only"]
|
273
|
+
end
|
274
|
+
if data.include? "is_default"
|
275
|
+
self.is_default = data["is_default"]
|
276
|
+
end
|
277
|
+
if data.include? "return_url"
|
278
|
+
self.return_url = data["return_url"]
|
279
|
+
end
|
280
|
+
if data.include? "cancel_url"
|
281
|
+
self.cancel_url = data["cancel_url"]
|
282
|
+
end
|
283
|
+
if data.include? "summary"
|
284
|
+
self.summary = data["summary"]
|
285
|
+
end
|
286
|
+
if data.include? "is_chargeable"
|
287
|
+
self.is_chargeable = data["is_chargeable"]
|
288
|
+
end
|
289
|
+
if data.include? "created_at"
|
290
|
+
self.created_at = data["created_at"]
|
291
|
+
end
|
292
|
+
if data.include? "description"
|
293
|
+
self.description = data["description"]
|
294
|
+
end
|
295
|
+
if data.include? "invoice"
|
296
|
+
self.invoice = data["invoice"]
|
297
|
+
end
|
298
|
+
if data.include? "invoice_id"
|
299
|
+
self.invoice_id = data["invoice_id"]
|
300
|
+
end
|
301
|
+
if data.include? "manual_invoice_cancellation"
|
302
|
+
self.manual_invoice_cancellation = data["manual_invoice_cancellation"]
|
303
|
+
end
|
304
|
+
if data.include? "verification_status"
|
305
|
+
self.verification_status = data["verification_status"]
|
306
|
+
end
|
307
|
+
if data.include? "can_get_balance"
|
308
|
+
self.can_get_balance = data["can_get_balance"]
|
309
|
+
end
|
310
|
+
|
311
|
+
self
|
312
|
+
end
|
313
|
+
|
314
|
+
# Prefills the object with the data passed as parameters
|
315
|
+
# Params:
|
316
|
+
# +data+:: +Hash+ of data
|
317
|
+
def prefill(data)
|
318
|
+
if data.nil?
|
319
|
+
return self
|
320
|
+
end
|
321
|
+
self.id = data.fetch(:id, self.id)
|
322
|
+
self.customer = data.fetch(:customer, self.customer)
|
323
|
+
self.customer_id = data.fetch(:customer_id, self.customer_id)
|
324
|
+
self.gateway_configuration = data.fetch(:gateway_configuration, self.gateway_configuration)
|
325
|
+
self.gateway_configuration_id = data.fetch(:gateway_configuration_id, self.gateway_configuration_id)
|
326
|
+
self.card = data.fetch(:card, self.card)
|
327
|
+
self.card_id = data.fetch(:card_id, self.card_id)
|
328
|
+
self.type = data.fetch(:type, self.type)
|
329
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
330
|
+
self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
|
331
|
+
self.is_default = data.fetch(:is_default, self.is_default)
|
332
|
+
self.return_url = data.fetch(:return_url, self.return_url)
|
333
|
+
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
334
|
+
self.summary = data.fetch(:summary, self.summary)
|
335
|
+
self.is_chargeable = data.fetch(:is_chargeable, self.is_chargeable)
|
336
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
337
|
+
self.description = data.fetch(:description, self.description)
|
338
|
+
self.invoice = data.fetch(:invoice, self.invoice)
|
339
|
+
self.invoice_id = data.fetch(:invoice_id, self.invoice_id)
|
340
|
+
self.manual_invoice_cancellation = data.fetch(:manual_invoice_cancellation, self.manual_invoice_cancellation)
|
341
|
+
self.verification_status = data.fetch(:verification_status, self.verification_status)
|
342
|
+
self.can_get_balance = data.fetch(:can_get_balance, self.can_get_balance)
|
343
|
+
|
344
|
+
self
|
345
|
+
end
|
346
|
+
|
347
|
+
# Get the customer's tokens.
|
348
|
+
# Params:
|
349
|
+
# +customer_id+:: ID of the customer
|
350
|
+
# +options+:: +Hash+ of options
|
351
|
+
def fetch_customer_tokens(customer_id, options = {})
|
352
|
+
self.prefill(options)
|
353
|
+
|
354
|
+
request = Request.new(@client)
|
355
|
+
path = "/customers/" + CGI.escape(customer_id) + "/tokens"
|
356
|
+
data = {
|
357
|
+
|
358
|
+
}
|
359
|
+
|
360
|
+
response = Response.new(request.get(path, data, options))
|
361
|
+
return_values = Array.new
|
362
|
+
|
363
|
+
a = Array.new
|
364
|
+
body = response.body
|
365
|
+
for v in body['tokens']
|
366
|
+
tmp = Token.new(@client)
|
367
|
+
tmp.fill_with_data(v)
|
368
|
+
a.push(tmp)
|
369
|
+
end
|
370
|
+
|
371
|
+
return_values.push(a)
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
return_values[0]
|
376
|
+
end
|
377
|
+
|
378
|
+
# Find a customer's token by its ID.
|
379
|
+
# Params:
|
380
|
+
# +customer_id+:: ID of the customer
|
381
|
+
# +token_id+:: ID of the token
|
382
|
+
# +options+:: +Hash+ of options
|
383
|
+
def find(customer_id, token_id, options = {})
|
384
|
+
self.prefill(options)
|
385
|
+
|
386
|
+
request = Request.new(@client)
|
387
|
+
path = "/customers/" + CGI.escape(customer_id) + "/tokens/" + CGI.escape(token_id) + ""
|
388
|
+
data = {
|
389
|
+
|
390
|
+
}
|
391
|
+
|
392
|
+
response = Response.new(request.get(path, data, options))
|
393
|
+
return_values = Array.new
|
394
|
+
|
395
|
+
body = response.body
|
396
|
+
body = body["token"]
|
397
|
+
|
398
|
+
|
399
|
+
obj = Token.new(@client)
|
400
|
+
return_values.push(obj.fill_with_data(body))
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
return_values[0]
|
405
|
+
end
|
406
|
+
|
407
|
+
# Create a new token for the given customer ID.
|
408
|
+
# Params:
|
409
|
+
# +options+:: +Hash+ of options
|
410
|
+
def create(options = {})
|
411
|
+
self.prefill(options)
|
412
|
+
|
413
|
+
request = Request.new(@client)
|
414
|
+
path = "/customers/" + CGI.escape(@customer_id) + "/tokens"
|
415
|
+
data = {
|
416
|
+
"metadata" => @metadata,
|
417
|
+
"return_url" => @return_url,
|
418
|
+
"cancel_url" => @cancel_url,
|
419
|
+
"description" => @description,
|
420
|
+
"invoice_id" => @invoice_id,
|
421
|
+
"manual_invoice_cancellation" => @manual_invoice_cancellation,
|
422
|
+
"source" => options.fetch(:source, nil),
|
423
|
+
"settings" => options.fetch(:settings, nil),
|
424
|
+
"device" => options.fetch(:device, nil),
|
425
|
+
"verify" => options.fetch(:verify, nil),
|
426
|
+
"verify_metadata" => options.fetch(:verify_metadata, nil),
|
427
|
+
"set_default" => options.fetch(:set_default, nil)
|
428
|
+
}
|
429
|
+
|
430
|
+
response = Response.new(request.post(path, data, options))
|
431
|
+
return_values = Array.new
|
432
|
+
|
433
|
+
body = response.body
|
434
|
+
body = body["token"]
|
435
|
+
|
436
|
+
|
437
|
+
return_values.push(self.fill_with_data(body))
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
return_values[0]
|
442
|
+
end
|
443
|
+
|
444
|
+
# Save the updated customer attributes.
|
445
|
+
# Params:
|
446
|
+
# +options+:: +Hash+ of options
|
447
|
+
def save(options = {})
|
448
|
+
self.prefill(options)
|
449
|
+
|
450
|
+
request = Request.new(@client)
|
451
|
+
path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
|
452
|
+
data = {
|
453
|
+
"source" => options.fetch(:source, nil),
|
454
|
+
"settings" => options.fetch(:settings, nil),
|
455
|
+
"device" => options.fetch(:device, nil),
|
456
|
+
"verify" => options.fetch(:verify, nil),
|
457
|
+
"verify_metadata" => options.fetch(:verify_metadata, nil),
|
458
|
+
"set_default" => options.fetch(:set_default, nil)
|
459
|
+
}
|
460
|
+
|
461
|
+
response = Response.new(request.put(path, data, options))
|
462
|
+
return_values = Array.new
|
463
|
+
|
464
|
+
return_values.push(response.success)
|
465
|
+
|
466
|
+
|
467
|
+
return_values[0]
|
468
|
+
end
|
469
|
+
|
470
|
+
# Delete a customer token
|
471
|
+
# Params:
|
472
|
+
# +options+:: +Hash+ of options
|
473
|
+
def delete(options = {})
|
474
|
+
self.prefill(options)
|
475
|
+
|
476
|
+
request = Request.new(@client)
|
477
|
+
path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
|
478
|
+
data = {
|
479
|
+
|
480
|
+
}
|
481
|
+
|
482
|
+
response = Response.new(request.delete(path, data, options))
|
483
|
+
return_values = Array.new
|
484
|
+
|
485
|
+
return_values.push(response.success)
|
486
|
+
|
487
|
+
|
488
|
+
return_values[0]
|
489
|
+
end
|
490
|
+
|
491
|
+
|
492
|
+
end
|
493
|
+
end
|