processout 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/processout/activity.rb +30 -6
- data/lib/processout/authorization_request.rb +44 -22
- data/lib/processout/card.rb +40 -13
- data/lib/processout/coupon.rb +50 -13
- data/lib/processout/customer.rb +66 -25
- data/lib/processout/customer_action.rb +18 -2
- data/lib/processout/discount.rb +38 -9
- data/lib/processout/event.rb +32 -6
- data/lib/processout/gateway.rb +30 -8
- data/lib/processout/gateway_configuration.rb +24 -5
- data/lib/processout/invoice.rb +66 -16
- data/lib/processout/plan.rb +50 -14
- data/lib/processout/product.rb +52 -13
- data/lib/processout/project.rb +26 -5
- data/lib/processout/refund.rb +34 -8
- data/lib/processout/subscription.rb +107 -37
- data/lib/processout/token.rb +38 -8
- data/lib/processout/transaction.rb +56 -17
- data/lib/processout/version.rb +1 -1
- data/lib/processout/webhook.rb +38 -12
- metadata +3 -3
data/lib/processout/project.rb
CHANGED
@@ -42,11 +42,11 @@ module ProcessOut
|
|
42
42
|
def initialize(client, data = {})
|
43
43
|
@client = client
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
self.id = data.fetch(:id, nil)
|
46
|
+
self.name = data.fetch(:name, nil)
|
47
|
+
self.logo_url = data.fetch(:logo_url, nil)
|
48
|
+
self.email = data.fetch(:email, nil)
|
49
|
+
self.created_at = data.fetch(:created_at, nil)
|
50
50
|
|
51
51
|
end
|
52
52
|
|
@@ -59,6 +59,9 @@ module ProcessOut
|
|
59
59
|
# Params:
|
60
60
|
# +data+:: +Hash+ of data coming from the API
|
61
61
|
def fill_with_data(data)
|
62
|
+
if data.nil?
|
63
|
+
return self
|
64
|
+
end
|
62
65
|
if data.include? "id"
|
63
66
|
self.id = data["id"]
|
64
67
|
end
|
@@ -78,10 +81,28 @@ module ProcessOut
|
|
78
81
|
self
|
79
82
|
end
|
80
83
|
|
84
|
+
# Prefills the object with the data passed as Parameters
|
85
|
+
# Params:
|
86
|
+
# +data+:: +Hash+ of data
|
87
|
+
def prefill(data)
|
88
|
+
if data.nil?
|
89
|
+
return self
|
90
|
+
end
|
91
|
+
self.id = data.fetch(:id, self.id)
|
92
|
+
self.name = data.fetch(:name, self.name)
|
93
|
+
self.logo_url = data.fetch(:logo_url, self.logo_url)
|
94
|
+
self.email = data.fetch(:email, self.email)
|
95
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
96
|
+
|
97
|
+
self
|
98
|
+
end
|
99
|
+
|
81
100
|
# Get all the gateway configurations of the project
|
82
101
|
# Params:
|
83
102
|
# +options+:: +Hash+ of options
|
84
103
|
def fetch_gateway_configurations(options = {})
|
104
|
+
self.prefill(options)
|
105
|
+
|
85
106
|
request = Request.new(@client)
|
86
107
|
path = "/projects/" + CGI.escape(@id) + "/gateway-configurations"
|
87
108
|
data = {
|
data/lib/processout/refund.rb
CHANGED
@@ -64,14 +64,14 @@ module ProcessOut
|
|
64
64
|
def initialize(client, data = {})
|
65
65
|
@client = client
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
self.id = data.fetch(:id, nil)
|
68
|
+
self.transaction = data.fetch(:transaction, nil)
|
69
|
+
self.reason = data.fetch(:reason, nil)
|
70
|
+
self.information = data.fetch(:information, nil)
|
71
|
+
self.amount = data.fetch(:amount, nil)
|
72
|
+
self.metadata = data.fetch(:metadata, nil)
|
73
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
74
|
+
self.created_at = data.fetch(:created_at, nil)
|
75
75
|
|
76
76
|
end
|
77
77
|
|
@@ -84,6 +84,9 @@ module ProcessOut
|
|
84
84
|
# Params:
|
85
85
|
# +data+:: +Hash+ of data coming from the API
|
86
86
|
def fill_with_data(data)
|
87
|
+
if data.nil?
|
88
|
+
return self
|
89
|
+
end
|
87
90
|
if data.include? "id"
|
88
91
|
self.id = data["id"]
|
89
92
|
end
|
@@ -112,12 +115,33 @@ module ProcessOut
|
|
112
115
|
self
|
113
116
|
end
|
114
117
|
|
118
|
+
# Prefills the object with the data passed as Parameters
|
119
|
+
# Params:
|
120
|
+
# +data+:: +Hash+ of data
|
121
|
+
def prefill(data)
|
122
|
+
if data.nil?
|
123
|
+
return self
|
124
|
+
end
|
125
|
+
self.id = data.fetch(:id, self.id)
|
126
|
+
self.transaction = data.fetch(:transaction, self.transaction)
|
127
|
+
self.reason = data.fetch(:reason, self.reason)
|
128
|
+
self.information = data.fetch(:information, self.information)
|
129
|
+
self.amount = data.fetch(:amount, self.amount)
|
130
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
131
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
132
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
133
|
+
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
115
137
|
# Find a transaction's refund by its ID.
|
116
138
|
# Params:
|
117
139
|
# +transaction_id+:: ID of the transaction on which the refund was applied
|
118
140
|
# +refund_id+:: ID of the refund
|
119
141
|
# +options+:: +Hash+ of options
|
120
142
|
def find(transaction_id, refund_id, options = {})
|
143
|
+
self.prefill(options)
|
144
|
+
|
121
145
|
request = Request.new(@client)
|
122
146
|
path = "/transactions/" + CGI.escape(transaction_id) + "/refunds/" + CGI.escape(refund_id) + ""
|
123
147
|
data = {
|
@@ -144,6 +168,8 @@ module ProcessOut
|
|
144
168
|
# +transaction_id+:: ID of the transaction
|
145
169
|
# +options+:: +Hash+ of options
|
146
170
|
def apply(transaction_id, options = {})
|
171
|
+
self.prefill(options)
|
172
|
+
|
147
173
|
request = Request.new(@client)
|
148
174
|
path = "/transactions/" + CGI.escape(transaction_id) + "/refunds"
|
149
175
|
data = {
|
@@ -165,30 +165,30 @@ module ProcessOut
|
|
165
165
|
def initialize(client, data = {})
|
166
166
|
@client = client
|
167
167
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
168
|
+
self.id = data.fetch(:id, nil)
|
169
|
+
self.project = data.fetch(:project, nil)
|
170
|
+
self.plan = data.fetch(:plan, nil)
|
171
|
+
self.customer = data.fetch(:customer, nil)
|
172
|
+
self.token = data.fetch(:token, nil)
|
173
|
+
self.url = data.fetch(:url, nil)
|
174
|
+
self.name = data.fetch(:name, nil)
|
175
|
+
self.amount = data.fetch(:amount, nil)
|
176
|
+
self.currency = data.fetch(:currency, nil)
|
177
|
+
self.metadata = data.fetch(:metadata, nil)
|
178
|
+
self.interval = data.fetch(:interval, nil)
|
179
|
+
self.trial_end_at = data.fetch(:trial_end_at, nil)
|
180
|
+
self.activated = data.fetch(:activated, nil)
|
181
|
+
self.active = data.fetch(:active, nil)
|
182
|
+
self.canceled = data.fetch(:canceled, nil)
|
183
|
+
self.cancellation_reason = data.fetch(:cancellation_reason, nil)
|
184
|
+
self.pending_cancellation = data.fetch(:pending_cancellation, nil)
|
185
|
+
self.cancel_at = data.fetch(:cancel_at, nil)
|
186
|
+
self.return_url = data.fetch(:return_url, nil)
|
187
|
+
self.cancel_url = data.fetch(:cancel_url, nil)
|
188
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
189
|
+
self.created_at = data.fetch(:created_at, nil)
|
190
|
+
self.activated_at = data.fetch(:activated_at, nil)
|
191
|
+
self.iterate_at = data.fetch(:iterate_at, nil)
|
192
192
|
|
193
193
|
end
|
194
194
|
|
@@ -201,6 +201,9 @@ module ProcessOut
|
|
201
201
|
# Params:
|
202
202
|
# +data+:: +Hash+ of data coming from the API
|
203
203
|
def fill_with_data(data)
|
204
|
+
if data.nil?
|
205
|
+
return self
|
206
|
+
end
|
204
207
|
if data.include? "id"
|
205
208
|
self.id = data["id"]
|
206
209
|
end
|
@@ -277,10 +280,47 @@ module ProcessOut
|
|
277
280
|
self
|
278
281
|
end
|
279
282
|
|
283
|
+
# Prefills the object with the data passed as Parameters
|
284
|
+
# Params:
|
285
|
+
# +data+:: +Hash+ of data
|
286
|
+
def prefill(data)
|
287
|
+
if data.nil?
|
288
|
+
return self
|
289
|
+
end
|
290
|
+
self.id = data.fetch(:id, self.id)
|
291
|
+
self.project = data.fetch(:project, self.project)
|
292
|
+
self.plan = data.fetch(:plan, self.plan)
|
293
|
+
self.customer = data.fetch(:customer, self.customer)
|
294
|
+
self.token = data.fetch(:token, self.token)
|
295
|
+
self.url = data.fetch(:url, self.url)
|
296
|
+
self.name = data.fetch(:name, self.name)
|
297
|
+
self.amount = data.fetch(:amount, self.amount)
|
298
|
+
self.currency = data.fetch(:currency, self.currency)
|
299
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
300
|
+
self.interval = data.fetch(:interval, self.interval)
|
301
|
+
self.trial_end_at = data.fetch(:trial_end_at, self.trial_end_at)
|
302
|
+
self.activated = data.fetch(:activated, self.activated)
|
303
|
+
self.active = data.fetch(:active, self.active)
|
304
|
+
self.canceled = data.fetch(:canceled, self.canceled)
|
305
|
+
self.cancellation_reason = data.fetch(:cancellation_reason, self.cancellation_reason)
|
306
|
+
self.pending_cancellation = data.fetch(:pending_cancellation, self.pending_cancellation)
|
307
|
+
self.cancel_at = data.fetch(:cancel_at, self.cancel_at)
|
308
|
+
self.return_url = data.fetch(:return_url, self.return_url)
|
309
|
+
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
310
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
311
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
312
|
+
self.activated_at = data.fetch(:activated_at, self.activated_at)
|
313
|
+
self.iterate_at = data.fetch(:iterate_at, self.iterate_at)
|
314
|
+
|
315
|
+
self
|
316
|
+
end
|
317
|
+
|
280
318
|
# Get the customer owning the subscription.
|
281
319
|
# Params:
|
282
320
|
# +options+:: +Hash+ of options
|
283
321
|
def fetch_customer(options = {})
|
322
|
+
self.prefill(options)
|
323
|
+
|
284
324
|
request = Request.new(@client)
|
285
325
|
path = "/subscriptions/" + CGI.escape(@id) + "/customers"
|
286
326
|
data = {
|
@@ -303,6 +343,8 @@ module ProcessOut
|
|
303
343
|
# Params:
|
304
344
|
# +options+:: +Hash+ of options
|
305
345
|
def fetch_discounts(options = {})
|
346
|
+
self.prefill(options)
|
347
|
+
|
306
348
|
request = Request.new(@client)
|
307
349
|
path = "/subscriptions/" + CGI.escape(@id) + "/discounts"
|
308
350
|
data = {
|
@@ -332,6 +374,8 @@ module ProcessOut
|
|
332
374
|
# +coupon_id+:: ID of the coupon
|
333
375
|
# +options+:: +Hash+ of options
|
334
376
|
def apply_coupon(coupon_id, options = {})
|
377
|
+
self.prefill(options)
|
378
|
+
|
335
379
|
request = Request.new(@client)
|
336
380
|
path = "/subscriptions/" + CGI.escape(@id) + "/discounts"
|
337
381
|
data = {
|
@@ -355,6 +399,8 @@ module ProcessOut
|
|
355
399
|
# +discount_id+:: ID of the discount
|
356
400
|
# +options+:: +Hash+ of options
|
357
401
|
def find_discount(discount_id, options = {})
|
402
|
+
self.prefill(options)
|
403
|
+
|
358
404
|
request = Request.new(@client)
|
359
405
|
path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + ""
|
360
406
|
data = {
|
@@ -378,6 +424,8 @@ module ProcessOut
|
|
378
424
|
# +discount_id+:: ID of the discount or coupon to be removed from the subscription
|
379
425
|
# +options+:: +Hash+ of options
|
380
426
|
def remove_discount(discount_id, options = {})
|
427
|
+
self.prefill(options)
|
428
|
+
|
381
429
|
request = Request.new(@client)
|
382
430
|
path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + ""
|
383
431
|
data = {
|
@@ -402,6 +450,8 @@ module ProcessOut
|
|
402
450
|
# Params:
|
403
451
|
# +options+:: +Hash+ of options
|
404
452
|
def fetch_transactions(options = {})
|
453
|
+
self.prefill(options)
|
454
|
+
|
405
455
|
request = Request.new(@client)
|
406
456
|
path = "/subscriptions/" + CGI.escape(@id) + "/transactions"
|
407
457
|
data = {
|
@@ -430,6 +480,8 @@ module ProcessOut
|
|
430
480
|
# Params:
|
431
481
|
# +options+:: +Hash+ of options
|
432
482
|
def all(options = {})
|
483
|
+
self.prefill(options)
|
484
|
+
|
433
485
|
request = Request.new(@client)
|
434
486
|
path = "/subscriptions"
|
435
487
|
data = {
|
@@ -459,6 +511,8 @@ module ProcessOut
|
|
459
511
|
# +customer_id+:: ID of the customer
|
460
512
|
# +options+:: +Hash+ of options
|
461
513
|
def create(customer_id, options = {})
|
514
|
+
self.prefill(options)
|
515
|
+
|
462
516
|
request = Request.new(@client)
|
463
517
|
path = "/subscriptions"
|
464
518
|
data = {
|
@@ -494,6 +548,8 @@ module ProcessOut
|
|
494
548
|
# +plan_id+:: ID of the plan
|
495
549
|
# +options+:: +Hash+ of options
|
496
550
|
def create_from_plan(customer_id, plan_id, options = {})
|
551
|
+
self.prefill(options)
|
552
|
+
|
497
553
|
request = Request.new(@client)
|
498
554
|
path = "/subscriptions"
|
499
555
|
data = {
|
@@ -529,6 +585,8 @@ module ProcessOut
|
|
529
585
|
# +subscription_id+:: ID of the subscription
|
530
586
|
# +options+:: +Hash+ of options
|
531
587
|
def find(subscription_id, options = {})
|
588
|
+
self.prefill(options)
|
589
|
+
|
532
590
|
request = Request.new(@client)
|
533
591
|
path = "/subscriptions/" + CGI.escape(subscription_id) + ""
|
534
592
|
data = {
|
@@ -550,15 +608,18 @@ module ProcessOut
|
|
550
608
|
return_values[0]
|
551
609
|
end
|
552
610
|
|
553
|
-
# Update the subscription.
|
611
|
+
# Update the subscription's plan.
|
554
612
|
# Params:
|
613
|
+
# +plan_id+:: ID of the new plan to be applied on the subscription
|
555
614
|
# +prorate+:: Define if proration should be done when updating the plan
|
556
615
|
# +options+:: +Hash+ of options
|
557
|
-
def
|
616
|
+
def update_plan(plan_id, prorate, options = {})
|
617
|
+
self.prefill(options)
|
618
|
+
|
558
619
|
request = Request.new(@client)
|
559
620
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
560
621
|
data = {
|
561
|
-
"
|
622
|
+
"plan_id" => plan_id,
|
562
623
|
"prorate" => prorate
|
563
624
|
}
|
564
625
|
|
@@ -576,17 +637,17 @@ module ProcessOut
|
|
576
637
|
return_values[0]
|
577
638
|
end
|
578
639
|
|
579
|
-
#
|
640
|
+
# Apply a source to the subscription to activate or update the subscription's source.
|
580
641
|
# Params:
|
581
|
-
# +
|
582
|
-
# +prorate+:: Define if proration should be done when updating the plan
|
642
|
+
# +source+:: Source to be applied on the subscription and used to pay future invoices. Can be a card, a token or a gateway request
|
583
643
|
# +options+:: +Hash+ of options
|
584
|
-
def
|
644
|
+
def apply_source(source, options = {})
|
645
|
+
self.prefill(options)
|
646
|
+
|
585
647
|
request = Request.new(@client)
|
586
648
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
587
649
|
data = {
|
588
|
-
"
|
589
|
-
"prorate" => prorate
|
650
|
+
"source" => source
|
590
651
|
}
|
591
652
|
|
592
653
|
response = Response.new(request.put(path, data, options))
|
@@ -603,15 +664,20 @@ module ProcessOut
|
|
603
664
|
return_values[0]
|
604
665
|
end
|
605
666
|
|
606
|
-
#
|
667
|
+
# Save the updated subscription attributes.
|
607
668
|
# Params:
|
608
|
-
# +source+:: Source to be applied on the subscription and used to pay future invoices. Can be a card, a token or a gateway request
|
609
669
|
# +options+:: +Hash+ of options
|
610
|
-
def
|
670
|
+
def save(options = {})
|
671
|
+
self.prefill(options)
|
672
|
+
|
611
673
|
request = Request.new(@client)
|
612
674
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
613
675
|
data = {
|
614
|
-
"
|
676
|
+
"name" => @name,
|
677
|
+
"amount" => @amount,
|
678
|
+
"interval" => @interval,
|
679
|
+
"trial_end_at" => @trial_end_at,
|
680
|
+
"metadata" => @metadata
|
615
681
|
}
|
616
682
|
|
617
683
|
response = Response.new(request.put(path, data, options))
|
@@ -633,6 +699,8 @@ module ProcessOut
|
|
633
699
|
# +cancellation_reason+:: Cancellation reason
|
634
700
|
# +options+:: +Hash+ of options
|
635
701
|
def cancel(cancellation_reason, options = {})
|
702
|
+
self.prefill(options)
|
703
|
+
|
636
704
|
request = Request.new(@client)
|
637
705
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
638
706
|
data = {
|
@@ -659,6 +727,8 @@ module ProcessOut
|
|
659
727
|
# +cancellation_reason+:: Cancellation reason
|
660
728
|
# +options+:: +Hash+ of options
|
661
729
|
def cancel_at_date(cancel_at, cancellation_reason, options = {})
|
730
|
+
self.prefill(options)
|
731
|
+
|
662
732
|
request = Request.new(@client)
|
663
733
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
664
734
|
data = {
|
data/lib/processout/token.rb
CHANGED
@@ -71,14 +71,14 @@ module ProcessOut
|
|
71
71
|
def initialize(client, data = {})
|
72
72
|
@client = client
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
74
|
+
self.id = data.fetch(:id, nil)
|
75
|
+
self.customer = data.fetch(:customer, nil)
|
76
|
+
self.customer_id = data.fetch(:customer_id, nil)
|
77
|
+
self.card = data.fetch(:card, nil)
|
78
|
+
self.type = data.fetch(:type, nil)
|
79
|
+
self.metadata = data.fetch(:metadata, nil)
|
80
|
+
self.is_subscription_only = data.fetch(:is_subscription_only, nil)
|
81
|
+
self.created_at = data.fetch(:created_at, nil)
|
82
82
|
|
83
83
|
end
|
84
84
|
|
@@ -91,6 +91,9 @@ module ProcessOut
|
|
91
91
|
# Params:
|
92
92
|
# +data+:: +Hash+ of data coming from the API
|
93
93
|
def fill_with_data(data)
|
94
|
+
if data.nil?
|
95
|
+
return self
|
96
|
+
end
|
94
97
|
if data.include? "id"
|
95
98
|
self.id = data["id"]
|
96
99
|
end
|
@@ -119,12 +122,33 @@ module ProcessOut
|
|
119
122
|
self
|
120
123
|
end
|
121
124
|
|
125
|
+
# Prefills the object with the data passed as Parameters
|
126
|
+
# Params:
|
127
|
+
# +data+:: +Hash+ of data
|
128
|
+
def prefill(data)
|
129
|
+
if data.nil?
|
130
|
+
return self
|
131
|
+
end
|
132
|
+
self.id = data.fetch(:id, self.id)
|
133
|
+
self.customer = data.fetch(:customer, self.customer)
|
134
|
+
self.customer_id = data.fetch(:customer_id, self.customer_id)
|
135
|
+
self.card = data.fetch(:card, self.card)
|
136
|
+
self.type = data.fetch(:type, self.type)
|
137
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
138
|
+
self.is_subscription_only = data.fetch(:is_subscription_only, self.is_subscription_only)
|
139
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
122
144
|
# Find a customer's token by its ID.
|
123
145
|
# Params:
|
124
146
|
# +customer_id+:: ID of the customer
|
125
147
|
# +token_id+:: ID of the token
|
126
148
|
# +options+:: +Hash+ of options
|
127
149
|
def find(customer_id, token_id, options = {})
|
150
|
+
self.prefill(options)
|
151
|
+
|
128
152
|
request = Request.new(@client)
|
129
153
|
path = "/customers/" + CGI.escape(customer_id) + "/tokens/" + CGI.escape(token_id) + ""
|
130
154
|
data = {
|
@@ -152,6 +176,8 @@ module ProcessOut
|
|
152
176
|
# +source+:: Source used to create the token (most likely a card token generated by ProcessOut.js)
|
153
177
|
# +options+:: +Hash+ of options
|
154
178
|
def create(customer_id, source, options = {})
|
179
|
+
self.prefill(options)
|
180
|
+
|
155
181
|
request = Request.new(@client)
|
156
182
|
path = "/customers/" + CGI.escape(customer_id) + "/tokens"
|
157
183
|
data = {
|
@@ -180,6 +206,8 @@ module ProcessOut
|
|
180
206
|
# +target+:: Authorization request ID
|
181
207
|
# +options+:: +Hash+ of options
|
182
208
|
def create_from_request(customer_id, source, target, options = {})
|
209
|
+
self.prefill(options)
|
210
|
+
|
183
211
|
request = Request.new(@client)
|
184
212
|
path = "/customers/" + CGI.escape(customer_id) + "/tokens"
|
185
213
|
data = {
|
@@ -206,6 +234,8 @@ module ProcessOut
|
|
206
234
|
# Params:
|
207
235
|
# +options+:: +Hash+ of options
|
208
236
|
def delete(options = {})
|
237
|
+
self.prefill(options)
|
238
|
+
|
209
239
|
request = Request.new(@client)
|
210
240
|
path = "customers/" + CGI.escape(@customer_id) + "/tokens/" + CGI.escape(@id) + ""
|
211
241
|
data = {
|
@@ -137,23 +137,23 @@ module ProcessOut
|
|
137
137
|
def initialize(client, data = {})
|
138
138
|
@client = client
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
140
|
+
self.id = data.fetch(:id, nil)
|
141
|
+
self.project = data.fetch(:project, nil)
|
142
|
+
self.customer = data.fetch(:customer, nil)
|
143
|
+
self.subscription = data.fetch(:subscription, nil)
|
144
|
+
self.token = data.fetch(:token, nil)
|
145
|
+
self.card = data.fetch(:card, nil)
|
146
|
+
self.name = data.fetch(:name, nil)
|
147
|
+
self.authorized_amount = data.fetch(:authorized_amount, nil)
|
148
|
+
self.captured_amount = data.fetch(:captured_amount, nil)
|
149
|
+
self.currency = data.fetch(:currency, nil)
|
150
|
+
self.status = data.fetch(:status, nil)
|
151
|
+
self.authorized = data.fetch(:authorized, nil)
|
152
|
+
self.captured = data.fetch(:captured, nil)
|
153
|
+
self.processout_fee = data.fetch(:processout_fee, nil)
|
154
|
+
self.metadata = data.fetch(:metadata, nil)
|
155
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
156
|
+
self.created_at = data.fetch(:created_at, nil)
|
157
157
|
|
158
158
|
end
|
159
159
|
|
@@ -166,6 +166,9 @@ module ProcessOut
|
|
166
166
|
# Params:
|
167
167
|
# +data+:: +Hash+ of data coming from the API
|
168
168
|
def fill_with_data(data)
|
169
|
+
if data.nil?
|
170
|
+
return self
|
171
|
+
end
|
169
172
|
if data.include? "id"
|
170
173
|
self.id = data["id"]
|
171
174
|
end
|
@@ -221,10 +224,40 @@ module ProcessOut
|
|
221
224
|
self
|
222
225
|
end
|
223
226
|
|
227
|
+
# Prefills the object with the data passed as Parameters
|
228
|
+
# Params:
|
229
|
+
# +data+:: +Hash+ of data
|
230
|
+
def prefill(data)
|
231
|
+
if data.nil?
|
232
|
+
return self
|
233
|
+
end
|
234
|
+
self.id = data.fetch(:id, self.id)
|
235
|
+
self.project = data.fetch(:project, self.project)
|
236
|
+
self.customer = data.fetch(:customer, self.customer)
|
237
|
+
self.subscription = data.fetch(:subscription, self.subscription)
|
238
|
+
self.token = data.fetch(:token, self.token)
|
239
|
+
self.card = data.fetch(:card, self.card)
|
240
|
+
self.name = data.fetch(:name, self.name)
|
241
|
+
self.authorized_amount = data.fetch(:authorized_amount, self.authorized_amount)
|
242
|
+
self.captured_amount = data.fetch(:captured_amount, self.captured_amount)
|
243
|
+
self.currency = data.fetch(:currency, self.currency)
|
244
|
+
self.status = data.fetch(:status, self.status)
|
245
|
+
self.authorized = data.fetch(:authorized, self.authorized)
|
246
|
+
self.captured = data.fetch(:captured, self.captured)
|
247
|
+
self.processout_fee = data.fetch(:processout_fee, self.processout_fee)
|
248
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
249
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
250
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
251
|
+
|
252
|
+
self
|
253
|
+
end
|
254
|
+
|
224
255
|
# Get the transaction's refunds.
|
225
256
|
# Params:
|
226
257
|
# +options+:: +Hash+ of options
|
227
258
|
def fetch_refunds(options = {})
|
259
|
+
self.prefill(options)
|
260
|
+
|
228
261
|
request = Request.new(@client)
|
229
262
|
path = "/transactions/" + CGI.escape(@id) + "/refunds"
|
230
263
|
data = {
|
@@ -254,6 +287,8 @@ module ProcessOut
|
|
254
287
|
# +refund_id+:: ID of the refund
|
255
288
|
# +options+:: +Hash+ of options
|
256
289
|
def find_refund(refund_id, options = {})
|
290
|
+
self.prefill(options)
|
291
|
+
|
257
292
|
request = Request.new(@client)
|
258
293
|
path = "/transactions/" + CGI.escape(@id) + "/refunds/" + CGI.escape(refund_id) + ""
|
259
294
|
data = {
|
@@ -276,6 +311,8 @@ module ProcessOut
|
|
276
311
|
# Params:
|
277
312
|
# +options+:: +Hash+ of options
|
278
313
|
def all(options = {})
|
314
|
+
self.prefill(options)
|
315
|
+
|
279
316
|
request = Request.new(@client)
|
280
317
|
path = "/transactions"
|
281
318
|
data = {
|
@@ -305,6 +342,8 @@ module ProcessOut
|
|
305
342
|
# +transaction_id+:: ID of the transaction
|
306
343
|
# +options+:: +Hash+ of options
|
307
344
|
def find(transaction_id, options = {})
|
345
|
+
self.prefill(options)
|
346
|
+
|
308
347
|
request = Request.new(@client)
|
309
348
|
path = "/transactions/" + CGI.escape(transaction_id) + ""
|
310
349
|
data = {
|
data/lib/processout/version.rb
CHANGED