stripe 3.12.1 → 3.13.0

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
  SHA1:
3
- metadata.gz: f69c49a7d892cd159ee277609a60cf58b0821661
4
- data.tar.gz: a4fd07a861afdc99dee8847f6c0ea3fb4b5ed1e8
3
+ metadata.gz: 719456b37833bcc702e2bfc07e527893605d8a1c
4
+ data.tar.gz: 5e7be4888ad520802089c4038d3a309db8b38bdc
5
5
  SHA512:
6
- metadata.gz: be354b7d9ead42c6e276275fc92797852d40dbd0aed9af69582b56d41e162ee1988e74f23a7a8a284a66151ae0846bc73694a0a74d7c0565f071cf9ee58ea5db
7
- data.tar.gz: d337e1b866dc73b92b7a461e52b0b83fa9bf08ee3520f5767e2837315bd39b308a002828f8e0c23ec68fd99e56241b4ed915359151639585e214410aa1c94e57
6
+ metadata.gz: 8e8b56ed5c634e90cc5e7ecd7bd351ba1c4a797607256762fda2862ceaf88fdc471919d94618a2643df85683624ff88acb40e417898bff66ec963d341e18c204
7
+ data.tar.gz: 6cda7ebdcdae5837a1ba955421546a16999ee33d091bf47ea5d75ee996cf00ba8caacef5df9196954c6ec274436a887d10f508fb9f1f9d73979aa9017c7e67f4
@@ -33,12 +33,12 @@ Metrics/LineLength:
33
33
  # Offense count: 32
34
34
  # Configuration parameters: CountComments.
35
35
  Metrics/MethodLength:
36
- Max: 45
36
+ Max: 46
37
37
 
38
38
  # Offense count: 1
39
39
  # Configuration parameters: CountComments.
40
40
  Metrics/ModuleLength:
41
- Max: 305
41
+ Max: 306
42
42
 
43
43
  # Offense count: 6
44
44
  # Configuration parameters: CountKeywordArgs.
@@ -16,7 +16,7 @@ sudo: false
16
16
 
17
17
  env:
18
18
  global:
19
- - STRIPE_MOCK_VERSION=0.8.0
19
+ - STRIPE_MOCK_VERSION=0.12.0
20
20
 
21
21
  cache:
22
22
  directories:
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.13.0 - 2018-04-11
4
+ * [#498](https://github.com/stripe/stripe-ruby/pull/498) Add support for flexible billing primitives
5
+
3
6
  ## 3.12.1 - 2018-04-05
4
7
  * [#636](https://github.com/stripe/stripe-ruby/pull/636) Fix a warning for uninitialized instance variable `@additive_params`
5
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.12.1
1
+ 3.13.0
@@ -76,6 +76,7 @@ require "stripe/three_d_secure"
76
76
  require "stripe/token"
77
77
  require "stripe/topup"
78
78
  require "stripe/transfer"
79
+ require "stripe/usage_record"
79
80
 
80
81
  # OAuth
81
82
  require "stripe/oauth"
@@ -0,0 +1,12 @@
1
+ module Stripe
2
+ class UsageRecord < APIResource
3
+ def self.create(params = {}, opts = {})
4
+ raise(ArgumentError, "Params must have a subscription_item key") unless params.key?(:subscription_item)
5
+ req_params = params.clone.delete_if { |key, _value| key == :subscription_item }
6
+ resp, opts = request(:post, "/v1/subscription_items/#{params[:subscription_item]}/usage_records", req_params, opts)
7
+ Util.convert_to_stripe_object(resp.data, opts)
8
+ end
9
+
10
+ OBJECT_NAME = "usage_record".freeze
11
+ end
12
+ end
@@ -85,6 +85,7 @@ module Stripe
85
85
  Token::OBJECT_NAME => Token,
86
86
  Topup::OBJECT_NAME => Topup,
87
87
  Transfer::OBJECT_NAME => Transfer,
88
+ UsageRecord::OBJECT_NAME => UsageRecord,
88
89
  }
89
90
  end
90
91
 
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = "3.12.1".freeze
2
+ VERSION = "3.13.0".freeze
3
3
  end
@@ -48,7 +48,8 @@ module Stripe
48
48
  @external_account_id
49
49
  )
50
50
  assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts/#{@external_account_id}"
