processout 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  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 +36 -0
  7. data/lib/processout/card_information.rb +14 -0
  8. data/lib/processout/coupon.rb +20 -0
  9. data/lib/processout/customer.rb +34 -22
  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 -0
  14. data/lib/processout/gateway.rb +18 -0
  15. data/lib/processout/gateway_configuration.rb +18 -0
  16. data/lib/processout/invoice.rb +43 -1
  17. data/lib/processout/invoice_detail.rb +22 -0
  18. data/lib/processout/invoice_device.rb +9 -0
  19. data/lib/processout/invoice_risk.rb +9 -0
  20. data/lib/processout/invoice_shipping.rb +19 -0
  21. data/lib/processout/networking/request.rb +1 -1
  22. data/lib/processout/payment_data_network_authentication.rb +8 -0
  23. data/lib/processout/payment_data_three_ds_authentication.rb +8 -0
  24. data/lib/processout/payment_data_three_ds_request.rb +11 -0
  25. data/lib/processout/payout.rb +27 -0
  26. data/lib/processout/payout_item.rb +20 -0
  27. data/lib/processout/plan.rb +21 -0
  28. data/lib/processout/product.rb +19 -0
  29. data/lib/processout/project.rb +18 -27
  30. data/lib/processout/refund.rb +17 -0
  31. data/lib/processout/subscription.rb +42 -0
  32. data/lib/processout/token.rb +39 -33
  33. data/lib/processout/transaction.rb +57 -0
  34. data/lib/processout/transaction_operation.rb +52 -0
  35. data/lib/processout/version.rb +1 -1
  36. data/lib/processout/webhook.rb +21 -0
  37. data/lib/processout/webhook_endpoint.rb +14 -0
  38. metadata +2 -2
@@ -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
@@ -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,9 +18,9 @@ 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
23
24
  attr_reader :is_chargeable
24
25
  attr_reader :created_at
25
26
 
@@ -100,6 +101,10 @@ module ProcessOut
100
101
  @is_subscription_only = val
101
102
  end
102
103
 
104
+ def is_default=(val)
105
+ @is_default = val
106
+ end
107
+
103
108
  def return_url=(val)
104
109
  @return_url = val
105
110
  end
@@ -108,10 +113,6 @@ module ProcessOut
108
113
  @cancel_url = val
109
114
  end
110
115
 
111
- def is_default=(val)
112
- @is_default = val
113
- end
114
-
115
116
  def is_chargeable=(val)
116
117
  @is_chargeable = val
117
118
  end
@@ -138,9 +139,9 @@ module ProcessOut
138
139
  self.type = data.fetch(:type, nil)
139
140
  self.metadata = data.fetch(:metadata, nil)
140
141
  self.is_subscription_only = data.fetch(:is_subscription_only, nil)
142
+ self.is_default = data.fetch(:is_default, nil)
141
143
  self.return_url = data.fetch(:return_url, nil)
142
144
  self.cancel_url = data.fetch(:cancel_url, nil)
143
- self.is_default = data.fetch(:is_default, nil)
144
145
  self.is_chargeable = data.fetch(:is_chargeable, nil)
145
146
  self.created_at = data.fetch(:created_at, nil)
146
147
 
@@ -151,6 +152,27 @@ module ProcessOut
151
152
  Token.new(@client, data)
152
153
  end
153
154
 
155
+ # Overrides the JSON marshaller to only send the fields we want
156
+ def to_json(options)
157
+ {
158
+ "id": self.id,
159
+ "customer": self.customer,
160
+ "customer_id": self.customer_id,
161
+ "gateway_configuration": self.gateway_configuration,
162
+ "gateway_configuration_id": self.gateway_configuration_id,
163
+ "card": self.card,
164
+ "card_id": self.card_id,
165
+ "type": self.type,
166
+ "metadata": self.metadata,
167
+ "is_subscription_only": self.is_subscription_only,
168
+ "is_default": self.is_default,
169
+ "return_url": self.return_url,
170
+ "cancel_url": self.cancel_url,
171
+ "is_chargeable": self.is_chargeable,
172
+ "created_at": self.created_at,
173
+ }.to_json
174
+ end
175
+
154
176
  # Fills the object with data coming from the API
155
177
  # Params:
156
178
  # +data+:: +Hash+ of data coming from the API
@@ -188,15 +210,15 @@ module ProcessOut
188
210
  if data.include? "is_subscription_only"
189
211
  self.is_subscription_only = data["is_subscription_only"]
190
212
  end
213
+ if data.include? "is_default"
214
+ self.is_default = data["is_default"]
215
+ end
191
216
  if data.include? "return_url"
192
217
  self.return_url = data["return_url"]
193
218
  end
194
219
  if data.include? "cancel_url"
195
220
  self.cancel_url = data["cancel_url"]
196
221
  end
197
- if data.include? "is_default"
198
- self.is_default = data["is_default"]
199
- end
200
222
  if data.include? "is_chargeable"
201
223
  self.is_chargeable = data["is_chargeable"]
202
224
  end
@@ -224,36 +246,15 @@ module ProcessOut
224
246
  self.type = data.fetch(:type, self.type)
