processout 2.11.0 → 2.14.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/lib/processout.rb +12 -6
  3. data/lib/processout/activity.rb +14 -0
  4. data/lib/processout/addon.rb +21 -0
  5. data/lib/processout/api_request.rb +21 -0
  6. data/lib/processout/api_version.rb +10 -0
  7. data/lib/processout/card.rb +79 -0
  8. data/lib/processout/card_information.rb +14 -0
  9. data/lib/processout/coupon.rb +20 -0
  10. data/lib/processout/customer.rb +62 -24
  11. data/lib/processout/customer_action.rb +9 -0
  12. data/lib/processout/discount.rb +21 -0
  13. data/lib/processout/dunning_action.rb +9 -0
  14. data/lib/processout/event.rb +14 -31
  15. data/lib/processout/gateway.rb +18 -0
  16. data/lib/processout/gateway_configuration.rb +19 -1
  17. data/lib/processout/invoice.rb +136 -1
  18. data/lib/processout/invoice_detail.rb +22 -0
  19. data/lib/processout/invoice_device.rb +20 -0
  20. data/lib/processout/invoice_external_fraud_tools.rb +70 -0
  21. data/lib/processout/invoice_risk.rb +9 -0
  22. data/lib/processout/invoice_shipping.rb +19 -0
  23. data/lib/processout/networking/request.rb +1 -1
  24. data/lib/processout/payment_data_network_authentication.rb +8 -0
  25. data/lib/processout/payment_data_three_ds_authentication.rb +8 -0
  26. data/lib/processout/payment_data_three_ds_request.rb +11 -0
  27. data/lib/processout/payout.rb +27 -0
  28. data/lib/processout/payout_item.rb +20 -0
  29. data/lib/processout/plan.rb +21 -0
  30. data/lib/processout/product.rb +19 -0
  31. data/lib/processout/project.rb +18 -27
  32. data/lib/processout/refund.rb +17 -0
  33. data/lib/processout/subscription.rb +42 -0
  34. data/lib/processout/three_ds.rb +103 -0
  35. data/lib/processout/token.rb +138 -22
  36. data/lib/processout/transaction.rb +113 -0
  37. data/lib/processout/transaction_operation.rb +94 -0
  38. data/lib/processout/version.rb +1 -1
  39. data/lib/processout/webhook.rb +21 -0
  40. data/lib/processout/webhook_endpoint.rb +14 -0
  41. metadata +5 -5
  42. data/lib/processout/authorization_request.rb +0 -320
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -37,6 +38,14 @@ module ProcessOut
37
38
  CustomerAction.new(@client, data)
38
39
  end
39
40
 
41
+ # Overrides the JSON marshaller to only send the fields we want
42
+ def to_json(options)
43
+ {
44
+ "type": self.type,
45
+ "value": self.value,
46
+ }.to_json
47
+ end
48
+
40
49
  # Fills the object with data coming from the API
41
50
  # Params:
42
51
  # +data+:: +Hash+ of data coming from the API
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -145,6 +146,26 @@ module ProcessOut
145
146
  Discount.new(@client, data)
146
147
  end
147
148
 
149
+ # Overrides the JSON marshaller to only send the fields we want
150
+ def to_json(options)
151
+ {
152
+ "id": self.id,
153
+ "project": self.project,
154
+ "project_id": self.project_id,
155
+ "subscription": self.subscription,
156
+ "subscription_id": self.subscription_id,
157
+ "coupon": self.coupon,
158
+ "coupon_id": self.coupon_id,
159
+ "name": self.name,
160
+ "amount": self.amount,
161
+ "percent": self.percent,
162
+ "expires_at": self.expires_at,
163
+ "metadata": self.metadata,
164
+ "sandbox": self.sandbox,
165
+ "created_at": self.created_at,
166
+ }.to_json
167
+ end
168
+
148
169
  # Fills the object with data coming from the API
149
170
  # Params:
150
171
  # +data+:: +Hash+ of data coming from the API
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -37,6 +38,14 @@ module ProcessOut
37
38
  DunningAction.new(@client, data)
38
39
  end
39
40
 
41
+ # Overrides the JSON marshaller to only send the fields we want
42
+ def to_json(options)
43
+ {
44
+ "action": self.action,
45
+ "delay_in_days": self.delay_in_days,
46
+ }.to_json
47
+ end
48
+
40
49
  # Fills the object with data coming from the API
