processout 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/processout/subscription.rb +12 -58
- data/lib/processout/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0a9ad7b4c761856cc0b61cdf83574b257b3fced
|
4
|
+
data.tar.gz: e8b2ac9780fc385076ac1aa7ed37230a761ec478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f88f795322e08c68800c720da6b50a9b8ffd9d7238cba2da74b18a158c0273641abc0d59150b41f907ccf4bafbcb3f6d55f0184095091e3ad63d5e12411a3972
|
7
|
+
data.tar.gz: 6380bf6fda3a98467a81441176dd16ab9abd220186ab8ebd697962c626736b2a141f4de69e78ca011d635b3a2e7253ef000ee450e2a256b110aa7b9ce8f7e0b0
|
@@ -9,6 +9,7 @@ module ProcessOut
|
|
9
9
|
|
10
10
|
attr_reader :id
|
11
11
|
attr_reader :project
|
12
|
+
attr_reader :plan_id
|
12
13
|
attr_reader :plan
|
13
14
|
attr_reader :customer
|
14
15
|
attr_reader :token
|
@@ -48,6 +49,10 @@ module ProcessOut
|
|
48
49
|
|
49
50
|
end
|
50
51
|
|
52
|
+
def plan_id=(val)
|
53
|
+
@plan_id = val
|
54
|
+
end
|
55
|
+
|
51
56
|
def plan=(val)
|
52
57
|
if val.instance_of? Plan
|
53
58
|
@plan = val
|
@@ -167,6 +172,7 @@ module ProcessOut
|
|
167
172
|
|
168
173
|
self.id = data.fetch(:id, nil)
|
169
174
|
self.project = data.fetch(:project, nil)
|
175
|
+
self.plan_id = data.fetch(:plan_id, nil)
|
170
176
|
self.plan = data.fetch(:plan, nil)
|
171
177
|
self.customer = data.fetch(:customer, nil)
|
172
178
|
self.token = data.fetch(:token, nil)
|
@@ -210,6 +216,9 @@ module ProcessOut
|
|
210
216
|
if data.include? "project"
|
211
217
|
self.project = data["project"]
|
212
218
|
end
|
219
|
+
if data.include? "plan_id"
|
220
|
+
self.plan_id = data["plan_id"]
|
221
|
+
end
|
213
222
|
if data.include? "plan"
|
214
223
|
self.plan = data["plan"]
|
215
224
|
end
|
@@ -289,6 +298,7 @@ module ProcessOut
|
|
289
298
|
end
|
290
299
|
self.id = data.fetch(:id, self.id)
|
291
300
|
self.project = data.fetch(:project, self.project)
|
301
|
+
self.plan_id = data.fetch(:plan_id, self.plan_id)
|
292
302
|
self.plan = data.fetch(:plan, self.plan)
|
293
303
|
self.customer = data.fetch(:customer, self.customer)
|
294
304
|
self.token = data.fetch(:token, self.token)
|
@@ -516,6 +526,7 @@ module ProcessOut
|
|
516
526
|
request = Request.new(@client)
|
517
527
|
path = "/subscriptions"
|
518
528
|
data = {
|
529
|
+
"plan_id" => @plan_id,
|
519
530
|
"cancel_at" => @cancel_at,
|
520
531
|
"name" => @name,
|
521
532
|
"amount" => @amount,
|
@@ -525,7 +536,6 @@ module ProcessOut
|
|
525
536
|
"trial_end_at" => @trial_end_at,
|
526
537
|
"return_url" => @return_url,
|
527
538
|
"cancel_url" => @cancel_url,
|
528
|
-
"plan_id" => options.fetch(:plan_id, nil),
|
529
539
|
"source" => options.fetch(:source, nil),
|
530
540
|
"prorate" => options.fetch(:prorate, nil),
|
531
541
|
"customer_id" => customer_id
|
@@ -609,62 +619,6 @@ module ProcessOut
|
|
609
619
|
|
610
620
|
|
611
621
|
|
612
|
-
return_values[0]
|
613
|
-
end
|
614
|
-
|
615
|
-
# Update the subscription's plan.
|
616
|
-
# Params:
|
617
|
-
# +plan_id+:: ID of the new plan to be applied on the subscription
|
618
|
-
# +prorate+:: Define if proration should be done when updating the plan
|
619
|
-
# +options+:: +Hash+ of options
|
620
|
-
def update_plan(plan_id, prorate, options = {})
|
621
|
-
self.prefill(options)
|
622
|
-
|
623
|
-
request = Request.new(@client)
|
624
|
-
path = "/subscriptions/" + CGI.escape(@id) + ""
|
625
|
-
data = {
|
626
|
-
"plan_id" => plan_id,
|
627
|
-
"prorate" => prorate
|
628
|
-
}
|
629
|
-
|
630
|
-
response = Response.new(request.put(path, data, options))
|
631
|
-
return_values = Array.new
|
632
|
-
|
633
|
-
body = response.body
|
634
|
-
body = body["subscription"]
|
635
|
-
|
636
|
-
|
637
|
-
return_values.push(self.fill_with_data(body))
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
return_values[0]
|
642
|
-
end
|
643
|
-
|
644
|
-
# Apply a source to the subscription to activate or update the subscription's source.
|
645
|
-
# Params:
|
646
|
-
# +source+:: Source to be applied on the subscription and used to pay future invoices. Can be a card, a token or a gateway request
|
647
|
-
# +options+:: +Hash+ of options
|
648
|
-
def apply_source(source, options = {})
|
649
|
-
self.prefill(options)
|
650
|
-
|
651
|
-
request = Request.new(@client)
|
652
|
-
path = "/subscriptions/" + CGI.escape(@id) + ""
|
653
|
-
data = {
|
654
|
-
"source" => source
|
655
|
-
}
|
656
|
-
|
657
|
-
response = Response.new(request.put(path, data, options))
|
658
|
-
return_values = Array.new
|
659
|
-
|
660
|
-
body = response.body
|
661
|
-
body = body["subscription"]
|
662
|
-
|
663
|
-
|
664
|
-
return_values.push(self.fill_with_data(body))
|
665
|
-
|
666
|
-
|
667
|
-
|
668
622
|
return_values[0]
|
669
623
|
end
|
670
624
|
|
@@ -677,13 +631,13 @@ module ProcessOut
|
|
677
631
|
request = Request.new(@client)
|
678
632
|
path = "/subscriptions/" + CGI.escape(@id) + ""
|
679
633
|
data = {
|
634
|
+
"plan_id" => @plan_id,
|
680
635
|
"name" => @name,
|
681
636
|
"amount" => @amount,
|
682
637
|
"interval" => @interval,
|
683
638
|
"trial_end_at" => @trial_end_at,
|
684
639
|
"metadata" => @metadata,
|
685
640
|
"coupon_id" => options.fetch(:coupon_id, nil),
|
686
|
-
"plan_id" => options.fetch(:plan_id, nil),
|
687
641
|
"source" => options.fetch(:source, nil),
|
688
642
|
"prorate" => options.fetch(:prorate, nil),
|
689
643
|
"proration_date" => options.fetch(:proration_date, nil)
|
data/lib/processout/version.rb
CHANGED