225
247
  self.metadata = data.fetch(:metadata, self.metadata)
226
248
  self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
249
+ self.is_default = data.fetch(:is_default, self.is_default)
227
250
  self.return_url = data.fetch(:return_url, self.return_url)
228
251
  self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
229
- self.is_default = data.fetch(:is_default, self.is_default)
230
252
  self.is_chargeable = data.fetch(:is_chargeable, self.is_chargeable)
231
253
  self.created_at = data.fetch(:created_at, self.created_at)
232
254
 
233
255
  self
234
256
  end
235
257
 
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
258
  # Get the customer's tokens.
258
259
  # Params:
259
260
  # +customer_id+:: ID of the customer
@@ -328,7 +329,7 @@ module ProcessOut
328
329
  "cancel_url" => @cancel_url,
329
330
  "source" => options.fetch(:source, nil),
330
331
  "settings" => options.fetch(:settings, nil),
331
- "target" => options.fetch(:target, nil),
332
+ "device" => options.fetch(:device, nil),
332
333
  "verify" => options.fetch(:verify, nil),
333
334
  "verify_metadata" => options.fetch(:verify_metadata, nil),
334
335
  "set_default" => options.fetch(:set_default, nil)
@@ -357,7 +358,12 @@ module ProcessOut
357
358
  request = Request.new(@client)
358
359
  path = "/customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
359
360
  data = {
360
-
361
+ "source" => options.fetch(:source, nil),
362
+ "settings" => options.fetch(:settings, nil),
363
+ "device" => options.fetch(:device, nil),
364
+ "verify" => options.fetch(:verify, nil),
365
+ "verify_metadata" => options.fetch(:verify_metadata, nil),
366
+ "set_default" => options.fetch(:set_default, nil)
361
367
  }
362
368
 
