processout 2.12.0 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/lib/processout.rb +18 -0
  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 +187 -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/invoice_tax.rb +81 -0
  24. data/lib/processout/networking/request.rb +1 -1
  25. data/lib/processout/payment_data_network_authentication.rb +8 -0
  26. data/lib/processout/payment_data_three_ds_authentication.rb +8 -0
  27. data/lib/processout/payment_data_three_ds_request.rb +11 -0
  28. data/lib/processout/payout.rb +27 -0
  29. data/lib/processout/payout_item.rb +20 -0
  30. data/lib/processout/plan.rb +21 -0
  31. data/lib/processout/product.rb +19 -0
  32. data/lib/processout/project.rb +18 -27
  33. data/lib/processout/refund.rb +17 -0
  34. data/lib/processout/subscription.rb +42 -0
  35. data/lib/processout/three_ds.rb +103 -0
  36. data/lib/processout/token.rb +108 -23
  37. data/lib/processout/transaction.rb +113 -0
  38. data/lib/processout/transaction_operation.rb +84 -0
  39. data/lib/processout/version.rb +1 -1
  40. data/lib/processout/webhook.rb +21 -0
  41. data/lib/processout/webhook_endpoint.rb +14 -0
  42. metadata +6 -4
@@ -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
 
@@ -30,14 +31,22 @@ module ProcessOut
30
31
  attr_reader :statement_descriptor_company
31
32
  attr_reader :statement_descriptor_url
32
33
  attr_reader :metadata
34
+ attr_reader :gateway_data
33
35
  attr_reader :return_url
34
36
  attr_reader :cancel_url
35
37
  attr_reader :webhook_url
38
+ attr_reader :require_backend_capture
36
39
  attr_reader :sandbox
37
40
  attr_reader :created_at
38
41
  attr_reader :risk
39
42
  attr_reader :shipping
40
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
41
50
 
42
51
 
43
52
  def id=(val)
@@ -208,6 +217,10 @@ module ProcessOut
208
217
  @metadata = val
209
218
  end
210
219
 
220
+ def gateway_data=(val)
221
+ @gateway_data = val
222
+ end
223
+
211
224
  def return_url=(val)
212
225
  @return_url = val
213
226
  end
@@ -220,6 +233,10 @@ module ProcessOut
220
233
  @webhook_url = val
221
234
  end
222
235
 
236
+ def require_backend_capture=(val)
237
+ @require_backend_capture = val
238
+ end
239
+
223
240
  def sandbox=(val)
224
241
  @sandbox = val
225
242
  end
@@ -276,6 +293,54 @@ module ProcessOut
276
293
 
277
294
  end
278
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
+
279
344
 
280
345
  # Initializes the Invoice object
281
346
  # Params:
@@ -307,14 +372,22 @@ module ProcessOut
307
372
  self.statement_descriptor_company = data.fetch(:statement_descriptor_company, nil)
308
373
  self.statement_descriptor_url = data.fetch(:statement_descriptor_url, nil)
309
374
  self.metadata = data.fetch(:metadata, nil)
375
+ self.gateway_data = data.fetch(:gateway_data, nil)
310
376
  self.return_url = data.fetch(:return_url, nil)
311
377
  self.cancel_url = data.fetch(:cancel_url, nil)
312
378
  self.webhook_url = data.fetch(:webhook_url, nil)
379
+ self.require_backend_capture = data.fetch(:require_backend_capture, nil)
313
380
  self.sandbox = data.fetch(:sandbox, nil)
314
381
  self.created_at = data.fetch(:created_at, nil)
315
382
  self.risk = data.fetch(:risk, nil)
316
383
  self.shipping = data.fetch(:shipping, nil)
317
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)
318
391
 
319
392
  end
320
393
 
@@ -323,6 +396,51 @@ module ProcessOut
323
396
  Invoice.new(@client, data)
324
397
  end
325
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
+
326
444
  # Fills the object with data coming from the API