41
50
  # Params:
42
51
  # +data+:: +Hash+ of data coming from the API
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -80,6 +81,19 @@ module ProcessOut
80
81
  Event.new(@client, data)
81
82
  end
82
83
 
84
+ # Overrides the JSON marshaller to only send the fields we want
85
+ def to_json(options)
86
+ {
87
+ "id": self.id,
88
+ "project": self.project,
89
+ "project_id": self.project_id,
90
+ "name": self.name,
91
+ "data": self.data,
92
+ "sandbox": self.sandbox,
93
+ "fired_at": self.fired_at,
94
+ }.to_json
95
+ end
96
+
83
97
  # Fills the object with data coming from the API
84
98
  # Params:
85
99
  # +data+:: +Hash+ of data coming from the API
@@ -215,37 +229,6 @@ module ProcessOut
215
229
 
216
230
 
217
231
 
218
- return_values[0]
219
- end
220
-
221
- # Find an event by the Resource ID that generated it.
222
- # Params:
223
- # +resource_id+:: Resource ID
224
- # +options+:: +Hash+ of options
225
- def find_by_resource_id(resource_id, options = {})
226
- self.prefill(options)
227
-
228
- request = Request.new(@client)
229
- path = "/events/by_resource_id/" + CGI.escape(resource_id) + ""
230
- data = {
231
-
232
- }
233
-
234
- response = Response.new(request.get(path, data, options))
235
- return_values = Array.new
236
-
237
- a = Array.new
238
- body = response.body
239
- for v in body['events']
240
- tmp = Event.new(@client)
241
- tmp.fill_with_data(v)
242
- a.push(tmp)
243
- end
244
-
245
- return_values.push(a)
246
-
247
-
248
-
249
232
  return_values[0]
250
233
  end
251
234
 
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -91,6 +92,23 @@ module ProcessOut
91
92
  Gateway.new(@client, data)
92
93
  end
93
94
 
95
+ # Overrides the JSON marshaller to only send the fields we want
96
+ def to_json(options)
97
+ {
98
+ "id": self.id,
99
+ "name": self.name,
100
+ "display_name": self.display_name,
101
+ "logo_url": self.logo_url,
102
+ "url": self.url,
103
+ "flows": self.flows,
104
+ "tags": self.tags,
105
+ "can_pull_transactions": self.can_pull_transactions,
106
+ "can_refund": self.can_refund,
107
+ "is_oauth_authentication": self.is_oauth_authentication,
108
+ "description": self.description,
109
+ }.to_json
110
+ end
111
+
94
112
  # Fills the object with data coming from the API
95
113
  # Params:
96
114
  # +data+:: +Hash+ of data coming from the API
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -115,6 +116,23 @@ module ProcessOut
115
116
  GatewayConfiguration.new(@client, data)
116
117
  end
117
118
 
119
+ # Overrides the JSON marshaller to only send the fields we want
120
+ def to_json(options)
121
+ {
122
+ "id": self.id,
123
+ "project": self.project,
124
+ "project_id": self.project_id,
125
+ "gateway": self.gateway,
126
+ "gateway_id": self.gateway_id,
127
+ "name": self.name,
128
+ "default_currency": self.default_currency,
129
+ "enabled": self.enabled,
130
+ "public_keys": self.public_keys,
131
+ "created_at": self.created_at,
132
+ "enabled_at": self.enabled_at,
133
+ }.to_json
134
+ end
135
+
118
136
  # Fills the object with data coming from the API
119
137
  # Params:
120
138
  # +data+:: +Hash+ of data coming from the API
@@ -190,7 +208,7 @@ module ProcessOut
190
208
  request = Request.new(@client)
191
209
  path = "/gateway-configurations"
192
210
  data = {
193
-
211
+ "expand_merchant_accounts" => options.fetch(:expand_merchant_accounts, nil)
194
212
  }
195
213
 
196
214
  response = Response.new(request.get(path, data, options))
@@ -1,6 +1,7 @@
1
1
  # The content of this file was automatically generated
2
2
 
3
3
  require "cgi"
4
+ require "json"
4
5
  require "processout/networking/request"
5
6
  require "processout/networking/response"
6
7
 
@@ -23,20 +24,27 @@ module ProcessOut
23
24
  attr_reader :name
24
25
  attr_reader :amount
