processout 2.13.0 → 2.15.1

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/activity.rb +14 -0
  3. data/lib/processout/addon.rb +21 -0
  4. data/lib/processout/api_request.rb +21 -0
  5. data/lib/processout/api_version.rb +10 -0
  6. data/lib/processout/card.rb +79 -0
  7. data/lib/processout/card_information.rb +14 -0
  8. data/lib/processout/coupon.rb +20 -0
  9. data/lib/processout/customer.rb +62 -24
  10. data/lib/processout/customer_action.rb +9 -0
  11. data/lib/processout/discount.rb +21 -0
  12. data/lib/processout/dunning_action.rb +9 -0
  13. data/lib/processout/event.rb +14 -31
  14. data/lib/processout/gateway.rb +18 -0
  15. data/lib/processout/gateway_configuration.rb +18 -0
  16. data/lib/processout/invoice.rb +166 -2
  17. data/lib/processout/invoice_detail.rb +22 -0
  18. data/lib/processout/invoice_device.rb +20 -0
  19. data/lib/processout/invoice_external_fraud_tools.rb +70 -0
  20. data/lib/processout/invoice_risk.rb +9 -0
  21. data/lib/processout/invoice_shipping.rb +19 -0
  22. data/lib/processout/invoice_tax.rb +81 -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 +158 -0
  35. data/lib/processout/token.rb +93 -30
  36. data/lib/processout/transaction.rb +113 -0
  37. data/lib/processout/transaction_operation.rb +52 -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. data/lib/processout.rb +18 -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
 
@@ -121,6 +122,26 @@ module ProcessOut
121
122
  Plan.new(@client, data)
122
123
  end
123
124
 
125
+ # Overrides the JSON marshaller to only send the fields we want
126
+ def to_json(options)
127
+ {
128
+ "id": self.id,
129
+ "project": self.project,
130
+ "project_id": self.project_id,
131
+ "url": self.url,
132
+ "name": self.name,
133
+ "amount": self.amount,
134
+ "currency": self.currency,
135
+ "metadata": self.metadata,
136
+ "interval": self.interval,
137
+ "trial_period": self.trial_period,
138
+ "return_url": self.return_url,
139
+ "cancel_url": self.cancel_url,
140
+ "sandbox": self.sandbox,
141
+ "created_at": self.created_at,
142
+ }.to_json
143
+ end
144
+
124
145
  # Fills the object with data coming from the API
125
146
  # Params:
126
147
  # +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
 
@@ -109,6 +110,24 @@ module ProcessOut
109
110
  Product.new(@client, data)
110
111
  end
111
112
 
113
+ # Overrides the JSON marshaller to only send the fields we want
114
+ def to_json(options)
115
+ {
116
+ "id": self.id,
117
+ "project": self.project,
118
+ "project_id": self.project_id,
119
+ "url": self.url,
120
+ "name": self.name,
121
+ "amount": self.amount,
122
+ "currency": self.currency,
123
+ "metadata": self.metadata,
124
+ "return_url": self.return_url,
125
+ "cancel_url": self.cancel_url,
126
+ "sandbox": self.sandbox,
127
+ "created_at": self.created_at,
128
+ }.to_json
129
+ end
130
+
112
131
  # Fills the object with data coming from the API
113
132
  # Params:
114
133
  # +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
 
@@ -131,6 +132,23 @@ module ProcessOut
131
132
  Project.new(@client, data)
132
133
  end
133
134
 
135
+ # Overrides the JSON marshaller to only send the fields we want
136
+ def to_json(options)
137
+ {
138
+ "id": self.id,
139
+ "supervisor_project": self.supervisor_project,
140
+ "supervisor_project_id": self.supervisor_project_id,
141
+ "api_version": self.api_version,
142
+ "name": self.name,
143
+ "logo_url": self.logo_url,
144
+ "email": self.email,
145
+ "default_currency": self.default_currency,
146
+ "private_key": self.private_key,
147
+ "dunning_configuration": self.dunning_configuration,
148
+ "created_at": self.created_at,
149
+ }.to_json
150
+ end
151
+
134
152
  # Fills the object with data coming from the API
