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
 
@@ -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,103 @@
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
+
16
+
17
+ def version=(val)
18
+ @version = val
19
+ end
20
+
21
+ def status=(val)
22
+ @status = val
23
+ end
24
+
25
+ def fingerprinted=(val)
26
+ @fingerprinted = val
27
+ end
28
+
29
+ def challenged=(val)
30
+ @challenged = val
31
+ end
32
+
33
+
34
+ # Initializes the ThreeDS object
35
+ # Params:
36
+ # +client+:: +ProcessOut+ client instance
37
+ # +data+:: data that can be used to fill the object
38
+ def initialize(client, data = {})
39
+ @client = client
40
+
41
+ self.version = data.fetch(:version, nil)
42
+ self.status = data.fetch(:status, nil)
43
+ self.fingerprinted = data.fetch(:fingerprinted, nil)
44
+ self.challenged = data.fetch(:challenged, nil)
45
+
46
+ end
47
+
48
+ # Create a new ThreeDS using the current client
49
+ def new(data = {})
50
+ ThreeDS.new(@client, data)
51
+ end
52
+
53
+ # Overrides the JSON marshaller to only send the fields we want
54
+ def to_json(options)
55
+ {
56
+ "Version": self.version,
57
+ "Status": self.status,
58
+ "fingerprinted": self.fingerprinted,
59
+ "challenged": self.challenged,
60
+ }.to_json
61
+ end
62
+
63
+ # Fills the object with data coming from the API
64
+ # Params:
65
+ # +data+:: +Hash+ of data coming from the API
66
+ def fill_with_data(data)
67
+ if data.nil?
68
+ return self
69
+ end
70
+ if data.include? "Version"
71
+ self.version = data["Version"]
72
+ end
73
+ if data.include? "Status"
74
+ self.status = data["Status"]
75
+ end
76
+ if data.include? "fingerprinted"
77
+ self.fingerprinted = data["fingerprinted"]
78
+ end
79
+ if data.include? "challenged"
80
+ self.challenged = data["challenged"]
81
+ end
82
+
83
+ self
84
+ end
85
+
86
+ # Prefills the object with the data passed as parameters
87
+ # Params:
88
+ # +data+:: +Hash+ of data
89
+ def prefill(data)
90
+ if data.nil?
91
+ return self
92
+ end
93
+ self.version = data.fetch(:version, self.version)
94
+ self.status = data.fetch(:status, self.status)
95
+ self.fingerprinted = data.fetch(:fingerprinted, self.fingerprinted)
96
+ self.challenged = data.fetch(:challenged, self.challenged)
97
+
98
+ self
99
+ end
100
+
101
+
102
+ end
103
+ 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
 
@@ -18,7 +19,14 @@ module ProcessOut
18
19
  attr_reader :metadata
19
20
  attr_reader :is_subscription_only
20
21
  attr_reader :is_default
22
+ attr_reader :return_url
23
+ attr_reader :cancel_url
24
+ attr_reader :summary
25
+ attr_reader :is_chargeable
21
26
  attr_reader :created_at
27
+ attr_reader :description
28
+ attr_reader :invoice
29
+ attr_reader :invoice_id
22
30
 
23
31
 
24
32
  def id=(val)
@@ -101,10 +109,50 @@ module ProcessOut
101
109
  @is_default = val
102
110
  end
103
111
 
112
+ def return_url=(val)
113
+ @return_url = val
114
+ end
115
+
116
+ def cancel_url=(val)
117
+ @cancel_url = val
118
+ end
119
+
120
+ def summary=(val)
121
+ @summary = val
122
+ end
123
+
124
+ def is_chargeable=(val)
125
+ @is_chargeable = val
126
+ end
127
+
104
128
  def created_at=(val)
105
129
  @created_at = val
106
130
  end
107
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
+
108
156
 
109
157
  # Initializes the Token object
110
158
  # Params:
@@ -124,7 +172,14 @@ module ProcessOut
124
172
  self.metadata = data.fetch(:metadata, nil)
125
173
  self.is_subscription_only = data.fetch(:is_subscription_only, nil)
126
174
  self.is_default = data.fetch(:is_default, nil)
175
+ self.return_url = data.fetch(:return_url, nil)
176
+ self.cancel_url = data.fetch(:cancel_url, nil)
177
+ self.summary = data.fetch(:summary, nil)
178
+ self.is_chargeable = data.fetch(:is_chargeable, nil)
127
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)
128
183
 
129
184
  end
130
185
 
@@ -133,6 +188,31 @@ module ProcessOut
133
188
  Token.new(@client, data)
134
189
  end
135
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
+
136
216
  # Fills the object with data coming from the API
137
217
  # Params:
138
218
  # +data+:: +Hash+ of data coming from the API
@@ -173,9 +253,30 @@ module ProcessOut
173
253
  if data.include? "is_default"
174
254
  self.is_default = data["is_default"]
175
255
  end
256
+ if data.include? "return_url"
257
+ self.return_url = data["return_url"]
258
+ end
259
+ if data.include? "cancel_url"
260
+ self.cancel_url = data["cancel_url"]
261
+ end
262
+ if data.include? "summary"
263
+ self.summary = data["summary"]
264
+ end
265
+ if data.include? "is_chargeable"
266
+ self.is_chargeable = data["is_chargeable"]
267
+ end
176
268
  if data.include? "created_at"
177
269
  self.created_at = data["created_at"]
178
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
179
280
 
180
281
  self
181
282
  end
@@ -198,32 +299,18 @@ module ProcessOut
198
299
  self.metadata = data.fetch(:metadata, self.metadata)
199
300
  self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
200
301
  self.is_default = data.fetch(:is_default, self.is_default)
302
+ self.return_url = data.fetch(:return_url, self.return_url)
303
+ self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
304
+ self.summary = data.fetch(:summary, self.summary)
305
+ self.is_chargeable = data.fetch(:is_chargeable, self.is_chargeable)
201
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)
202
310
 
203
311
  self
204
312
  end
205
313
 
206
- # Verify a customer token's card is valid.
207
- # Params:
208
- # +options+:: +Hash+ of options
209
- def verify(options = {})
210
- self.prefill(options)
211
-
212
- request = Request.new(@client)
213
- path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + "/verify"
214
- data = {
215
-
216
- }
217
-
218
- response = Response.new(request.post(path, data, options))
219
- return_values = Array.new
220
-
221
- return_values.push(response.success)
222
-
223
-
224
- return_values[0]
225
- end
226
-
227
314
  # Get the customer's tokens.
228
315
  # Params:
229
316
  # +customer_id+:: ID of the customer
@@ -294,9 +381,12 @@ module ProcessOut
294
381
  path = "/customers/" + CGI.escape(@customer_id) + "/tokens"
295
382
  data = {
296
383
  "metadata" => @metadata,
384
+ "return_url" => @return_url,
385
+ "cancel_url" => @cancel_url,
386
+ "description" => @description,
297
387
  "source" => options.fetch(:source, nil),
298
388
  "settings" => options.fetch(:settings, nil),
299
- "target" => options.fetch(:target, nil),
389
+ "device" => options.fetch(:device, nil),
300
390
  "verify" => options.fetch(:verify, nil),
301
391
  "verify_metadata" => options.fetch(:verify_metadata, nil),
302
392
  "set_default" => options.fetch(:set_default, nil)
@@ -313,6 +403,32 @@ module ProcessOut
313
403
 
314
404
 
315
405
 
406
+ return_values[0]
407
+ end
408
+
409
+ # Save the updated customer attributes.
410
+ # Params:
411
+ # +options+:: +Hash+ of options
412
+ def save(options = {})
413
+ self.prefill(options)
414
+
415
+ request = Request.new(@client)
416
+ path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
417
+ data = {
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)
424
+ }
425
+
426
+ response = Response.new(request.put(path, data, options))
427
+ return_values = Array.new
428
+
429
+ return_values.push(response.success)
430
+
431
+
316
432
  return_values[0]
317
433
  end
318
434