processout 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +52 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Dockerfile +7 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/Makefile +4 -0
  9. data/README.md +12 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/processout/activity.rb +206 -0
  14. data/lib/processout/addon.rb +401 -0
  15. data/lib/processout/alternative_merchant_certificate.rb +115 -0
  16. data/lib/processout/api_request.rb +295 -0
  17. data/lib/processout/api_version.rb +92 -0
  18. data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
  19. data/lib/processout/balance.rb +92 -0
  20. data/lib/processout/balances.rb +111 -0
  21. data/lib/processout/card.rb +503 -0
  22. data/lib/processout/card_information.rb +164 -0
  23. data/lib/processout/coupon.rb +352 -0
  24. data/lib/processout/customer.rb +755 -0
  25. data/lib/processout/customer_action.rb +81 -0
  26. data/lib/processout/discount.rb +360 -0
  27. data/lib/processout/dunning_action.rb +81 -0
  28. data/lib/processout/errors/authentication_error.rb +9 -0
  29. data/lib/processout/errors/generic_error.rb +9 -0
  30. data/lib/processout/errors/internal_error.rb +9 -0
  31. data/lib/processout/errors/notfound_error.rb +9 -0
  32. data/lib/processout/errors/validation_error.rb +9 -0
  33. data/lib/processout/event.rb +237 -0
  34. data/lib/processout/gateway.rb +210 -0
  35. data/lib/processout/gateway_configuration.rb +346 -0
  36. data/lib/processout/gateway_request.rb +26 -0
  37. data/lib/processout/invoice.rb +984 -0
  38. data/lib/processout/invoice_detail.rb +235 -0
  39. data/lib/processout/invoice_device.rb +92 -0
  40. data/lib/processout/invoice_external_fraud_tools.rb +70 -0
  41. data/lib/processout/invoice_risk.rb +81 -0
  42. data/lib/processout/invoice_shipping.rb +202 -0
  43. data/lib/processout/invoice_tax.rb +81 -0
  44. data/lib/processout/networking/request.rb +102 -0
  45. data/lib/processout/networking/response.rb +67 -0
  46. data/lib/processout/payment_data_network_authentication.rb +70 -0
  47. data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
  48. data/lib/processout/payment_data_three_ds_request.rb +103 -0
  49. data/lib/processout/payout.rb +379 -0
  50. data/lib/processout/payout_item.rb +238 -0
  51. data/lib/processout/plan.rb +368 -0
  52. data/lib/processout/product.rb +368 -0
  53. data/lib/processout/project.rb +353 -0
  54. data/lib/processout/refund.rb +277 -0
  55. data/lib/processout/subscription.rb +910 -0
  56. data/lib/processout/three_ds.rb +158 -0
  57. data/lib/processout/token.rb +493 -0
  58. data/lib/processout/transaction.rb +905 -0
  59. data/lib/processout/transaction_operation.rb +418 -0
  60. data/lib/processout/version.rb +3 -0
  61. data/lib/processout/webhook.rb +237 -0
  62. data/lib/processout/webhook_endpoint.rb +149 -0
  63. data/lib/processout.rb +263 -0
  64. data/processout.gemspec +26 -0
  65. metadata +66 -3