25
26
  attr_reader :currency
27
+ attr_reader :merchant_initiator_type
26
28
  attr_reader :statement_descriptor
27
29
  attr_reader :statement_descriptor_phone
28
30
  attr_reader :statement_descriptor_city
29
31
  attr_reader :statement_descriptor_company
30
32
  attr_reader :statement_descriptor_url
31
33
  attr_reader :metadata
34
+ attr_reader :gateway_data
32
35
  attr_reader :return_url
33
36
  attr_reader :cancel_url
34
37
  attr_reader :webhook_url
38
+ attr_reader :require_backend_capture
35
39
  attr_reader :sandbox
36
40
  attr_reader :created_at
37
41
  attr_reader :risk
38
42
  attr_reader :shipping
39
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
40
48
 
41
49
 
42
50
  def id=(val)
@@ -179,6 +187,10 @@ module ProcessOut
179
187
  @currency = val
180
188
  end
181
189
 
190
+ def merchant_initiator_type=(val)
191
+ @merchant_initiator_type = val
192
+ end
193
+
182
194
  def statement_descriptor=(val)
183
195
  @statement_descriptor = val
184
196
  end
@@ -203,6 +215,10 @@ module ProcessOut
203
215
  @metadata = val
204
216
  end
205
217
 
218
+ def gateway_data=(val)
219
+ @gateway_data = val
220
+ end
221
+
206
222
  def return_url=(val)
207
223
  @return_url = val
208
224
  end
@@ -215,6 +231,10 @@ module ProcessOut
215
231
  @webhook_url = val
216
232
  end
217
233
 
234
+ def require_backend_capture=(val)
235
+ @require_backend_capture = val
236
+ end
237
+
218
238
  def sandbox=(val)
219
239
  @sandbox = val
220
240
  end
@@ -271,6 +291,34 @@ module ProcessOut
271
291
 
272
292
  end
273
293
 
294
+ def external_fraud_tools=(val)
295
+ if val.nil?
296
+ @external_fraud_tools = val
297
+ return
298
+ end
299
+
300
+ if val.instance_of? InvoiceExternalFraudTools
301
+ @external_fraud_tools = val
302
+ else
303
+ obj = InvoiceExternalFraudTools.new(@client)
304
+ obj.fill_with_data(val)
305
+ @external_fraud_tools = obj
306
+ end
307
+
308
+ end
309
+
310
+ def exemption_reason_3ds2=(val)
311
+ @exemption_reason_3ds2 = val
312
+ end
313
+
314
+ def sca_exemption_reason=(val)
315
+ @sca_exemption_reason = val
316
+ end
317
+
318
+ def challenge_indicator=(val)
319
+ @challenge_indicator = val
320
+ end
321
+
274
322
 
275
323
  # Initializes the Invoice object
276
324
  # Params:
@@ -295,20 +343,27 @@ module ProcessOut
295
343
  self.name = data.fetch(:name, nil)
296
344
  self.amount = data.fetch(:amount, nil)
297
345
  self.currency = data.fetch(:currency, nil)
346
+ self.merchant_initiator_type = data.fetch(:merchant_initiator_type, nil)
298
347
  self.statement_descriptor = data.fetch(:statement_descriptor, nil)
299
348
  self.statement_descriptor_phone = data.fetch(:statement_descriptor_phone, nil)
300
349
  self.statement_descriptor_city = data.fetch(:statement_descriptor_city, nil)
301
350
  self.statement_descriptor_company = data.fetch(:statement_descriptor_company, nil)
302
351
  self.statement_descriptor_url = data.fetch(:statement_descriptor_url, nil)
303
352
  self.metadata = data.fetch(:metadata, nil)
353
+ self.gateway_data = data.fetch(:gateway_data, nil)
304
354
  self.return_url = data.fetch(:return_url, nil)
305
355
  self.cancel_url = data.fetch(:cancel_url, nil)
306
356
  self.webhook_url = data.fetch(:webhook_url, nil)
357
+ self.require_backend_capture = data.fetch(:require_backend_capture, nil)
307
358
  self.sandbox = data.fetch(:sandbox, nil)
308
359
  self.created_at = data.fetch(:created_at, nil)
309
360
  self.risk = data.fetch(:risk, nil)
310
361
  self.shipping = data.fetch(:shipping, nil)
311
362
  self.device = data.fetch(:device, nil)
