processout 2.17.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +4 -65
- data/.gitignore +0 -52
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Dockerfile +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Makefile +0 -4
- data/README.md +0 -12
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/processout/activity.rb +0 -206
- data/lib/processout/addon.rb +0 -401
- data/lib/processout/api_request.rb +0 -295
- data/lib/processout/api_version.rb +0 -92
- data/lib/processout/balance.rb +0 -81
- data/lib/processout/balances.rb +0 -111
- data/lib/processout/card.rb +0 -503
- data/lib/processout/card_information.rb +0 -164
- data/lib/processout/coupon.rb +0 -352
- data/lib/processout/customer.rb +0 -755
- data/lib/processout/customer_action.rb +0 -81
- data/lib/processout/discount.rb +0 -360
- data/lib/processout/dunning_action.rb +0 -81
- data/lib/processout/errors/authentication_error.rb +0 -9
- data/lib/processout/errors/generic_error.rb +0 -9
- data/lib/processout/errors/internal_error.rb +0 -9
- data/lib/processout/errors/notfound_error.rb +0 -9
- data/lib/processout/errors/validation_error.rb +0 -9
- data/lib/processout/event.rb +0 -237
- data/lib/processout/gateway.rb +0 -210
- data/lib/processout/gateway_configuration.rb +0 -346
- data/lib/processout/gateway_request.rb +0 -26
- data/lib/processout/invoice.rb +0 -945
- data/lib/processout/invoice_detail.rb +0 -224
- data/lib/processout/invoice_device.rb +0 -92
- data/lib/processout/invoice_external_fraud_tools.rb +0 -70
- data/lib/processout/invoice_risk.rb +0 -81
- data/lib/processout/invoice_shipping.rb +0 -191
- data/lib/processout/invoice_tax.rb +0 -81
- data/lib/processout/networking/request.rb +0 -102
- data/lib/processout/networking/response.rb +0 -67
- data/lib/processout/payment_data_network_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_request.rb +0 -103
- data/lib/processout/payout.rb +0 -379
- data/lib/processout/payout_item.rb +0 -238
- data/lib/processout/plan.rb +0 -368
- data/lib/processout/product.rb +0 -368
- data/lib/processout/project.rb +0 -353
- data/lib/processout/refund.rb +0 -265
- data/lib/processout/subscription.rb +0 -910
- data/lib/processout/three_ds.rb +0 -158
- data/lib/processout/token.rb +0 -482
- data/lib/processout/transaction.rb +0 -894
- data/lib/processout/transaction_operation.rb +0 -418
- data/lib/processout/version.rb +0 -3
- data/lib/processout/webhook.rb +0 -237
- data/lib/processout/webhook_endpoint.rb +0 -149
- data/lib/processout.rb +0 -251
- data/processout.gemspec +0 -26
data/lib/processout/invoice.rb
DELETED
@@ -1,945 +0,0 @@
|
|
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 Invoice
|
10
|
-
|
11
|
-
attr_reader :id
|
12
|
-
attr_reader :project
|
13
|
-
attr_reader :project_id
|
14
|
-
attr_reader :transaction
|
15
|
-
attr_reader :transaction_id
|
16
|
-
attr_reader :customer
|
17
|
-
attr_reader :customer_id
|
18
|
-
attr_reader :subscription
|
19
|
-
attr_reader :subscription_id
|
20
|
-
attr_reader :token
|
21
|
-
attr_reader :token_id
|
22
|
-
attr_reader :details
|
23
|
-
attr_reader :url
|
24
|
-
attr_reader :name
|
25
|
-
attr_reader :amount
|
26
|
-
attr_reader :currency
|
27
|
-
attr_reader :merchant_initiator_type
|
28
|
-
attr_reader :statement_descriptor
|
29
|
-
attr_reader :statement_descriptor_phone
|
30
|
-
attr_reader :statement_descriptor_city
|
31
|
-
attr_reader :statement_descriptor_company
|
32
|
-
attr_reader :statement_descriptor_url
|
33
|
-
attr_reader :metadata
|
34
|
-
attr_reader :gateway_data
|
35
|
-
attr_reader :return_url
|
36
|
-
attr_reader :cancel_url
|
37
|
-
attr_reader :webhook_url
|
38
|
-
attr_reader :require_backend_capture
|
39
|
-
attr_reader :sandbox
|
40
|
-
attr_reader :created_at
|
41
|
-
attr_reader :risk
|
42
|
-
attr_reader :shipping
|
43
|
-
attr_reader :device
|
44
|
-
attr_reader :external_fraud_tools
|
45
|
-
attr_reader :exemption_reason_3ds2
|
46
|
-
attr_reader :sca_exemption_reason
|
47
|
-
attr_reader :challenge_indicator
|
48
|
-
attr_reader :incremental
|
49
|
-
attr_reader :tax
|
50
|
-
|
51
|
-
|
52
|
-
def id=(val)
|
53
|
-
@id = val
|
54
|
-
end
|
55
|
-
|
56
|
-
def project=(val)
|
57
|
-
if val.nil?
|
58
|
-
@project = val
|
59
|
-
return
|
60
|
-
end
|
61
|
-
|
62
|
-
if val.instance_of? Project
|
63
|
-
@project = val
|
64
|
-
else
|
65
|
-
obj = Project.new(@client)
|
66
|
-
obj.fill_with_data(val)
|
67
|
-
@project = obj
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def project_id=(val)
|
73
|
-
@project_id = val
|
74
|
-
end
|
75
|
-
|
76
|
-
def transaction=(val)
|
77
|
-
if val.nil?
|
78
|
-
@transaction = val
|
79
|
-
return
|
80
|
-
end
|
81
|
-
|
82
|
-
if val.instance_of? Transaction
|
83
|
-
@transaction = val
|
84
|
-
else
|
85
|
-
obj = Transaction.new(@client)
|
86
|
-
obj.fill_with_data(val)
|
87
|
-
@transaction = obj
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
def transaction_id=(val)
|
93
|
-
@transaction_id = val
|
94
|
-
end
|
95
|
-
|
96
|
-
def customer=(val)
|
97
|
-
if val.nil?
|
98
|
-
@customer = val
|
99
|
-
return
|
100
|
-
end
|
101
|
-
|
102
|
-
if val.instance_of? Customer
|
103
|
-
@customer = val
|
104
|
-
else
|
105
|
-
obj = Customer.new(@client)
|
106
|
-
obj.fill_with_data(val)
|
107
|
-
@customer = obj
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
def customer_id=(val)
|
113
|
-
@customer_id = val
|
114
|
-
end
|
115
|
-
|
116
|
-
def subscription=(val)
|
117
|
-
if val.nil?
|
118
|
-
@subscription = val
|
119
|
-
return
|
120
|
-
end
|
121
|
-
|
122
|
-
if val.instance_of? Subscription
|
123
|
-
@subscription = val
|
124
|
-
else
|
125
|
-
obj = Subscription.new(@client)
|
126
|
-
obj.fill_with_data(val)
|
127
|
-
@subscription = obj
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
def subscription_id=(val)
|
133
|
-
@subscription_id = val
|
134
|
-
end
|
135
|
-
|
136
|
-
def token=(val)
|
137
|
-
if val.nil?
|
138
|
-
@token = val
|
139
|
-
return
|
140
|
-
end
|
141
|
-
|
142
|
-
if val.instance_of? Token
|
143
|
-
@token = val
|
144
|
-
else
|
145
|
-
obj = Token.new(@client)
|
146
|
-
obj.fill_with_data(val)
|
147
|
-
@token = obj
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
def token_id=(val)
|
153
|
-
@token_id = val
|
154
|
-
end
|
155
|
-
|
156
|
-
def details=(val)
|
157
|
-
if val.nil?
|
158
|
-
@details = []
|
159
|
-
return
|
160
|
-
end
|
161
|
-
|
162
|
-
if val.length > 0 and val[0].instance_of? InvoiceDetail
|
163
|
-
@details = val
|
164
|
-
else
|
165
|
-
l = Array.new
|
166
|
-
for v in val
|
167
|
-
obj = InvoiceDetail.new(@client)
|
168
|
-
obj.fill_with_data(v)
|
169
|
-
l.push(obj)
|
170
|
-
end
|
171
|
-
@details = l
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
def url=(val)
|
177
|
-
@url = val
|
178
|
-
end
|
179
|
-
|
180
|
-
def name=(val)
|
181
|
-
@name = val
|
182
|
-
end
|
183
|
-
|
184
|
-
def amount=(val)
|
185
|
-
@amount = val
|
186
|
-
end
|
187
|
-
|
188
|
-
def currency=(val)
|
189
|
-
@currency = val
|
190
|
-
end
|
191
|
-
|
192
|
-
def merchant_initiator_type=(val)
|
193
|
-
@merchant_initiator_type = val
|
194
|
-
end
|
195
|
-
|
196
|
-
def statement_descriptor=(val)
|
197
|
-
@statement_descriptor = val
|
198
|
-
end
|
199
|
-
|
200
|
-
def statement_descriptor_phone=(val)
|
201
|
-
@statement_descriptor_phone = val
|
202
|
-
end
|
203
|
-
|
204
|
-
def statement_descriptor_city=(val)
|
205
|
-
@statement_descriptor_city = val
|
206
|
-
end
|
207
|
-
|
208
|
-
def statement_descriptor_company=(val)
|
209
|
-
@statement_descriptor_company = val
|
210
|
-
end
|
211
|
-
|
212
|
-
def statement_descriptor_url=(val)
|
213
|
-
@statement_descriptor_url = val
|
214
|
-
end
|
215
|
-
|
216
|
-
def metadata=(val)
|
217
|
-
@metadata = val
|
218
|
-
end
|
219
|
-
|
220
|
-
def gateway_data=(val)
|
221
|
-
@gateway_data = val
|
222
|
-
end
|
223
|
-
|
224
|
-
def return_url=(val)
|
225
|
-
@return_url = val
|
226
|
-
end
|
227
|
-
|
228
|
-
def cancel_url=(val)
|
229
|
-
@cancel_url = val
|
230
|
-
end
|
231
|
-
|
232
|
-
def webhook_url=(val)
|
233
|
-
@webhook_url = val
|
234
|
-
end
|
235
|
-
|
236
|
-
def require_backend_capture=(val)
|
237
|
-
@require_backend_capture = val
|
238
|
-
end
|
239
|
-
|
240
|
-
def sandbox=(val)
|
241
|
-
@sandbox = val
|
242
|
-
end
|
243
|
-
|
244
|
-
def created_at=(val)
|
245
|
-
@created_at = val
|
246
|
-
end
|
247
|
-
|
248
|
-
def risk=(val)
|
249
|
-
if val.nil?
|
250
|
-
@risk = val
|
251
|
-
return
|
252
|
-
end
|
253
|
-
|
254
|
-
if val.instance_of? InvoiceRisk
|
255
|
-
@risk = val
|
256
|
-
else
|
257
|
-
obj = InvoiceRisk.new(@client)
|
258
|
-
obj.fill_with_data(val)
|
259
|
-
@risk = obj
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|
263
|
-
|
264
|
-
def shipping=(val)
|
265
|
-
if val.nil?
|
266
|
-
@shipping = val
|
267
|
-
return
|
268
|
-
end
|
269
|
-
|
270
|
-
if val.instance_of? InvoiceShipping
|
271
|
-
@shipping = val
|
272
|
-
else
|
273
|
-
obj = InvoiceShipping.new(@client)
|
274
|
-
obj.fill_with_data(val)
|
275
|
-
@shipping = obj
|
276
|
-
end
|
277
|
-
|
278
|
-
end
|
279
|
-
|
280
|
-
def device=(val)
|
281
|
-
if val.nil?
|
282
|
-
@device = val
|
283
|
-
return
|
284
|
-
end
|
285
|
-
|
286
|
-
if val.instance_of? InvoiceDevice
|
287
|
-
@device = val
|
288
|
-
else
|
289
|
-
obj = InvoiceDevice.new(@client)
|
290
|
-
obj.fill_with_data(val)
|
291
|
-
@device = obj
|
292
|
-
end
|
293
|
-
|
294
|
-
end
|
295
|
-
|
296
|
-
def external_fraud_tools=(val)
|
297
|
-
if val.nil?
|
298
|
-
@external_fraud_tools = val
|
299
|
-
return
|
300
|
-
end
|
301
|
-
|
302
|
-
if val.instance_of? InvoiceExternalFraudTools
|
303
|
-
@external_fraud_tools = val
|
304
|
-
else
|
305
|
-
obj = InvoiceExternalFraudTools.new(@client)
|
306
|
-
obj.fill_with_data(val)
|
307
|
-
@external_fraud_tools = obj
|
308
|
-
end
|
309
|
-
|
310
|
-
end
|
311
|
-
|
312
|
-
def exemption_reason_3ds2=(val)
|
313
|
-
@exemption_reason_3ds2 = val
|
314
|
-
end
|
315
|
-
|
316
|
-
def sca_exemption_reason=(val)
|
317
|
-
@sca_exemption_reason = val
|
318
|
-
end
|
319
|
-
|
320
|
-
def challenge_indicator=(val)
|
321
|
-
@challenge_indicator = val
|
322
|
-
end
|
323
|
-
|
324
|
-
def incremental=(val)
|
325
|
-
@incremental = val
|
326
|
-
end
|
327
|
-
|
328
|
-
def tax=(val)
|
329
|
-
if val.nil?
|
330
|
-
@tax = val
|
331
|
-
return
|
332
|
-
end
|
333
|
-
|
334
|
-
if val.instance_of? InvoiceTax
|
335
|
-
@tax = val
|
336
|
-
else
|
337
|
-
obj = InvoiceTax.new(@client)
|
338
|
-
obj.fill_with_data(val)
|
339
|
-
@tax = obj
|
340
|
-
end
|
341
|
-
|
342
|
-
end
|
343
|
-
|
344
|
-
|
345
|
-
# Initializes the Invoice object
|
346
|
-
# Params:
|
347
|
-
# +client+:: +ProcessOut+ client instance
|
348
|
-
# +data+:: data that can be used to fill the object
|
349
|
-
def initialize(client, data = {})
|
350
|
-
@client = client
|
351
|
-
|
352
|
-
self.id = data.fetch(:id, nil)
|
353
|
-
self.project = data.fetch(:project, nil)
|
354
|
-
self.project_id = data.fetch(:project_id, nil)
|
355
|
-
self.transaction = data.fetch(:transaction, nil)
|
356
|
-
self.transaction_id = data.fetch(:transaction_id, nil)
|
357
|
-
self.customer = data.fetch(:customer, nil)
|
358
|
-
self.customer_id = data.fetch(:customer_id, nil)
|
359
|
-
self.subscription = data.fetch(:subscription, nil)
|
360
|
-
self.subscription_id = data.fetch(:subscription_id, nil)
|
361
|
-
self.token = data.fetch(:token, nil)
|
362
|
-
self.token_id = data.fetch(:token_id, nil)
|
363
|
-
self.details = data.fetch(:details, nil)
|
364
|
-
self.url = data.fetch(:url, nil)
|
365
|
-
self.name = data.fetch(:name, nil)
|
366
|
-
self.amount = data.fetch(:amount, nil)
|
367
|
-
self.currency = data.fetch(:currency, nil)
|
368
|
-
self.merchant_initiator_type = data.fetch(:merchant_initiator_type, nil)
|
369
|
-
self.statement_descriptor = data.fetch(:statement_descriptor, nil)
|
370
|
-
self.statement_descriptor_phone = data.fetch(:statement_descriptor_phone, nil)
|
371
|
-
self.statement_descriptor_city = data.fetch(:statement_descriptor_city, nil)
|
372
|
-
self.statement_descriptor_company = data.fetch(:statement_descriptor_company, nil)
|
373
|
-
self.statement_descriptor_url = data.fetch(:statement_descriptor_url, nil)
|
374
|
-
self.metadata = data.fetch(:metadata, nil)
|
375
|
-
self.gateway_data = data.fetch(:gateway_data, nil)
|
376
|
-
self.return_url = data.fetch(:return_url, nil)
|
377
|
-
self.cancel_url = data.fetch(:cancel_url, nil)
|
378
|
-
self.webhook_url = data.fetch(:webhook_url, nil)
|
379
|
-
self.require_backend_capture = data.fetch(:require_backend_capture, nil)
|
380
|
-
self.sandbox = data.fetch(:sandbox, nil)
|
381
|
-
self.created_at = data.fetch(:created_at, nil)
|
382
|
-
self.risk = data.fetch(:risk, nil)
|
383
|
-
self.shipping = data.fetch(:shipping, nil)
|
384
|
-
self.device = data.fetch(:device, nil)
|
385
|
-
self.external_fraud_tools = data.fetch(:external_fraud_tools, nil)
|
386
|
-
self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, nil)
|
387
|
-
self.sca_exemption_reason = data.fetch(:sca_exemption_reason, nil)
|
388
|
-
self.challenge_indicator = data.fetch(:challenge_indicator, nil)
|
389
|
-
self.incremental = data.fetch(:incremental, nil)
|
390
|
-
self.tax = data.fetch(:tax, nil)
|
391
|
-
|
392
|
-
end
|
393
|
-
|
394
|
-
# Create a new Invoice using the current client
|
395
|
-
def new(data = {})
|
396
|
-
Invoice.new(@client, data)
|
397
|
-
end
|
398
|
-
|
399
|
-
# Overrides the JSON marshaller to only send the fields we want
|
400
|
-
def to_json(options)
|
401
|
-
{
|
402
|
-
"id": self.id,
|
403
|
-
"project": self.project,
|
404
|
-
"project_id": self.project_id,
|
405
|
-
"transaction": self.transaction,
|
406
|
-
"transaction_id": self.transaction_id,
|
407
|
-
"customer": self.customer,
|
408
|
-
"customer_id": self.customer_id,
|
409
|
-
"subscription": self.subscription,
|
410
|
-
"subscription_id": self.subscription_id,
|
411
|
-
"token": self.token,
|
412
|
-
"token_id": self.token_id,
|
413
|
-
"details": self.details,
|
414
|
-
"url": self.url,
|
415
|
-
"name": self.name,
|
416
|
-
"amount": self.amount,
|
417
|
-
"currency": self.currency,
|
418
|
-
"merchant_initiator_type": self.merchant_initiator_type,
|
419
|
-
"statement_descriptor": self.statement_descriptor,
|
420
|
-
"statement_descriptor_phone": self.statement_descriptor_phone,
|
421
|
-
"statement_descriptor_city": self.statement_descriptor_city,
|
422
|
-
"statement_descriptor_company": self.statement_descriptor_company,
|
423
|
-
"statement_descriptor_url": self.statement_descriptor_url,
|
424
|
-
"metadata": self.metadata,
|
425
|
-
"gateway_data": self.gateway_data,
|
426
|
-
"return_url": self.return_url,
|
427
|
-
"cancel_url": self.cancel_url,
|
428
|
-
"webhook_url": self.webhook_url,
|
429
|
-
"require_backend_capture": self.require_backend_capture,
|
430
|
-
"sandbox": self.sandbox,
|
431
|
-
"created_at": self.created_at,
|
432
|
-
"risk": self.risk,
|
433
|
-
"shipping": self.shipping,
|
434
|
-
"device": self.device,
|
435
|
-
"external_fraud_tools": self.external_fraud_tools,
|
436
|
-
"exemption_reason_3ds2": self.exemption_reason_3ds2,
|
437
|
-
"sca_exemption_reason": self.sca_exemption_reason,
|
438
|
-
"challenge_indicator": self.challenge_indicator,
|
439
|
-
"incremental": self.incremental,
|
440
|
-
"tax": self.tax,
|
441
|
-
}.to_json
|
442
|
-
end
|
443
|
-
|
444
|
-
# Fills the object with data coming from the API
|
445
|
-
# Params:
|
446
|
-
# +data+:: +Hash+ of data coming from the API
|
447
|
-
def fill_with_data(data)
|
448
|
-
if data.nil?
|
449
|
-
return self
|
450
|
-
end
|
451
|
-
if data.include? "id"
|
452
|
-
self.id = data["id"]
|
453
|
-
end
|
454
|
-
if data.include? "project"
|
455
|
-
self.project = data["project"]
|
456
|
-
end
|
457
|
-
if data.include? "project_id"
|
458
|
-
self.project_id = data["project_id"]
|
459
|
-
end
|
460
|
-
if data.include? "transaction"
|
461
|
-
self.transaction = data["transaction"]
|
462
|
-
end
|
463
|
-
if data.include? "transaction_id"
|
464
|
-
self.transaction_id = data["transaction_id"]
|
465
|
-
end
|
466
|
-
if data.include? "customer"
|
467
|
-
self.customer = data["customer"]
|
468
|
-
end
|
469
|
-
if data.include? "customer_id"
|
470
|
-
self.customer_id = data["customer_id"]
|
471
|
-
end
|
472
|
-
if data.include? "subscription"
|
473
|
-
self.subscription = data["subscription"]
|
474
|
-
end
|
475
|
-
if data.include? "subscription_id"
|
476
|
-
self.subscription_id = data["subscription_id"]
|
477
|
-
end
|
478
|
-
if data.include? "token"
|
479
|
-
self.token = data["token"]
|
480
|
-
end
|
481
|
-
if data.include? "token_id"
|
482
|
-
self.token_id = data["token_id"]
|
483
|
-
end
|
484
|
-
if data.include? "details"
|
485
|
-
self.details = data["details"]
|
486
|
-
end
|
487
|
-
if data.include? "url"
|
488
|
-
self.url = data["url"]
|
489
|
-
end
|
490
|
-
if data.include? "name"
|
491
|
-
self.name = data["name"]
|
492
|
-
end
|
493
|
-
if data.include? "amount"
|
494
|
-
self.amount = data["amount"]
|
495
|
-
end
|
496
|
-
if data.include? "currency"
|
497
|
-
self.currency = data["currency"]
|
498
|
-
end
|
499
|
-
if data.include? "merchant_initiator_type"
|
500
|
-
self.merchant_initiator_type = data["merchant_initiator_type"]
|
501
|
-
end
|
502
|
-
if data.include? "statement_descriptor"
|
503
|
-
self.statement_descriptor = data["statement_descriptor"]
|
504
|
-
end
|
505
|
-
if data.include? "statement_descriptor_phone"
|
506
|
-
self.statement_descriptor_phone = data["statement_descriptor_phone"]
|
507
|
-
end
|
508
|
-
if data.include? "statement_descriptor_city"
|
509
|
-
self.statement_descriptor_city = data["statement_descriptor_city"]
|
510
|
-
end
|
511
|
-
if data.include? "statement_descriptor_company"
|
512
|
-
self.statement_descriptor_company = data["statement_descriptor_company"]
|
513
|
-
end
|
514
|
-
if data.include? "statement_descriptor_url"
|
515
|
-
self.statement_descriptor_url = data["statement_descriptor_url"]
|
516
|
-
end
|
517
|
-
if data.include? "metadata"
|
518
|
-
self.metadata = data["metadata"]
|
519
|
-
end
|
520
|
-
if data.include? "gateway_data"
|
521
|
-
self.gateway_data = data["gateway_data"]
|
522
|
-
end
|
523
|
-
if data.include? "return_url"
|
524
|
-
self.return_url = data["return_url"]
|
525
|
-
end
|
526
|
-
if data.include? "cancel_url"
|
527
|
-
self.cancel_url = data["cancel_url"]
|
528
|
-
end
|
529
|
-
if data.include? "webhook_url"
|
530
|
-
self.webhook_url = data["webhook_url"]
|
531
|
-
end
|
532
|
-
if data.include? "require_backend_capture"
|
533
|
-
self.require_backend_capture = data["require_backend_capture"]
|
534
|
-
end
|
535
|
-
if data.include? "sandbox"
|
536
|
-
self.sandbox = data["sandbox"]
|
537
|
-
end
|
538
|
-
if data.include? "created_at"
|
539
|
-
self.created_at = data["created_at"]
|
540
|
-
end
|
541
|
-
if data.include? "risk"
|
542
|
-
self.risk = data["risk"]
|
543
|
-
end
|
544
|
-
if data.include? "shipping"
|
545
|
-
self.shipping = data["shipping"]
|
546
|
-
end
|
547
|
-
if data.include? "device"
|
548
|
-
self.device = data["device"]
|
549
|
-
end
|
550
|
-
if data.include? "external_fraud_tools"
|
551
|
-
self.external_fraud_tools = data["external_fraud_tools"]
|
552
|
-
end
|
553
|
-
if data.include? "exemption_reason_3ds2"
|
554
|
-
self.exemption_reason_3ds2 = data["exemption_reason_3ds2"]
|
555
|
-
end
|
556
|
-
if data.include? "sca_exemption_reason"
|
557
|
-
self.sca_exemption_reason = data["sca_exemption_reason"]
|
558
|
-
end
|
559
|
-
if data.include? "challenge_indicator"
|
560
|
-
self.challenge_indicator = data["challenge_indicator"]
|
561
|
-
end
|
562
|
-
if data.include? "incremental"
|
563
|
-
self.incremental = data["incremental"]
|
564
|
-
end
|
565
|
-
if data.include? "tax"
|
566
|
-
self.tax = data["tax"]
|
567
|
-
end
|
568
|
-
|
569
|
-
self
|
570
|
-
end
|
571
|
-
|
572
|
-
# Prefills the object with the data passed as parameters
|
573
|
-
# Params:
|
574
|
-
# +data+:: +Hash+ of data
|
575
|
-
def prefill(data)
|
576
|
-
if data.nil?
|
577
|
-
return self
|
578
|
-
end
|
579
|
-
self.id = data.fetch(:id, self.id)
|
580
|
-
self.project = data.fetch(:project, self.project)
|
581
|
-
self.project_id = data.fetch(:project_id, self.project_id)
|
582
|
-
self.transaction = data.fetch(:transaction, self.transaction)
|
583
|
-
self.transaction_id = data.fetch(:transaction_id, self.transaction_id)
|
584
|
-
self.customer = data.fetch(:customer, self.customer)
|
585
|
-
self.customer_id = data.fetch(:customer_id, self.customer_id)
|
586
|
-
self.subscription = data.fetch(:subscription, self.subscription)
|
587
|
-
self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
|
588
|
-
self.token = data.fetch(:token, self.token)
|
589
|
-
self.token_id = data.fetch(:token_id, self.token_id)
|
590
|
-
self.details = data.fetch(:details, self.details)
|
591
|
-
self.url = data.fetch(:url, self.url)
|
592
|
-
self.name = data.fetch(:name, self.name)
|
593
|
-
self.amount = data.fetch(:amount, self.amount)
|
594
|
-
self.currency = data.fetch(:currency, self.currency)
|
595
|
-
self.merchant_initiator_type = data.fetch(:merchant_initiator_type, self.merchant_initiator_type)
|
596
|
-
self.statement_descriptor = data.fetch(:statement_descriptor, self.statement_descriptor)
|
597
|
-
self.statement_descriptor_phone = data.fetch(:statement_descriptor_phone, self.statement_descriptor_phone)
|
598
|
-
self.statement_descriptor_city = data.fetch(:statement_descriptor_city, self.statement_descriptor_city)
|
599
|
-
self.statement_descriptor_company = data.fetch(:statement_descriptor_company, self.statement_descriptor_company)
|
600
|
-
self.statement_descriptor_url = data.fetch(:statement_descriptor_url, self.statement_descriptor_url)
|
601
|
-
self.metadata = data.fetch(:metadata, self.metadata)
|
602
|
-
self.gateway_data = data.fetch(:gateway_data, self.gateway_data)
|
603
|
-
self.return_url = data.fetch(:return_url, self.return_url)
|
604
|
-
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
605
|
-
self.webhook_url = data.fetch(:webhook_url, self.webhook_url)
|
606
|
-
self.require_backend_capture = data.fetch(:require_backend_capture, self.require_backend_capture)
|
607
|
-
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
608
|
-
self.created_at = data.fetch(:created_at, self.created_at)
|
609
|
-
self.risk = data.fetch(:risk, self.risk)
|
610
|
-
self.shipping = data.fetch(:shipping, self.shipping)
|
611
|
-
self.device = data.fetch(:device, self.device)
|
612
|
-
self.external_fraud_tools = data.fetch(:external_fraud_tools, self.external_fraud_tools)
|
613
|
-
self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, self.exemption_reason_3ds2)
|
614
|
-
self.sca_exemption_reason = data.fetch(:sca_exemption_reason, self.sca_exemption_reason)
|
615
|
-
self.challenge_indicator = data.fetch(:challenge_indicator, self.challenge_indicator)
|
616
|
-
self.incremental = data.fetch(:incremental, self.incremental)
|
617
|
-
self.tax = data.fetch(:tax, self.tax)
|
618
|
-
|
619
|
-
self
|
620
|
-
end
|
621
|
-
|
622
|
-
# Create an incremental authorization
|
623
|
-
# Params:
|
624
|
-
# +amount+:: Amount to increment authorization by
|
625
|
-
# +options+:: +Hash+ of options
|
626
|
-
def increment_authorization(amount, options = {})
|
627
|
-
self.prefill(options)
|
628
|
-
|
629
|
-
request = Request.new(@client)
|
630
|
-
path = "/invoices/" + CGI.escape(@id) + "/increment_authorization"
|
631
|
-
data = {
|
632
|
-
"amount" => amount
|
633
|
-
}
|
634
|
-
|
635
|
-
response = Response.new(request.post(path, data, options))
|
636
|
-
return_values = Array.new
|
637
|
-
|
638
|
-
body = response.body
|
639
|
-
body = body["transaction"]
|
640
|
-
transaction = Transaction.new(@client)
|
641
|
-
return_values.push(transaction.fill_with_data(body))
|
642
|
-
|
643
|
-
|
644
|
-
return_values[0]
|
645
|
-
end
|
646
|
-
|
647
|
-
# Authorize the invoice using the given source (customer or token)
|
648
|
-
# Params:
|
649
|
-
# +source+:: Source used to authorization the payment. Can be a card, a token or a gateway request
|
650
|
-
# +options+:: +Hash+ of options
|
651
|
-
def authorize(source, options = {})
|
652
|
-
self.prefill(options)
|
653
|
-
|
654
|
-
request = Request.new(@client)
|
655
|
-
path = "/invoices/" + CGI.escape(@id) + "/authorize"
|
656
|
-
data = {
|
657
|
-
"device" => @device,
|
658
|
-
"incremental" => @incremental,
|
659
|
-
"synchronous" => options.fetch(:synchronous, nil),
|
660
|
-
"retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
|
661
|
-
"capture_amount" => options.fetch(:capture_amount, nil),
|
662
|
-
"enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil),
|
663
|
-
"auto_capture_at" => options.fetch(:auto_capture_at, nil),
|
664
|
-
"source" => source
|
665
|
-
}
|
666
|
-
|
667
|
-
response = Response.new(request.post(path, data, options))
|
668
|
-
return_values = Array.new
|
669
|
-
|
670
|
-
body = response.body
|
671
|
-
body = body["transaction"]
|
672
|
-
transaction = Transaction.new(@client)
|
673
|
-
return_values.push(transaction.fill_with_data(body))
|
674
|
-
|
675
|
-
|
676
|
-
return_values[0]
|
677
|
-
end
|
678
|
-
|
679
|
-
# Capture the invoice using the given source (customer or token)
|
680
|
-
# Params:
|
681
|
-
# +source+:: Source used to authorization the payment. Can be a card, a token or a gateway request
|
682
|
-
# +options+:: +Hash+ of options
|
683
|
-
def capture(source, options = {})
|
684
|
-
self.prefill(options)
|
685
|
-
|
686
|
-
request = Request.new(@client)
|
687
|
-
path = "/invoices/" + CGI.escape(@id) + "/capture"
|
688
|
-
data = {
|
689
|
-
"device" => @device,
|
690
|
-
"incremental" => @incremental,
|
691
|
-
"authorize_only" => options.fetch(:authorize_only, nil),
|
692
|
-
"synchronous" => options.fetch(:synchronous, nil),
|
693
|
-
"retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
|
694
|
-
"capture_amount" => options.fetch(:capture_amount, nil),
|
695
|
-
"auto_capture_at" => options.fetch(:auto_capture_at, nil),
|
696
|
-
"enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil),
|
697
|
-
"source" => source
|
698
|
-
}
|
699
|
-
|
700
|
-
response = Response.new(request.post(path, data, options))
|
701
|
-
return_values = Array.new
|
702
|
-
|
703
|
-
body = response.body
|
704
|
-
body = body["transaction"]
|
705
|
-
transaction = Transaction.new(@client)
|
706
|
-
return_values.push(transaction.fill_with_data(body))
|
707
|
-
|
708
|
-
|
709
|
-
return_values[0]
|
710
|
-
end
|
711
|
-
|
712
|
-
# Get the customer linked to the invoice.
|
713
|
-
# Params:
|
714
|
-
# +options+:: +Hash+ of options
|
715
|
-
def fetch_customer(options = {})
|
716
|
-
self.prefill(options)
|
717
|
-
|
718
|
-
request = Request.new(@client)
|
719
|
-
path = "/invoices/" + CGI.escape(@id) + "/customers"
|
720
|
-
data = {
|
721
|
-
|
722
|
-
}
|
723
|
-
|
724
|
-
response = Response.new(request.get(path, data, options))
|
725
|
-
return_values = Array.new
|
726
|
-
|
727
|
-
body = response.body
|
728
|
-
body = body["customer"]
|
729
|
-
customer = Customer.new(@client)
|
730
|
-
return_values.push(customer.fill_with_data(body))
|
731
|
-
|
732
|
-
|
733
|
-
return_values[0]
|
734
|
-
end
|
735
|
-
|
736
|
-
# Assign a customer to the invoice.
|
737
|
-
# Params:
|
738
|
-
# +customer_id+:: ID of the customer to be linked to the invoice
|
739
|
-
# +options+:: +Hash+ of options
|
740
|
-
def assign_customer(customer_id, options = {})
|
741
|
-
self.prefill(options)
|
742
|
-
|
743
|
-
request = Request.new(@client)
|
744
|
-
path = "/invoices/" + CGI.escape(@id) + "/customers"
|
745
|
-
data = {
|
746
|
-
"customer_id" => customer_id
|
747
|
-
}
|
748
|
-
|
749
|
-
response = Response.new(request.post(path, data, options))
|
750
|
-
return_values = Array.new
|
751
|
-
|
752
|
-
body = response.body
|
753
|
-
body = body["customer"]
|
754
|
-
customer = Customer.new(@client)
|
755
|
-
return_values.push(customer.fill_with_data(body))
|
756
|
-
|
757
|
-
|
758
|
-
return_values[0]
|
759
|
-
end
|
760
|
-
|
761
|
-
# Initiate a 3-D Secure authentication
|
762
|
-
# Params:
|
763
|
-
# +source+:: Source used to initiate the 3-D Secure authentication. Can be a card, or a token representing a card
|
764
|
-
# +options+:: +Hash+ of options
|
765
|
-
def initiate_three_d_s(source, options = {})
|
766
|
-
self.prefill(options)
|
767
|
-
|
768
|
-
request = Request.new(@client)
|
769
|
-
path = "/invoices/" + CGI.escape(@id) + "/three-d-s"
|
770
|
-
data = {
|
771
|
-
"enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil),
|
772
|
-
"source" => source
|
773
|
-
}
|
774
|
-
|
775
|
-
response = Response.new(request.post(path, data, options))
|
776
|
-
return_values = Array.new
|
777
|
-
|
778
|
-
body = response.body
|
779
|
-
body = body["customer_action"]
|
780
|
-
customer_action = CustomerAction.new(@client)
|
781
|
-
return_values.push(customer_action.fill_with_data(body))
|
782
|
-
|
783
|
-
|
784
|
-
return_values[0]
|
785
|
-
end
|
786
|
-
|
787
|
-
# Get the transaction of the invoice.
|
788
|
-
# Params:
|
789
|
-
# +options+:: +Hash+ of options
|
790
|
-
def fetch_transaction(options = {})
|
791
|
-
self.prefill(options)
|
792
|
-
|
793
|
-
request = Request.new(@client)
|
794
|
-
path = "/invoices/" + CGI.escape(@id) + "/transactions"
|
795
|
-
data = {
|
796
|
-
|
797
|
-
}
|
798
|
-
|
799
|
-
response = Response.new(request.get(path, data, options))
|
800
|
-
return_values = Array.new
|
801
|
-
|
802
|
-
body = response.body
|
803
|
-
body = body["transaction"]
|
804
|
-
transaction = Transaction.new(@client)
|
805
|
-
return_values.push(transaction.fill_with_data(body))
|
806
|
-
|
807
|
-
|
808
|
-
return_values[0]
|
809
|
-
end
|
810
|
-
|
811
|
-
# Void the invoice
|
812
|
-
# Params:
|
813
|
-
# +options+:: +Hash+ of options
|
814
|
-
def void(options = {})
|
815
|
-
self.prefill(options)
|
816
|
-
|
817
|
-
request = Request.new(@client)
|
818
|
-
path = "/invoices/" + CGI.escape(@id) + "/void"
|
819
|
-
data = {
|
820
|
-
|
821
|
-
}
|
822
|
-
|
823
|
-
response = Response.new(request.post(path, data, options))
|
824
|
-
return_values = Array.new
|
825
|
-
|
826
|
-
body = response.body
|
827
|
-
body = body["transaction"]
|
828
|
-
transaction = Transaction.new(@client)
|
829
|
-
return_values.push(transaction.fill_with_data(body))
|
830
|
-
|
831
|
-
|
832
|
-
return_values[0]
|
833
|
-
end
|
834
|
-
|
835
|
-
# Get all the invoices.
|
836
|
-
# Params:
|
837
|
-
# +options+:: +Hash+ of options
|
838
|
-
def all(options = {})
|
839
|
-
self.prefill(options)
|
840
|
-
|
841
|
-
request = Request.new(@client)
|
842
|
-
path = "/invoices"
|
843
|
-
data = {
|
844
|
-
|
845
|
-
}
|
846
|
-
|
847
|
-
response = Response.new(request.get(path, data, options))
|
848
|
-
return_values = Array.new
|
849
|
-
|
850
|
-
a = Array.new
|
851
|
-
body = response.body
|
852
|
-
for v in body['invoices']
|
853
|
-
tmp = Invoice.new(@client)
|
854
|
-
tmp.fill_with_data(v)
|
855
|
-
a.push(tmp)
|
856
|
-
end
|
857
|
-
|
858
|
-
return_values.push(a)
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
return_values[0]
|
863
|
-
end
|
864
|
-
|
865
|
-
# Create a new invoice.
|
866
|
-
# Params:
|
867
|
-
# +options+:: +Hash+ of options
|
868
|
-
def create(options = {})
|
869
|
-
self.prefill(options)
|
870
|
-
|
871
|
-
request = Request.new(@client)
|
872
|
-
path = "/invoices"
|
873
|
-
data = {
|
874
|
-
"customer_id" => @customer_id,
|
875
|
-
"name" => @name,
|
876
|
-
"amount" => @amount,
|
877
|
-
"currency" => @currency,
|
878
|
-
"metadata" => @metadata,
|
879
|
-
"details" => @details,
|
880
|
-
"exemption_reason_3ds2" => @exemption_reason_3ds2,
|
881
|
-
"sca_exemption_reason" => @sca_exemption_reason,
|
882
|
-
"challenge_indicator" => @challenge_indicator,
|
883
|
-
"gateway_data" => @gateway_data,
|
884
|
-
"merchant_initiator_type" => @merchant_initiator_type,
|
885
|
-
"statement_descriptor" => @statement_descriptor,
|
886
|
-
"statement_descriptor_phone" => @statement_descriptor_phone,
|
887
|
-
"statement_descriptor_city" => @statement_descriptor_city,
|
888
|
-
"statement_descriptor_company" => @statement_descriptor_company,
|
889
|
-
"statement_descriptor_url" => @statement_descriptor_url,
|
890
|
-
"return_url" => @return_url,
|
891
|
-
"cancel_url" => @cancel_url,
|
892
|
-
"webhook_url" => @webhook_url,
|
893
|
-
"risk" => @risk,
|
894
|
-
"shipping" => @shipping,
|
895
|
-
"device" => @device,
|
896
|
-
"require_backend_capture" => @require_backend_capture,
|
897
|
-
"external_fraud_tools" => @external_fraud_tools,
|
898
|
-
"tax" => @tax
|
899
|
-
}
|
900
|
-
|
901
|
-
response = Response.new(request.post(path, data, options))
|
902
|
-
return_values = Array.new
|
903
|
-
|
904
|
-
body = response.body
|
905
|
-
body = body["invoice"]
|
906
|
-
|
907
|
-
|
908
|
-
return_values.push(self.fill_with_data(body))
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
return_values[0]
|
913
|
-
end
|
914
|
-
|
915
|
-
# Find an invoice by its ID.
|
916
|
-
# Params:
|
917
|
-
# +invoice_id+:: ID of the invoice
|
918
|
-
# +options+:: +Hash+ of options
|
919
|
-
def find(invoice_id, options = {})
|
920
|
-
self.prefill(options)
|
921
|
-
|
922
|
-
request = Request.new(@client)
|
923
|
-
path = "/invoices/" + CGI.escape(invoice_id) + ""
|
924
|
-
data = {
|
925
|
-
|
926
|
-
}
|
927
|
-
|
928
|
-
response = Response.new(request.get(path, data, options))
|
929
|
-
return_values = Array.new
|
930
|
-
|
931
|
-
body = response.body
|
932
|
-
body = body["invoice"]
|
933
|
-
|
934
|
-
|
935
|
-
obj = Invoice.new(@client)
|
936
|
-
return_values.push(obj.fill_with_data(body))
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
return_values[0]
|
941
|
-
end
|
942
|
-
|
943
|
-
|
944
|
-
end
|
945
|
-
end
|