@@ -0,0 +1,353 @@
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 Project
10
+
11
+ attr_reader :id
12
+ attr_reader :supervisor_project
13
+ attr_reader :supervisor_project_id
14
+ attr_reader :api_version
15
+ attr_reader :name
16
+ attr_reader :logo_url
17
+ attr_reader :email
18
+ attr_reader :default_currency
19
+ attr_reader :private_key
20
+ attr_reader :dunning_configuration
21
+ attr_reader :created_at
22
+
23
+
24
+ def id=(val)
25
+ @id = val
26
+ end
27
+
28
+ def supervisor_project=(val)
29
+ if val.nil?
30
+ @supervisor_project = val
31
+ return
32
+ end
33
+
34
+ if val.instance_of? Project
35
+ @supervisor_project = val
36
+ else
37
+ obj = Project.new(@client)
38
+ obj.fill_with_data(val)
39
+ @supervisor_project = obj
40
+ end
41
+
42
+ end
43
+
44
+ def supervisor_project_id=(val)
45
+ @supervisor_project_id = val
46
+ end
47
+
48
+ def api_version=(val)
49
+ if val.nil?
50
+ @api_version = val
51
+ return
52
+ end
53
+
54
+ if val.instance_of? APIVersion
55
+ @api_version = val
56
+ else
57
+ obj = APIVersion.new(@client)
58
+ obj.fill_with_data(val)
59
+ @api_version = obj
60
+ end
61
+
62
+ end
63
+
64
+ def name=(val)
65
+ @name = val
66
+ end
67
+
68
+ def logo_url=(val)
69
+ @logo_url = val
70
+ end
71
+
72
+ def email=(val)
73
+ @email = val
74
+ end
75
+
76
+ def default_currency=(val)
77
+ @default_currency = val
78
+ end
79
+
80
+ def private_key=(val)
81
+ @private_key = val
82
+ end
83
+
84
+ def dunning_configuration=(val)
85
+ if val.nil?
86
+ @dunning_configuration = []
87
+ return
88
+ end
89
+
90
+ if val.length > 0 and val[0].instance_of? DunningAction
91
+ @dunning_configuration = val
92
+ else
93
+ l = Array.new
94
+ for v in val
95
+ obj = DunningAction.new(@client)
96
+ obj.fill_with_data(v)
97
+ l.push(obj)
98
+ end
99
+ @dunning_configuration = l
100
+ end
101
+
102
+ end
103
+
104
+ def created_at=(val)
105
+ @created_at = val
106
+ end
107
+
108
+
109
+ # Initializes the Project object
110
+ # Params:
111
+ # +client+:: +ProcessOut+ client instance
112
+ # +data+:: data that can be used to fill the object
113
+ def initialize(client, data = {})
114
+ @client = client
115
+
116
+ self.id = data.fetch(:id, nil)
117
+ self.supervisor_project = data.fetch(:supervisor_project, nil)
118
+ self.supervisor_project_id = data.fetch(:supervisor_project_id, nil)
119
+ self.api_version = data.fetch(:api_version, nil)
120
+ self.name = data.fetch(:name, nil)
121
+ self.logo_url = data.fetch(:logo_url, nil)
122
+ self.email = data.fetch(:email, nil)
123
+ self.default_currency = data.fetch(:default_currency, nil)
124
+ self.private_key = data.fetch(:private_key, nil)
125
+ self.dunning_configuration = data.fetch(:dunning_configuration, nil)
126
+ self.created_at = data.fetch(:created_at, nil)
127
+
128
+ end
129
+
130
+ # Create a new Project using the current client
131
+ def new(data = {})
132
+ Project.new(@client, data)
133
+ end
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
+
152
+ # Fills the object with data coming from the API
153
+ # Params:
154
+ # +data+:: +Hash+ of data coming from the API
155
+ def fill_with_data(data)
156
+ if data.nil?
157
+ return self
158
+ end
159
+ if data.include? "id"
160
+ self.id = data["id"]
161
+ end
162
+ if data.include? "supervisor_project"
163
+ self.supervisor_project = data["supervisor_project"]
164
+ end
165
+ if data.include? "supervisor_project_id"
166
+ self.supervisor_project_id = data["supervisor_project_id"]
167
+ end
168
+ if data.include? "api_version"
169
+ self.api_version = data["api_version"]
170
+ end
171
+ if data.include? "name"
172
+ self.name = data["name"]
173
+ end
174
+ if data.include? "logo_url"
175
+ self.logo_url = data["logo_url"]
176
+ end
177
+ if data.include? "email"
178
+ self.email = data["email"]
179
+ end
180
+ if data.include? "default_currency"
181
+ self.default_currency = data["default_currency"]
182
+ end
183
+ if data.include? "private_key"
184
+ self.private_key = data["private_key"]
185
+ end
186
+ if data.include? "dunning_configuration"
187
+ self.dunning_configuration = data["dunning_configuration"]
188
+ end
189
+ if data.include? "created_at"
190
+ self.created_at = data["created_at"]
191
+ end
192
+
193
+ self
194
+ end
195
+
196
+ # Prefills the object with the data passed as parameters
197
+ # Params:
198
+ # +data+:: +Hash+ of data
199
+ def prefill(data)
200
+ if data.nil?
201
+ return self
202
+ end
203
+ self.id = data.fetch(:id, self.id)
204
+ self.supervisor_project = data.fetch(:supervisor_project, self.supervisor_project)
205
+ self.supervisor_project_id = data.fetch(:supervisor_project_id, self.supervisor_project_id)
206
+ self.api_version = data.fetch(:api_version, self.api_version)
207
+ self.name = data.fetch(:name, self.name)
208
+ self.logo_url = data.fetch(:logo_url, self.logo_url)
209
+ self.email = data.fetch(:email, self.email)
210
+ self.default_currency = data.fetch(:default_currency, self.default_currency)
211
+ self.private_key = data.fetch(:private_key, self.private_key)
212
+ self.dunning_configuration = data.fetch(:dunning_configuration, self.dunning_configuration)
213
+ self.created_at = data.fetch(:created_at, self.created_at)
214
+
215
+ self
216
+ end
217
+
218
+ # Fetch the current project information.
219
+ # Params:
220
+ # +options+:: +Hash+ of options
221
+ def fetch(options = {})
222
+ self.prefill(options)
223
+
224
+ request = Request.new(@client)
225
+ path = "/projects/" + CGI.escape(@id) + ""
226
+ data = {
227
+
228
+ }
229
+
230
+ response = Response.new(request.get(path, data, options))
231
+ return_values = Array.new
232
+
233
+ body = response.body
234
+ body = body["project"]
235
+
236
+
237
+ return_values.push(self.fill_with_data(body))
238
+
239
+
240
+
241
+ return_values[0]
242
+ end
243
+
244
+ # Save the updated project's attributes.
245
+ # Params:
246
+ # +options+:: +Hash+ of options
247
+ def save(options = {})
248
+ self.prefill(options)
249
+
250
+ request = Request.new(@client)
251
+ path = "/projects/" + CGI.escape(@id) + ""
252
+ data = {
253
+
254
+ }
255
+
256
+ response = Response.new(request.put(path, data, options))
257
+ return_values = Array.new
258
+
259
+ body = response.body
260
+ body = body["project"]
261
+
262
+
263
+ return_values.push(self.fill_with_data(body))
264
+
265
+
266
+
267
+ return_values[0]
268
+ end
269
+
270
+ # Delete the project. Be careful! Executing this request will prevent any further interaction with the API that uses this project.
271
+ # Params:
272
+ # +options+:: +Hash+ of options
273
+ def delete(options = {})
274
+ self.prefill(options)
275
+
276
+ request = Request.new(@client)
277
+ path = "/projects/{project_id}"
278
+ data = {
279
+
280
+ }
281
+
282
+ response = Response.new(request.delete(path, data, options))
283
+ return_values = Array.new
284
+
285
+ return_values.push(response.success)
286
+
287
+
288
+ return_values[0]
289
+ end
290
+
291
+ # Get all the supervised projects.
292
+ # Params:
293
+ # +options+:: +Hash+ of options
294
+ def fetch_supervised(options = {})
295
+ self.prefill(options)
296
+
297
+ request = Request.new(@client)
298
+ path = "/supervised-projects"
299
+ data = {
300
+
301
+ }
302
+
303
+ response = Response.new(request.get(path, data, options))
304
+ return_values = Array.new
305
+
306
+ a = Array.new
307
+ body = response.body
308
+ for v in body['projects']
309
+ tmp = Project.new(@client)
310
+ tmp.fill_with_data(v)
311
+ a.push(tmp)
312
+ end
313
+
314
+ return_values.push(a)
315
+
316
+
317
+
318
+ return_values[0]
319
+ end
320
+
321
+ # Create a new supervised project.
322
+ # Params:
323
+ # +options+:: +Hash+ of options
324
+ def create_supervised(options = {})
325
+ self.prefill(options)
326
+
327
+ request = Request.new(@client)
328
+ path = "/supervised-projects"
329
+ data = {
330
+ "id" => @id,
331
+ "name" => @name,
332
+ "default_currency" => @default_currency,
333
+ "dunning_configuration" => @dunning_configuration,
334
+ "applepay_settings" => options.fetch(:applepay_settings, nil)
335
+ }
336
+
337
+ response = Response.new(request.post(path, data, options))
338
+ return_values = Array.new
339
+
340
+ body = response.body
341
+ body = body["project"]
342
+
343
+
344
+ return_values.push(self.fill_with_data(body))
345
+
346
+
347
+
348
+ return_values[0]
349
+ end
350
+
351
+
352
+ end
353
+ end
@@ -0,0 +1,277 @@
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 Refund
10
+
11
+ attr_reader :id
12
+ attr_reader :transaction
13
+ attr_reader :transaction_id
14
+ attr_reader :amount
15
+ attr_reader :reason
16
+ attr_reader :information
17
+ attr_reader :has_failed
18
+ attr_reader :metadata
19
+ attr_reader :sandbox
20
+ attr_reader :created_at
21
+ attr_reader :invoice_detail_ids
22
+
23
+
24
+ def id=(val)
25
+ @id = val
26
+ end
27
+
28
+ def transaction=(val)
29
+ if val.nil?
30
+ @transaction = val
31
+ return
32
+ end
33
+
34
+ if val.instance_of? Transaction
35
+ @transaction = val
36
+ else
37
+ obj = Transaction.new(@client)
38
+ obj.fill_with_data(val)
39
+ @transaction = obj
40
+ end
41
+
42
+ end
43
+
44
+ def transaction_id=(val)
45
+ @transaction_id = val
46
+ end
47
+
48
+ def amount=(val)
49
+ @amount = val
50
+ end
51
+
52
+ def reason=(val)
53
+ @reason = val
54
+ end
55
+
56
+ def information=(val)
57
+ @information = val
58
+ end
59
+
60
+ def has_failed=(val)
61
+ @has_failed = val
62
+ end
63
+
64
+ def metadata=(val)
65
+ @metadata = val
66
+ end
67
+
68
+ def sandbox=(val)
69
+ @sandbox = val
70
+ end
71
+
72
+ def created_at=(val)
73
+ @created_at = val
74
+ end
75
+
76
+ def invoice_detail_ids=(val)
77
+ @invoice_detail_ids = val
78
+ end
79
+
80
+
81
+ # Initializes the Refund object
82
+ # Params:
83
+ # +client+:: +ProcessOut+ client instance
84
+ # +data+:: data that can be used to fill the object
85
+ def initialize(client, data = {})
86
+ @client = client
87
+
88
+ self.id = data.fetch(:id, nil)
89
+ self.transaction = data.fetch(:transaction, nil)
90
+ self.transaction_id = data.fetch(:transaction_id, nil)
91
+ self.amount = data.fetch(:amount, nil)
92
+ self.reason = data.fetch(:reason, nil)
93
+ self.information = data.fetch(:information, nil)
94
+ self.has_failed = data.fetch(:has_failed, nil)
95
+ self.metadata = data.fetch(:metadata, nil)
96
+ self.sandbox = data.fetch(:sandbox, nil)
97
+ self.created_at = data.fetch(:created_at, nil)
98
+ self.invoice_detail_ids = data.fetch(:invoice_detail_ids, nil)
99
+
100
+ end
101
+
102
+ # Create a new Refund using the current client
103
+ def new(data = {})
104
+ Refund.new(@client, data)
105
+ end
106
+
107
+ # Overrides the JSON marshaller to only send the fields we want
108
+ def to_json(options)
109
+ {
110
+ "id": self.id,
111
+ "transaction": self.transaction,
112
+ "transaction_id": self.transaction_id,
113
+ "amount": self.amount,
114
+ "reason": self.reason,
115
+ "information": self.information,
116
+ "has_failed": self.has_failed,
117
+ "metadata": self.metadata,
118
+ "sandbox": self.sandbox,
119
+ "created_at": self.created_at,
120
+ "invoice_detail_ids": self.invoice_detail_ids,
121
+ }.to_json
122
+ end
123
+
124
+ # Fills the object with data coming from the API
125
+ # Params:
126
+ # +data+:: +Hash+ of data coming from the API
127
+ def fill_with_data(data)
128
+ if data.nil?
129
+ return self
130
+ end
131
+ if data.include? "id"
132
+ self.id = data["id"]
133
+ end
134
+ if data.include? "transaction"
135
+ self.transaction = data["transaction"]
136
+ end
137
+ if data.include? "transaction_id"
138
+ self.transaction_id = data["transaction_id"]
139
+ end
140
+ if data.include? "amount"
141
+ self.amount = data["amount"]
142
+ end
143
+ if data.include? "reason"
144
+ self.reason = data["reason"]
145
+ end
146
+ if data.include? "information"
147
+ self.information = data["information"]
148
+ end
149
+ if data.include? "has_failed"
150
+ self.has_failed = data["has_failed"]
151
+ end
152
+ if data.include? "metadata"
153
+ self.metadata = data["metadata"]
154
+ end
155
+ if data.include? "sandbox"
156
+ self.sandbox = data["sandbox"]
157
+ end
158
+ if data.include? "created_at"
159
+ self.created_at = data["created_at"]
160
+ end
161
+ if data.include? "invoice_detail_ids"
162
+ self.invoice_detail_ids = data["invoice_detail_ids"]
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Prefills the object with the data passed as parameters
169
+ # Params:
170
+ # +data+:: +Hash+ of data
171
+ def prefill(data)
172
+ if data.nil?
173
+ return self
174
+ end
175
+ self.id = data.fetch(:id, self.id)
176
+ self.transaction = data.fetch(:transaction, self.transaction)
177
+ self.transaction_id = data.fetch(:transaction_id, self.transaction_id)
178
+ self.amount = data.fetch(:amount, self.amount)
179
+ self.reason = data.fetch(:reason, self.reason)
180
+ self.information = data.fetch(:information, self.information)
181
+ self.has_failed = data.fetch(:has_failed, self.has_failed)
182
+ self.metadata = data.fetch(:metadata, self.metadata)
183
+ self.sandbox = data.fetch(:sandbox, self.sandbox)
184
+ self.created_at = data.fetch(:created_at, self.created_at)
185
+ self.invoice_detail_ids = data.fetch(:invoice_detail_ids, self.invoice_detail_ids)
186
+
187
+ self
188
+ end
189
+
190
+ # Get the transaction's refunds.
191
+ # Params:
192
+ # +transaction_id+:: ID of the transaction
193
+ # +options+:: +Hash+ of options
194
+ def fetch_transaction_refunds(transaction_id, options = {})
195
+ self.prefill(options)
196
+
197
+ request = Request.new(@client)
198
+ path = "/transactions/" + CGI.escape(transaction_id) + "/refunds"
199
+ data = {
200
+
201
+ }
202
+
203
+ response = Response.new(request.get(path, data, options))
204
+ return_values = Array.new
205
+
206
+ a = Array.new
207
+ body = response.body
208
+ for v in body['refunds']
209
+ tmp = Refund.new(@client)
210
+ tmp.fill_with_data(v)
211
+ a.push(tmp)
212
+ end
213
+
214
+ return_values.push(a)
215
+
216
+
217
+
218
+ return_values[0]
219
+ end
220
+
221
+ # Find a transaction's refund by its ID.
222
+ # Params:
223
+ # +transaction_id+:: ID of the transaction on which the refund was applied
224
+ # +refund_id+:: ID of the refund
225
+ # +options+:: +Hash+ of options
226
+ def find(transaction_id, refund_id, options = {})
227
+ self.prefill(options)
228
+
229
+ request = Request.new(@client)
230
+ path = "/transactions/" + CGI.escape(transaction_id) + "/refunds/" + CGI.escape(refund_id) + ""
231
+ data = {
232
+
233
+ }
234
+
235
+ response = Response.new(request.get(path, data, options))
236
+ return_values = Array.new
237
+
238
+ body = response.body
239
+ body = body["refund"]
240
+
241
+
242
+ obj = Refund.new(@client)
243
+ return_values.push(obj.fill_with_data(body))
244
+
245
+
246
+
247
+ return_values[0]
248
+ end
249
+
250
+ # Create a refund for a transaction.
251
+ # Params:
252
+ # +options+:: +Hash+ of options
253
+ def create(options = {})
254
+ self.prefill(options)
255
+
256
+ request = Request.new(@client)
257
+ path = "/transactions/" + CGI.escape(@transaction_id) + "/refunds"
258
+ data = {
259
+ "amount" => @amount,
260
+ "reason" => @reason,
261
+ "information" => @information,
262
+ "invoice_detail_ids" => @invoice_detail_ids,
263
+ "metadata" => options.fetch(:metadata, nil)
264
+ }
265
+
266
+ response = Response.new(request.post(path, data, options))
267
+ return_values = Array.new
268
+
269
+ return_values.push(response.success)
270
+
271
+
272
+ return_values[0]
273
+ end
274
+
275
+
276
+ end
277
+ end