stripe 3.12.1 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +1 -0
- data/lib/stripe/usage_record.rb +12 -0
- data/lib/stripe/util.rb +1 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_external_accounts_operations_test.rb +2 -1
- data/test/stripe/plan_test.rb +40 -0
- data/test/stripe/usage_record_test.rb +26 -0
- data/test/test_helper.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719456b37833bcc702e2bfc07e527893605d8a1c
|
4
|
+
data.tar.gz: 5e7be4888ad520802089c4038d3a309db8b38bdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8b56ed5c634e90cc5e7ecd7bd351ba1c4a797607256762fda2862ceaf88fdc471919d94618a2643df85683624ff88acb40e417898bff66ec963d341e18c204
|
7
|
+
data.tar.gz: 6cda7ebdcdae5837a1ba955421546a16999ee33d091bf47ea5d75ee996cf00ba8caacef5df9196954c6ec274436a887d10f508fb9f1f9d73979aa9017c7e67f4
|
data/.rubocop_todo.yml
CHANGED
@@ -33,12 +33,12 @@ Metrics/LineLength:
|
|
33
33
|
# Offense count: 32
|
34
34
|
# Configuration parameters: CountComments.
|
35
35
|
Metrics/MethodLength:
|
36
|
-
Max:
|
36
|
+
Max: 46
|
37
37
|
|
38
38
|
# Offense count: 1
|
39
39
|
# Configuration parameters: CountComments.
|
40
40
|
Metrics/ModuleLength:
|
41
|
-
Max:
|
41
|
+
Max: 306
|
42
42
|
|
43
43
|
# Offense count: 6
|
44
44
|
# Configuration parameters: CountKeywordArgs.
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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.
|
1
|
+
3.13.0
|
data/lib/stripe.rb
CHANGED
@@ -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
|
data/lib/stripe/util.rb
CHANGED
data/lib/stripe/version.rb
CHANGED
@@ -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.
|
51
|
+
assert external_account.deleted
|
52
|
+
assert_equal @external_account_id, external_account.id
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
data/test/stripe/plan_test.rb
CHANGED
@@ -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
|
data/test/test_helper.rb
CHANGED
@@ -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.
|
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.
|
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-
|
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
|