135
153
  # Params:
136
154
  # +data+:: +Hash+ of data coming from the API
@@ -197,33 +215,6 @@ module ProcessOut
197
215
  self
198
216
  end
199
217
 
200
- # Regenerate the project private key. Make sure to store the new private key and use it in any future request.
201
- # Params:
202
- # +options+:: +Hash+ of options
203
- def regenerate_private_key(options = {})
204
- self.prefill(options)
205
-
206
- request = Request.new(@client)
207
- path = "/private-keys"
208
- data = {
209
-
210
- }
211
-
212
- response = Response.new(request.post(path, data, options))
213
- return_values = Array.new
214
-
215
- body = response.body
216
- body = body["project"]
217
-
218
-
219
- obj = Project.new(@client)
220
- return_values.push(obj.fill_with_data(body))
221
-
222
-
223
-
224
- return_values[0]
225
- end
226
-
227
218
  # Fetch the current project information.
228
219
  # Params:
229
220
  # +options+:: +Hash+ of 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
 
@@ -97,6 +98,22 @@ module ProcessOut
97
98
  Refund.new(@client, data)
98
99
  end
99
100
 
101
+ # Overrides the JSON marshaller to only send the fields we want
102
+ def to_json(options)
103
+ {
104
+ "id": self.id,
105
+ "transaction": self.transaction,
106
+ "transaction_id": self.transaction_id,
107
+ "amount": self.amount,
108
+ "reason": self.reason,
109
+ "information": self.information,
110
+ "has_failed": self.has_failed,
111
+ "metadata": self.metadata,
112
+ "sandbox": self.sandbox,
113
+ "created_at": self.created_at,
114
+ }.to_json
115
+ end
116
+
100
117
  # Fills the object with data coming from the API
101
118
  # Params:
102
119
  # +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
 
@@ -331,6 +332,47 @@ module ProcessOut
331
332
  Subscription.new(@client, data)
332
333
  end
333
334
 
335
+ # Overrides the JSON marshaller to only send the fields we want
336
+ def to_json(options)
337
+ {
338
+ "id": self.id,
339
+ "project": self.project,
340
+ "project_id": self.project_id,
341
+ "plan": self.plan,
342
+ "plan_id": self.plan_id,
343
+ "discounts": self.discounts,
344
+ "addons": self.addons,
345
+ "transactions": self.transactions,
346
+ "customer": self.customer,
347
+ "customer_id": self.customer_id,
348
+ "token": self.token,
349
+ "token_id": self.token_id,
350
+ "url": self.url,
351
+ "name": self.name,
352
+ "amount": self.amount,
353
+ "billable_amount": self.billable_amount,
354
+ "discounted_amount": self.discounted_amount,
355
+ "addons_amount": self.addons_amount,
356
+ "currency": self.currency,
357
+ "metadata": self.metadata,
358
+ "interval": self.interval,
359
+ "trial_end_at": self.trial_end_at,
360
+ "activated": self.activated,
361
+ "active": self.active,
362
+ "cancel_at": self.cancel_at,
363
+ "canceled": self.canceled,
364
+ "cancellation_reason": self.cancellation_reason,
365
+ "pending_cancellation": self.pending_cancellation,
366
+ "return_url": self.return_url,
367
+ "cancel_url": self.cancel_url,
368
+ "unpaid_state": self.unpaid_state,
369
+ "sandbox": self.sandbox,
370
+ "created_at": self.created_at,
371
+ "activated_at": self.activated_at,
372
+ "iterate_at": self.iterate_at,
373
+ }.to_json
374
+ end
375
+
334
376
  # Fills the object with data coming from the API
335
377
  # Params:
336
378
  # +data+:: +Hash+ of data coming from the API
@@ -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
@@ -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
 
@@ -17,11 +18,15 @@ module ProcessOut
17
18
  attr_reader :type
18
19
  attr_reader :metadata
19
20
  attr_reader :is_subscription_only
21
+ attr_reader :is_default
20
22
  attr_reader :return_url
21
23
  attr_reader :cancel_url
22
- attr_reader :is_default
24
+ attr_reader :summary
23
25
  attr_reader :is_chargeable
24
26
  attr_reader :created_at
27
+ attr_reader :description
28
+ attr_reader :invoice
29
+ attr_reader :invoice_id
25
30
 
26
31
 
27
32
  def id=(val)
@@ -100,6 +105,10 @@ module ProcessOut
100
105
  @is_subscription_only = val
101
106
  end
102
107
 
108
+ def is_default=(val)
109
+ @is_default = val
110
+ end
111
+
103
112
  def return_url=(val)
104
113
  @return_url = val
105
114
  end
@@ -108,8 +117,8 @@ module ProcessOut
108
117
  @cancel_url = val
109
118
  end
110
119
 
111
- def is_default=(val)
112
- @is_default = val
120
+ def summary=(val)
121
+ @summary = val
113
122
  end
114
123
 
115
124
  def is_chargeable=(val)
@@ -120,6 +129,30 @@ module ProcessOut
120
129
  @created_at = val
121
130
  end
122
131
 
132
+ def description=(val)
133
+ @description = val
134
+ end
135
+
136
+ def invoice=(val)
137
+ if val.nil?
138
+ @invoice = val
139
+ return
140
+ end
141
+
142
+ if val.instance_of? Invoice
143
+ @invoice = val
144
+ else
145
+ obj = Invoice.new(@client)
146
+ obj.fill_with_data(val)
147
+ @invoice = obj
148
+ end
149
+
150
+ end
151
+
152
+ def invoice_id=(val)
153
+ @invoice_id = val
154
+ end
155
+
123
156
 
124
157
  # Initializes the Token object
125
158
  # Params:
@@ -138,11 +171,15 @@ module ProcessOut
138
171
  self.type = data.fetch(:type, nil)
139
172
  self.metadata = data.fetch(:metadata, nil)
140
173
  self.is_subscription_only = data.fetch(:is_subscription_only, nil)
174
+ self.is_default = data.fetch(:is_default, nil)
141
175
  self.return_url = data.fetch(:return_url, nil)
142
176
  self.cancel_url = data.fetch(:cancel_url, nil)
143
- self.is_default = data.fetch(:is_default, nil)
177
+ self.summary = data.fetch(:summary, nil)
144
178
  self.is_chargeable = data.fetch(:is_chargeable, nil)
145
179
  self.created_at = data.fetch(:created_at, nil)
180
+ self.description = data.fetch(:description, nil)
181
+ self.invoice = data.fetch(:invoice, nil)
182
+ self.invoice_id = data.fetch(:invoice_id, nil)
146
183
 
147
184
  end
148
185
 
@@ -151,6 +188,31 @@ module ProcessOut
151
188
  Token.new(@client, data)
152
189
  end
153
190
 
191
+ # Overrides the JSON marshaller to only send the fields we want
192
+ def to_json(options)
193
+ {
194
+ "id": self.id,
195
+ "customer": self.customer,
196
+ "customer_id": self.customer_id,
197
+ "gateway_configuration": self.gateway_configuration,
198
+ "gateway_configuration_id": self.gateway_configuration_id,
199
+ "card": self.card,
200
+ "card_id": self.card_id,
201
+ "type": self.type,
202
+ "metadata": self.metadata,
203
+ "is_subscription_only": self.is_subscription_only,
204
+ "is_default": self.is_default,
205
+ "return_url": self.return_url,
206
+ "cancel_url": self.cancel_url,
207
+ "summary": self.summary,
208
+ "is_chargeable": self.is_chargeable,
209
+ "created_at": self.created_at,
210
+ "description": self.description,
211
+ "invoice": self.invoice,
212
+ "invoice_id": self.invoice_id,
213
+ }.to_json
214
+ end
215
+
154
216
  # Fills the object with data coming from the API
155
217
  # Params:
156
218
  # +data+:: +Hash+ of data coming from the API
@@ -188,14 +250,17 @@ module ProcessOut
188
250
  if data.include? "is_subscription_only"
