stripe-rails 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e690f4a7b8ea6a4c35c93f5610d7c24d674e01f346ba7efe4fde29a006f1b65c
4
- data.tar.gz: 6b0630b85e0375aec712c16f838e2f72afcd5bb08e13cf14954446614815fcad
3
+ metadata.gz: 51f0207403afbfce8ee8b69a3f83b939cec5c1bdffbfc73e487cb3a07f6c4e10
4
+ data.tar.gz: 02415c95fd7dbd5cb6ef51b8536160e15f8f73e3b67edb89978dc6c326e91e70
5
5
  SHA512:
6
- metadata.gz: 669a5d261e8b93f9649422203e85ed6ab4cd1a49097efcbad0820201869627ae3aa605ea3c5c6c0a7601853e951c78920841523ad6ca7c2ae44d356c6a7b9e59
7
- data.tar.gz: f815812e608075b93621d38775a391704efa4c3e39e64102ae65a395670429cbbcd4048a58a6c3ff71992b5cbe33ff9cb157d3e49a16164a07d6cca58ca5a6b8
6
+ metadata.gz: fb22773c38887ff388f6a7e8ec92bb1ab586a9c8686e7e98f2d55d2c7214db49fb51dc9353ed34da2e9eb7e2b1d93c18c136ebf86650a9e033b18fa2c8b54363
7
+ data.tar.gz: 479bfa26243c4bbb04625603d7055c6baee96758e54ec8f6a5f208ba50fadab8fea9181076070d931b3591532384ee9cbd5a1c02d66ae6a995faaa1b7bb632c3
@@ -1,3 +1,7 @@
1
+ ## 1.5.3 (2018-10-25)
2
+
3
+ * Add usage_type, aggregate_usage, and billing_scheme - thanks @garrettqmartin8
4
+
1
5
  ## 1.5.2 (2018-10-15)
2
6
 
3
7
  * fixes undefined method `expand_path' for Stripe::File:Class - Thanks to @BitesGit for reporting this.
@@ -3,12 +3,12 @@
3
3
  # Example
4
4
  # Stripe::Products::PRIMO #=> 'primo'
5
5
 
6
- # Stripe.products :primo do |products|
7
- # # products name as it will appear on credit card statements
8
- # products.name = 'Acme as a service PRIMO'
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
- # products.type = 'service'
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 create_options)
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 create_options)
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
@@ -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
- }.delete_if{|_, v| v.nil? }
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
- }.delete_if{|_, v| v.nil? }
95
+ }
91
96
  end
92
97
  end
93
98
  end
@@ -44,7 +44,7 @@ module Stripe
44
44
  shippable: shippable,
45
45
  url: url,
46
46
  statement_descriptor: statement_descriptor
47
- }.delete_if{|_, v| v.nil? }
47
+ }
48
48
  end
49
49
  end
50
50
  end
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = '1.5.2'
3
+ VERSION = '1.5.3'
4
4
  end
5
5
  end
@@ -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
@@ -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.2
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-15 00:00:00.000000000 Z
13
+ date: 2018-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails