processout 2.12.0 → 2.15.0

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 +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
 
@@ -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,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,8 +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
21
25
  attr_reader :is_chargeable
22
26
  attr_reader :created_at
27
+ attr_reader :description
28
+ attr_reader :invoice
29
+ attr_reader :invoice_id
23
30
 
24
31
 
25
32
  def id=(val)
@@ -102,6 +109,18 @@ module ProcessOut
102
109
  @is_default = val
103
110
  end
104
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
+
105
124
  def is_chargeable=(val)
106
125
  @is_chargeable = val
107
126
  end
@@ -110,6 +129,30 @@ module ProcessOut
110
129
  @created_at = val
111
130
  end
112
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
+
113
156
 
114
157
  # Initializes the Token object
115
158
  # Params:
@@ -129,8 +172,14 @@ module ProcessOut
129
172
  self.metadata = data.fetch(:metadata, nil)
130
173
  self.is_subscription_only = data.fetch(:is_subscription_only, nil)
131
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)
132
178
  self.is_chargeable = data.fetch(:is_chargeable, nil)
133
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)
134
183
 
135
184
  end
136
185
 
@@ -139,6 +188,31 @@ module ProcessOut
139
188
  Token.new(@client, data)
140
189
  end
141
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
+
142
216
  # Fills the object with data coming from the API
143
217
  # Params:
144
218
  # +data+:: +Hash+ of data coming from the API
@@ -179,12 +253,30 @@ module ProcessOut
179
253
  if data.include? "is_default"
180
254
  self.is_default = data["is_default"]
181
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
182
265
  if data.include? "is_chargeable"
183
266
  self.is_chargeable = data["is_chargeable"]
184
267
  end
185
268
  if data.include? "created_at"
186
269
  self.created_at = data["created_at"]
187
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
188
280
 
189
281
  self
190
282
  end
@@ -207,33 +299,18 @@ module ProcessOut
207
299
  self.metadata = data.fetch(:metadata, self.metadata)
208
300
  self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
209
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)
210
305
  self.is_chargeable = data.fetch(:is_chargeable, self.is_chargeable)
211
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)
212
310
 
213
311
  self
214
312
  end
215
313
 
216
- # Verify a customer token's card is valid.
217
- # Params:
218
- # +options+:: +Hash+ of options
219
- def verify(options = {})
220
- self.prefill(options)
221
-
222
- request = Request.new(@client)
223
- path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + "/verify"
224
- data = {
225
-
226
- }
227
-
228
- response = Response.new(request.post(path, data, options))
229
- return_values = Array.new
230
-
231
- return_values.push(response.success)
232
-
233
-
234
- return_values[0]
235
- end
236
-
237
314
  # Get the customer's tokens.
238
315
  # Params:
239
316
  # +customer_id+:: ID of the customer
@@ -304,9 +381,12 @@ module ProcessOut
304
381
  path = "/customers/" + CGI.escape(@customer_id) + "/tokens"
305
382
  data = {
306
383
  "metadata" => @metadata,
384
+ "return_url" => @return_url,
385
+ "cancel_url" => @cancel_url,
386
+ "description" => @description,
307
387
  "source" => options.fetch(:source, nil),
308
388
  "settings" => options.fetch(:settings, nil),
309
- "target" => options.fetch(:target, nil),
389
+ "device" => options.fetch(:device, nil),
310
390
  "verify" => options.fetch(:verify, nil),
311
391
  "verify_metadata" => options.fetch(:verify_metadata, nil),
312
392
  "set_default" => options.fetch(:set_default, nil)
@@ -335,7 +415,12 @@ module ProcessOut
335
415
  request = Request.new(@client)
336
416
  path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
337
417
  data = {
338
-
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)
339
424
  }
340
425
 
341
426
  response = Response.new(request.put(path, data, options))