189
251
  self.is_subscription_only = data["is_subscription_only"]
190
252
  end
253
+ if data.include? "is_default"
254
+ self.is_default = data["is_default"]
255
+ end
191
256
  if data.include? "return_url"
192
257
  self.return_url = data["return_url"]
193
258
  end
194
259
  if data.include? "cancel_url"
195
260
  self.cancel_url = data["cancel_url"]
196
261
  end
197
- if data.include? "is_default"
198
- self.is_default = data["is_default"]
262
+ if data.include? "summary"
263
+ self.summary = data["summary"]
199
264
  end
200
265
  if data.include? "is_chargeable"
201
266
  self.is_chargeable = data["is_chargeable"]
@@ -203,6 +268,15 @@ module ProcessOut
203
268
  if data.include? "created_at"
204
269
  self.created_at = data["created_at"]
205
270
  end
271
+ if data.include? "description"
272
+ self.description = data["description"]
273
+ end
274
+ if data.include? "invoice"
275
+ self.invoice = data["invoice"]
276
+ end
277
+ if data.include? "invoice_id"
278
+ self.invoice_id = data["invoice_id"]
279
+ end
206
280
 
207
281
  self
208
282
  end
@@ -224,36 +298,19 @@ module ProcessOut
224
298
  self.type = data.fetch(:type, self.type)
225
299
  self.metadata = data.fetch(:metadata, self.metadata)
226
300
  self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
301
+ self.is_default = data.fetch(:is_default, self.is_default)
227
302
  self.return_url = data.fetch(:return_url, self.return_url)
228
303
  self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
229
- self.is_default = data.fetch(:is_default, self.is_default)
304
+ self.summary = data.fetch(:summary, self.summary)
230
305
  self.is_chargeable = data.fetch(:is_chargeable, self.is_chargeable)
231
306
  self.created_at = data.fetch(:created_at, self.created_at)
307
+ self.description = data.fetch(:description, self.description)
308
+ self.invoice = data.fetch(:invoice, self.invoice)
309
+ self.invoice_id = data.fetch(:invoice_id, self.invoice_id)
232
310
 
233
311
  self
234
312
  end
235
313
 
236
- # Verify a customer token's card is valid.
237
- # Params:
238
- # +options+:: +Hash+ of options
239
- def verify(options = {})
240
- self.prefill(options)
241
-
242
- request = Request.new(@client)
243
- path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + "/verify"
244
- data = {
245
-
246
- }
247
-
248
- response = Response.new(request.post(path, data, options))
249
- return_values = Array.new
250
-
251
- return_values.push(response.success)
252
-
253
-
254
- return_values[0]
255
- end
256
-
257
314
  # Get the customer's tokens.
258
315
  # Params:
259
316
  # +customer_id+:: ID of the customer
@@ -326,9 +383,10 @@ module ProcessOut
326
383
  "metadata" => @metadata,
327
384
  "return_url" => @return_url,
328
385
  "cancel_url" => @cancel_url,
386
+ "description" => @description,
329
387
  "source" => options.fetch(:source, nil),
330
388
  "settings" => options.fetch(:settings, nil),
331
- "target" => options.fetch(:target, nil),
389
+ "device" => options.fetch(:device, nil),
332
390
  "verify" => options.fetch(:verify, nil),
333
391
  "verify_metadata" => options.fetch(:verify_metadata, nil),
334
392
  "set_default" => options.fetch(:set_default, nil)
@@ -357,7 +415,12 @@ module ProcessOut
357
415
  request = Request.new(@client)
358
416
  path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
359
417
  data = {
360
-
418
+ "source" => options.fetch(:source, nil),
419
+ "settings" => options.fetch(:settings, nil),
420
+ "device" => options.fetch(:device, nil),
421
+ "verify" => options.fetch(:verify, nil),
422
+ "verify_metadata" => options.fetch(:verify_metadata, nil),
423
+ "set_default" => options.fetch(:set_default, nil)
361
424
  }
362
425
 
363
426
  response = Response.new(request.put(path, data, options))