stripe-rails 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/lib/generators/templates/products.rb +4 -4
- data/lib/stripe/configuration_builder.rb +6 -2
- data/lib/stripe/plans.rb +7 -2
- data/lib/stripe/products.rb +1 -1
- data/lib/stripe/rails/version.rb +1 -1
- data/test/dummy/config/stripe/plans.rb +9 -0
- data/test/plan_builder_spec.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f0207403afbfce8ee8b69a3f83b939cec5c1bdffbfc73e487cb3a07f6c4e10
|
4
|
+
data.tar.gz: 02415c95fd7dbd5cb6ef51b8536160e15f8f73e3b67edb89978dc6c326e91e70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb22773c38887ff388f6a7e8ec92bb1ab586a9c8686e7e98f2d55d2c7214db49fb51dc9353ed34da2e9eb7e2b1d93c18c136ebf86650a9e033b18fa2c8b54363
|
7
|
+
data.tar.gz: 479bfa26243c4bbb04625603d7055c6baee96758e54ec8f6a5f208ba50fadab8fea9181076070d931b3591532384ee9cbd5a1c02d66ae6a995faaa1b7bb632c3
|
data/Changelog.md
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
# Example
|
4
4
|
# Stripe::Products::PRIMO #=> 'primo'
|
5
5
|
|
6
|
-
# Stripe.
|
7
|
-
# #
|
8
|
-
#
|
6
|
+
# Stripe.product :primo do |product|
|
7
|
+
# # product's name as it will appear on credit card statements
|
8
|
+
# product.name = 'Acme as a service PRIMO'
|
9
9
|
#
|
10
10
|
# # Product, either 'service' or 'good'
|
11
|
-
#
|
11
|
+
# product.type = 'service'
|
12
12
|
# end
|
13
13
|
|
14
14
|
# Once you have your productss defined, you can run
|
@@ -76,7 +76,7 @@ module Stripe
|
|
76
76
|
if exists?
|
77
77
|
puts "[EXISTS] - #{@stripe_class}:#{@id}" unless Stripe::Engine.testing
|
78
78
|
else
|
79
|
-
object = @stripe_class.create({:id => @id}.merge
|
79
|
+
object = @stripe_class.create({:id => @id}.merge compact_create_options)
|
80
80
|
puts "[CREATE] - #{@stripe_class}:#{object}" unless Stripe::Engine.testing
|
81
81
|
end
|
82
82
|
end
|
@@ -85,10 +85,14 @@ module Stripe
|
|
85
85
|
if object = exists?
|
86
86
|
object.delete
|
87
87
|
end
|
88
|
-
object = @stripe_class.create({:id => @id}.merge
|
88
|
+
object = @stripe_class.create({:id => @id}.merge compact_create_options)
|
89
89
|
puts "[RESET] - #{@stripe_class}:#{object}" unless Stripe::Engine.testing
|
90
90
|
end
|
91
91
|
|
92
|
+
def compact_create_options
|
93
|
+
create_options.delete_if { |_, v| v.nil? }
|
94
|
+
end
|
95
|
+
|
92
96
|
def to_s
|
93
97
|
@id.to_s
|
94
98
|
end
|
data/lib/stripe/plans.rb
CHANGED
@@ -69,14 +69,19 @@ module Stripe
|
|
69
69
|
interval_count: interval_count,
|
70
70
|
trial_period_days: trial_period_days,
|
71
71
|
metadata: metadata,
|
72
|
+
usage_type: usage_type,
|
73
|
+
aggregate_usage: aggregate_usage,
|
74
|
+
billing_scheme: billing_scheme,
|
72
75
|
nickname: nickname
|
73
|
-
}
|
76
|
+
}
|
74
77
|
end
|
75
78
|
|
76
79
|
def product_options
|
77
80
|
product_id.presence || { name: name, statement_descriptor: statement_descriptor }
|
78
81
|
end
|
79
82
|
|
83
|
+
# Note: these options serve an older API, as such they should
|
84
|
+
# probably never be updated.
|
80
85
|
def create_options_without_products
|
81
86
|
{
|
82
87
|
currency: currency,
|
@@ -87,7 +92,7 @@ module Stripe
|
|
87
92
|
trial_period_days: trial_period_days,
|
88
93
|
metadata: metadata,
|
89
94
|
statement_descriptor: statement_descriptor
|
90
|
-
}
|
95
|
+
}
|
91
96
|
end
|
92
97
|
end
|
93
98
|
end
|
data/lib/stripe/products.rb
CHANGED
data/lib/stripe/rails/version.rb
CHANGED
@@ -10,3 +10,12 @@ Stripe.plan :alternative_currency do |plan|
|
|
10
10
|
plan.interval = 'month'
|
11
11
|
plan.currency = 'cad'
|
12
12
|
end
|
13
|
+
|
14
|
+
Stripe.plan :metered do |plan|
|
15
|
+
plan.name = 'Metered'
|
16
|
+
plan.amount = 699
|
17
|
+
plan.interval = 'month'
|
18
|
+
plan.usage_type = 'metered'
|
19
|
+
plan.aggregate_usage = 'max'
|
20
|
+
plan.billing_scheme = 'per_unit'
|
21
|
+
end
|
data/test/plan_builder_spec.rb
CHANGED
@@ -256,6 +256,26 @@ describe 'building plans' do
|
|
256
256
|
Stripe::Plans::GOLD.put!
|
257
257
|
end
|
258
258
|
|
259
|
+
it 'creates a metered plan' do
|
260
|
+
Stripe::Plan.expects(:create).with(
|
261
|
+
:id => :metered,
|
262
|
+
:currency => 'usd',
|
263
|
+
:product => {
|
264
|
+
:name => 'Metered',
|
265
|
+
:statement_descriptor => nil,
|
266
|
+
},
|
267
|
+
:amount => 699,
|
268
|
+
:interval => 'month',
|
269
|
+
:interval_count => 1,
|
270
|
+
:trial_period_days => 0,
|
271
|
+
:usage_type => 'metered',
|
272
|
+
:aggregate_usage => 'max',
|
273
|
+
:billing_scheme => 'per_unit'
|
274
|
+
)
|
275
|
+
Stripe::Plans::METERED.put!
|
276
|
+
end
|
277
|
+
|
278
|
+
|
259
279
|
describe 'when using a product id' do
|
260
280
|
before do
|
261
281
|
Stripe::Plans::GOLD.product_id = 'prod_XXXXXXXXXXXXXX'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-10-
|
13
|
+
date: 2018-10-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|