363
369
  response = Response.new(request.put(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
 
@@ -441,6 +442,62 @@ module ProcessOut
441
442
  Transaction.new(@client, data)
442
443
  end
443
444
 
445
+ # Overrides the JSON marshaller to only send the fields we want
446
+ def to_json(options)
447
+ {
448
+ "id": self.id,
449
+ "project": self.project,
450
+ "project_id": self.project_id,
451
+ "invoice": self.invoice,
452
+ "invoice_id": self.invoice_id,
453
+ "customer": self.customer,
454
+ "customer_id": self.customer_id,
455
+ "subscription": self.subscription,
456
+ "subscription_id": self.subscription_id,
457
+ "token": self.token,
458
+ "token_id": self.token_id,
459
+ "card": self.card,
460
+ "card_id": self.card_id,
461
+ "gateway_configuration": self.gateway_configuration,
462
+ "gateway_configuration_id": self.gateway_configuration_id,
463
+ "operations": self.operations,
464
+ "refunds": self.refunds,
465
+ "name": self.name,
466
+ "amount": self.amount,
467
+ "amount_local": self.amount_local,
468
+ "authorized_amount": self.authorized_amount,
469
+ "authorized_amount_local": self.authorized_amount_local,
470
+ "captured_amount": self.captured_amount,
471
+ "captured_amount_local": self.captured_amount_local,
472
+ "refunded_amount": self.refunded_amount,
473
+ "refunded_amount_local": self.refunded_amount_local,
474
+ "available_amount": self.available_amount,
475
+ "available_amount_local": self.available_amount_local,
476
+ "currency": self.currency,
477
+ "error_code": self.error_code,
478
+ "gateway_name": self.gateway_name,
479
+ "three_d_s_status": self.three_d_s_status,
480
+ "status": self.status,
481
+ "authorized": self.authorized,
482
+ "captured": self.captured,
483
+ "voided": self.voided,
484
+ "refunded": self.refunded,
485
+ "chargedback": self.chargedback,
486
+ "received_fraud_notification": self.received_fraud_notification,
487
+ "received_retrieval_request": self.received_retrieval_request,
488
+ "processout_fee": self.processout_fee,
489
+ "estimated_fee": self.estimated_fee,
490
+ "gateway_fee": self.gateway_fee,
491
+ "gateway_fee_local": self.gateway_fee_local,
492
+ "currency_fee": self.currency_fee,
493
+ "metadata": self.metadata,
494
+ "sandbox": self.sandbox,
495
+ "created_at": self.created_at,
496
+ "chargedback_at": self.chargedback_at,
497
+ "refunded_at": self.refunded_at,
498
+ }.to_json
499
+ end
500
+
444
501
  # Fills the object with data coming from the API
445
502
  # Params:
446
503
  # +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
 
@@ -17,11 +18,13 @@ module ProcessOut
17
18
  attr_reader :gateway_configuration
18
19
  attr_reader :gateway_configuration_id
19
20
  attr_reader :amount
21
+ attr_reader :currency
20
22
  attr_reader :is_attempt
21
23
  attr_reader :has_failed
22
24
  attr_reader :is_accountable
23
25
  attr_reader :type
24
26
  attr_reader :gateway_operation_id
27
+ attr_reader :arn
25
28
  attr_reader :error_code
26
29
  attr_reader :gateway_data
27
30
  attr_reader :payment_data_three_d_s_request
@@ -120,6 +123,10 @@ module ProcessOut
120
123
  @amount = val
121
124
  end
122
125
 
126
+ def currency=(val)
127
+ @currency = val
128
+ end
129
+
123
130
  def is_attempt=(val)
124
131
  @is_attempt = val
125
132
  end
@@ -140,6 +147,10 @@ module ProcessOut
140
147
  @gateway_operation_id = val
141
148
  end
142
149
 
150
+ def arn=(val)
151
+ @arn = val
152
+ end
153
+
143
154
  def error_code=(val)
144
155
  @error_code = val
145
156
  end
@@ -226,11 +237,13 @@ module ProcessOut
226
237
  self.gateway_configuration = data.fetch(:gateway_configuration, nil)
227
238
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, nil)
228
239
  self.amount = data.fetch(:amount, nil)
240
+ self.currency = data.fetch(:currency, nil)
229
241
  self.is_attempt = data.fetch(:is_attempt, nil)
230
242
  self.has_failed = data.fetch(:has_failed, nil)
231
243
  self.is_accountable = data.fetch(:is_accountable, nil)
232
244
  self.type = data.fetch(:type, nil)
233
245
  self.gateway_operation_id = data.fetch(:gateway_operation_id, nil)
246
+ self.arn = data.fetch(:arn, nil)
234
247
  self.error_code = data.fetch(:error_code, nil)
235
248
  self.gateway_data = data.fetch(:gateway_data, nil)
236
249
  self.payment_data_three_d_s_request = data.fetch(:payment_data_three_d_s_request, nil)
@@ -247,6 +260,37 @@ module ProcessOut
247
260
  TransactionOperation.new(@client, data)
248
261
  end
249
262
 
263
+ # Overrides the JSON marshaller to only send the fields we want
264
+ def to_json(options)
265
+ {
266
+ "id": self.id,
267
+ "transaction": self.transaction,
268
+ "transaction_id": self.transaction_id,
269
+ "token": self.token,
270
+ "token_id": self.token_id,
271
+ "card": self.card,
272
+ "card_id": self.card_id,
273
+ "gateway_configuration": self.gateway_configuration,
274
+ "gateway_configuration_id": self.gateway_configuration_id,
275
+ "amount": self.amount,
276
+ "currency": self.currency,
277
+ "is_attempt": self.is_attempt,
278
+ "has_failed": self.has_failed,
279
+ "is_accountable": self.is_accountable,
280
+ "type": self.type,
281
+ "gateway_operation_id": self.gateway_operation_id,
282
+ "arn": self.arn,
283
+ "error_code": self.error_code,
284
+ "gateway_data": self.gateway_data,
285
+ "payment_data_three_d_s_request": self.payment_data_three_d_s_request,
286
+ "payment_data_three_d_s_authentication": self.payment_data_three_d_s_authentication,
287
+ "payment_data_network_authentication": self.payment_data_network_authentication,
288
+ "metadata": self.metadata,
289
+ "gateway_fee": self.gateway_fee,
290
+ "created_at": self.created_at,
291
+ }.to_json
292
+ end
293
+
250
294
  # Fills the object with data coming from the API
251
295
  # Params:
252
296
  # +data+:: +Hash+ of data coming from the API
@@ -284,6 +328,9 @@ module ProcessOut
284
328
  if data.include? "amount"
285
329
  self.amount = data["amount"]
286
330
  end
331
+ if data.include? "currency"
332
+ self.currency = data["currency"]
333
+ end
287
334
  if data.include? "is_attempt"
288
335
  self.is_attempt = data["is_attempt"]
289
336
  end
@@ -299,6 +346,9 @@ module ProcessOut
299
346
  if data.include? "gateway_operation_id"
300
347
  self.gateway_operation_id = data["gateway_operation_id"]
301
348
  end
349
+ if data.include? "arn"
350
+ self.arn = data["arn"]
351
+ end
302
352
  if data.include? "error_code"
303
353
  self.error_code = data["error_code"]
304
354
  end
@@ -344,11 +394,13 @@ module ProcessOut
344
394
  self.gateway_configuration = data.fetch(:gateway_configuration, self.gateway_configuration)
345
395
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, self.gateway_configuration_id)
346
396
  self.amount = data.fetch(:amount, self.amount)
397
+ self.currency = data.fetch(:currency, self.currency)
347
398
  self.is_attempt = data.fetch(:is_attempt, self.is_attempt)
348
399
  self.has_failed = data.fetch(:has_failed, self.has_failed)
349
400
  self.is_accountable = data.fetch(:is_accountable, self.is_accountable)
350
401
  self.type = data.fetch(:type, self.type)
351
402
  self.gateway_operation_id = data.fetch(:gateway_operation_id, self.gateway_operation_id)
403
+ self.arn = data.fetch(:arn, self.arn)
352
404
  self.error_code = data.fetch(:error_code, self.error_code)
353
405
  self.gateway_data = data.fetch(:gateway_data, self.gateway_data)
354
406
  self.payment_data_three_d_s_request = data.fetch(:payment_data_three_d_s_request, self.payment_data_three_d_s_request)