327
445
  # Params:
328
446
  # +data+:: +Hash+ of data coming from the API
@@ -399,6 +517,9 @@ module ProcessOut
399
517
  if data.include? "metadata"
400
518
  self.metadata = data["metadata"]
401
519
  end
520
+ if data.include? "gateway_data"
521
+ self.gateway_data = data["gateway_data"]
522
+ end
402
523
  if data.include? "return_url"
403
524
  self.return_url = data["return_url"]
404
525
  end
@@ -408,6 +529,9 @@ module ProcessOut
408
529
  if data.include? "webhook_url"
409
530
  self.webhook_url = data["webhook_url"]
410
531
  end
532
+ if data.include? "require_backend_capture"
533
+ self.require_backend_capture = data["require_backend_capture"]
534
+ end
411
535
  if data.include? "sandbox"
412
536
  self.sandbox = data["sandbox"]
413
537
  end
@@ -423,6 +547,24 @@ module ProcessOut
423
547
  if data.include? "device"
424
548
  self.device = data["device"]
425
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
426
568
 
427
569
  self
428
570
  end
@@ -457,18 +599,51 @@ module ProcessOut
457
599
  self.statement_descriptor_company = data.fetch(:statement_descriptor_company, self.statement_descriptor_company)
458
600
  self.statement_descriptor_url = data.fetch(:statement_descriptor_url, self.statement_descriptor_url)
459
601
  self.metadata = data.fetch(:metadata, self.metadata)
602
+ self.gateway_data = data.fetch(:gateway_data, self.gateway_data)
460
603
  self.return_url = data.fetch(:return_url, self.return_url)
461
604
  self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
462
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)
463
607
  self.sandbox = data.fetch(:sandbox, self.sandbox)
464
608
  self.created_at = data.fetch(:created_at, self.created_at)
465
609
  self.risk = data.fetch(:risk, self.risk)
466
610
  self.shipping = data.fetch(:shipping, self.shipping)
467
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)
468
618
 
469
619
  self
470
620
  end
471
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
+
472
647
  # Authorize the invoice using the given source (customer or token)
473
648
  # Params:
474
649
  # +source+:: Source used to authorization the payment. Can be a card, a token or a gateway request
@@ -479,6 +654,8 @@ module ProcessOut
479
654
  request = Request.new(@client)
480
655
  path = "/invoices/" + CGI.escape(@id) + "/authorize"
481
656
  data = {
657
+ "device" => @device,
658
+ "incremental" => @incremental,
482
659
  "synchronous" => options.fetch(:synchronous, nil),
483
660
  "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
484
661
  "capture_amount" => options.fetch(:capture_amount, nil),
@@ -509,6 +686,8 @@ module ProcessOut
509
686
  request = Request.new(@client)
510
687
  path = "/invoices/" + CGI.escape(@id) + "/capture"
511
688
  data = {
689
+ "device" => @device,
690
+ "incremental" => @incremental,
512
691
  "authorize_only" => options.fetch(:authorize_only, nil),
513
692
  "synchronous" => options.fetch(:synchronous, nil),
514
693
  "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
@@ -698,6 +877,10 @@ module ProcessOut
698
877
  "currency" => @currency,
699
878
  "metadata" => @metadata,
700
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,
701
884
  "merchant_initiator_type" => @merchant_initiator_type,
702
885
  "statement_descriptor" => @statement_descriptor,
703
886
  "statement_descriptor_phone" => @statement_descriptor_phone,
@@ -709,7 +892,10 @@ module ProcessOut
709
892
  "webhook_url" => @webhook_url,
710
893
  "risk" => @risk,
711
894
  "shipping" => @shipping,
712
- "device" => @device
895
+ "device" => @device,
896
+ "require_backend_capture" => @require_backend_capture,
897
+ "external_fraud_tools" => @external_fraud_tools,
898
+ "tax" => @tax
713
899
  }
714
900
 
715
901
  response = Response.new(request.post(path, data, options))