363
+ self.external_fraud_tools = data.fetch(:external_fraud_tools, nil)
364
+ self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, nil)
365
+ self.sca_exemption_reason = data.fetch(:sca_exemption_reason, nil)
366
+ self.challenge_indicator = data.fetch(:challenge_indicator, nil)
312
367
 
313
368
  end
314
369
 
@@ -317,6 +372,49 @@ module ProcessOut
317
372
  Invoice.new(@client, data)
318
373
  end
319
374
 
375
+ # Overrides the JSON marshaller to only send the fields we want
376
+ def to_json(options)
377
+ {
378
+ "id": self.id,
379
+ "project": self.project,
380
+ "project_id": self.project_id,
381
+ "transaction": self.transaction,
382
+ "transaction_id": self.transaction_id,
383
+ "customer": self.customer,
384
+ "customer_id": self.customer_id,
385
+ "subscription": self.subscription,
386
+ "subscription_id": self.subscription_id,
387
+ "token": self.token,
388
+ "token_id": self.token_id,
389
+ "details": self.details,
390
+ "url": self.url,
391
+ "name": self.name,
392
+ "amount": self.amount,
393
+ "currency": self.currency,
394
+ "merchant_initiator_type": self.merchant_initiator_type,
395
+ "statement_descriptor": self.statement_descriptor,
396
+ "statement_descriptor_phone": self.statement_descriptor_phone,
397
+ "statement_descriptor_city": self.statement_descriptor_city,
398
+ "statement_descriptor_company": self.statement_descriptor_company,
399
+ "statement_descriptor_url": self.statement_descriptor_url,
400
+ "metadata": self.metadata,
401
+ "gateway_data": self.gateway_data,
402
+ "return_url": self.return_url,
403
+ "cancel_url": self.cancel_url,
404
+ "webhook_url": self.webhook_url,
405
+ "require_backend_capture": self.require_backend_capture,
406
+ "sandbox": self.sandbox,
407
+ "created_at": self.created_at,
408
+ "risk": self.risk,
409
+ "shipping": self.shipping,
410
+ "device": self.device,
411
+ "external_fraud_tools": self.external_fraud_tools,
412
+ "exemption_reason_3ds2": self.exemption_reason_3ds2,
413
+ "sca_exemption_reason": self.sca_exemption_reason,
414
+ "challenge_indicator": self.challenge_indicator,
415
+ }.to_json
416
+ end
417
+
320
418
  # Fills the object with data coming from the API
321
419
  # Params:
322
420
  # +data+:: +Hash+ of data coming from the API
@@ -372,6 +470,9 @@ module ProcessOut
372
470
  if data.include? "currency"
373
471
  self.currency = data["currency"]
374
472
  end
473
+ if data.include? "merchant_initiator_type"
474
+ self.merchant_initiator_type = data["merchant_initiator_type"]
475
+ end
375
476
  if data.include? "statement_descriptor"
376
477
  self.statement_descriptor = data["statement_descriptor"]
377
478
  end
@@ -390,6 +491,9 @@ module ProcessOut
390
491
  if data.include? "metadata"
391
492
  self.metadata = data["metadata"]
392
493
  end
494
+ if data.include? "gateway_data"
495
+ self.gateway_data = data["gateway_data"]
496
+ end
393
497
  if data.include? "return_url"
394
498
  self.return_url = data["return_url"]
395
499
  end
@@ -399,6 +503,9 @@ module ProcessOut
399
503
  if data.include? "webhook_url"
400
504
  self.webhook_url = data["webhook_url"]
401
505
  end
506
+ if data.include? "require_backend_capture"
507
+ self.require_backend_capture = data["require_backend_capture"]
508
+ end
402
509
  if data.include? "sandbox"
403
510
  self.sandbox = data["sandbox"]
404
511
  end
@@ -414,6 +521,18 @@ module ProcessOut
414
521
  if data.include? "device"
415
522
  self.device = data["device"]
416
523
  end
524
+ if data.include? "external_fraud_tools"
525
+ self.external_fraud_tools = data["external_fraud_tools"]
526
+ end
527
+ if data.include? "exemption_reason_3ds2"
528
+ self.exemption_reason_3ds2 = data["exemption_reason_3ds2"]
529
+ end
530
+ if data.include? "sca_exemption_reason"
531
+ self.sca_exemption_reason = data["sca_exemption_reason"]
532
+ end
533
+ if data.include? "challenge_indicator"
534
+ self.challenge_indicator = data["challenge_indicator"]
535
+ end
417
536
 
418
537
  self
419
538
  end
@@ -441,20 +560,27 @@ module ProcessOut
441
560
  self.name = data.fetch(:name, self.name)
442
561
  self.amount = data.fetch(:amount, self.amount)
443
562
  self.currency = data.fetch(:currency, self.currency)
563
+ self.merchant_initiator_type = data.fetch(:merchant_initiator_type, self.merchant_initiator_type)
444
564
  self.statement_descriptor = data.fetch(:statement_descriptor, self.statement_descriptor)
445
565
  self.statement_descriptor_phone = data.fetch(:statement_descriptor_phone, self.statement_descriptor_phone)
446
566
  self.statement_descriptor_city = data.fetch(:statement_descriptor_city, self.statement_descriptor_city)
447
567
  self.statement_descriptor_company = data.fetch(:statement_descriptor_company, self.statement_descriptor_company)
448
568
  self.statement_descriptor_url = data.fetch(:statement_descriptor_url, self.statement_descriptor_url)
449
569
  self.metadata = data.fetch(:metadata, self.metadata)
570
+ self.gateway_data = data.fetch(:gateway_data, self.gateway_data)
450
571
  self.return_url = data.fetch(:return_url, self.return_url)
451
572
  self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
452
573
  self.webhook_url = data.fetch(:webhook_url, self.webhook_url)
574
+ self.require_backend_capture = data.fetch(:require_backend_capture, self.require_backend_capture)
453
575
  self.sandbox = data.fetch(:sandbox, self.sandbox)
454
576
  self.created_at = data.fetch(:created_at, self.created_at)
455
577
  self.risk = data.fetch(:risk, self.risk)
456
578
  self.shipping = data.fetch(:shipping, self.shipping)
457
579
  self.device = data.fetch(:device, self.device)
580
+ self.external_fraud_tools = data.fetch(:external_fraud_tools, self.external_fraud_tools)
581
+ self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, self.exemption_reason_3ds2)
582
+ self.sca_exemption_reason = data.fetch(:sca_exemption_reason, self.sca_exemption_reason)
583
+ self.challenge_indicator = data.fetch(:challenge_indicator, self.challenge_indicator)
458
584
 
459
585
  self
460
586
  end
@@ -469,6 +595,7 @@ module ProcessOut
469
595
  request = Request.new(@client)
470
596
  path = "/invoices/" + CGI.escape(@id) + "/authorize"
471
597
  data = {
598
+ "device" => @device,
472
599
  "synchronous" => options.fetch(:synchronous, nil),
473
600
  "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
474
601
  "capture_amount" => options.fetch(:capture_amount, nil),
@@ -499,6 +626,7 @@ module ProcessOut
499
626
  request = Request.new(@client)
500
627
  path = "/invoices/" + CGI.escape(@id) + "/capture"
501
628
  data = {
629
+ "device" => @device,
502
630
  "authorize_only" => options.fetch(:authorize_only, nil),
503
631
  "synchronous" => options.fetch(:synchronous, nil),
504
632
  "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
@@ -688,6 +816,11 @@ module ProcessOut
688
816
  "currency" => @currency,
689
817
  "metadata" => @metadata,
690
818
  "details" => @details,
819
+ "exemption_reason_3ds2" => @exemption_reason_3ds2,
820
+ "sca_exemption_reason" => @sca_exemption_reason,
821
+ "challenge_indicator" => @challenge_indicator,
822
+ "gateway_data" => @gateway_data,
823
+ "merchant_initiator_type" => @merchant_initiator_type,
691
824
  "statement_descriptor" => @statement_descriptor,
692
825
  "statement_descriptor_phone" => @statement_descriptor_phone,
693
826
  "statement_descriptor_city" => @statement_descriptor_city,
@@ -698,7 +831,9 @@ module ProcessOut
698
831
  "webhook_url" => @webhook_url,
699
832
  "risk" => @risk,
700
833
  "shipping" => @shipping,
701
- "device" => @device
834
+ "device" => @device,
835
+ "require_backend_capture" => @require_backend_capture,
836
+ "external_fraud_tools" => @external_fraud_tools
702
837
  }
703
838
 
704
839
  response = Response.new(request.post(path, data, options))