51
- assert external_account.is_a?(Stripe::BankAccount)
51
+ assert external_account.deleted
52
+ assert_equal @external_account_id, external_account.id
52
53
  end
53
54
  end
54
55
 
@@ -27,6 +27,46 @@ module Stripe
27
27
  assert plan.is_a?(Stripe::Plan)
28
28
  end
29
29
 
30
+ should "be creatable with metered configuration" do
31
+ plan = Stripe::Plan.create(
32
+ amount: 5000,
33
+ interval: "month",
34
+ name: "Sapphire elite",
35
+ currency: "usd",
36
+ id: "sapphire-elite",
37
+ usage_type: "metered"
38
+ )
39
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
40
+ assert plan.is_a?(Stripe::Plan)
41
+ end
42
+
43
+ should "be creatable with tiered configuration" do
44
+ plan = Stripe::Plan.create(
45
+ interval: "month",
46
+ name: "Sapphire elite",
47
+ currency: "usd",
48
+ id: "sapphire-elite",
49
+ billing_scheme: "tiered",
50
+ tiers_mode: "volume",
51
+ tiers: [{ up_to: 100, amount: 1000 }, { up_to: "inf", amount: 2000 }]
52
+ )
53
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
54
+ assert plan.is_a?(Stripe::Plan)
55
+ end
56
+
57
+ should "be creatable with transform_usage" do
58
+ plan = Stripe::Plan.create(
59
+ interval: "month",
60
+ name: "Sapphire elite",
61
+ currency: "usd",
62
+ id: "sapphire-elite",
63
+ amount: 5000,
64
+ transform_usage: { round: "up", divide_by: 50 }
65
+ )
66
+ assert_requested :post, "#{Stripe.api_base}/v1/plans"
67
+ assert plan.is_a?(Stripe::Plan)
68
+ end
69
+
30
70
  should "be saveable" do
31
71
  plan = Stripe::Plan.retrieve("sapphire-elite")
32
72
  plan.metadata["key"] = "value"
@@ -0,0 +1,26 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ module Stripe
4
+ class UsageRecordTest < Test::Unit::TestCase
5
+ should "be creatable" do
6
+ usage_record = Stripe::UsageRecord.create(
7
+ quantity: 5000,
8
+ subscription_item: "si_abc",
9
+ timestamp: Time.now.to_i,
10
+ action: "increment"
11
+ )
12
+ assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_abc/usage_records"
13
+ assert usage_record.is_a?(Stripe::UsageRecord)
14
+ end
15
+
16
+ should "raise when subscription_item is missing" do
17
+ assert_raise ArgumentError do
18
+ Stripe::UsageRecord.create(
19
+ quantity: 5000,
20
+ timestamp: Time.now.to_i,
21
+ action: "increment"
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -13,7 +13,7 @@ PROJECT_ROOT = File.expand_path("../../", __FILE__)
13
13
 
14
14
  require File.expand_path("../test_data", __FILE__)
15
15
 
16
- MOCK_MINIMUM_VERSION = "0.4.0".freeze
16
+ MOCK_MINIMUM_VERSION = "0.12.0".freeze
17
17
  MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
18
18
 
19
19
  # Disable all real network connections except those that are outgoing to
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.1
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2018-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -105,6 +105,7 @@ files:
105
105
  - lib/stripe/token.rb
106
106
  - lib/stripe/topup.rb
107
107
  - lib/stripe/transfer.rb
108
+ - lib/stripe/usage_record.rb
108
109
  - lib/stripe/util.rb
109
110
  - lib/stripe/version.rb
110
111
  - lib/stripe/webhook.rb
@@ -159,6 +160,7 @@ files:
159
160
  - test/stripe/topup_test.rb
160
161
  - test/stripe/transfer_reversals_operations_test.rb
161
162
  - test/stripe/transfer_test.rb
163
+ - test/stripe/usage_record_test.rb
162
164
  - test/stripe/util_test.rb
163
165
  - test/stripe/webhook_test.rb
164
166
  - test/stripe_test.rb
@@ -239,6 +241,7 @@ test_files:
239
241
  - test/stripe/topup_test.rb
240
242
  - test/stripe/transfer_reversals_operations_test.rb
241
243
  - test/stripe/transfer_test.rb
244
+ - test/stripe/usage_record_test.rb
242
245
  - test/stripe/util_test.rb
243
246
  - test/stripe/webhook_test.rb
244
247
  - test/stripe_test.rb