stripe 5.26.0 → 5.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +15 -0
- data/README.md +6 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +2 -2
- data/lib/stripe/connection_manager.rb +3 -0
- data/lib/stripe/object_types.rb +1 -0
- data/lib/stripe/resources.rb +1 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
- data/lib/stripe/resources/customer.rb +6 -1
- data/lib/stripe/resources/payout.rb +10 -0
- data/lib/stripe/stripe_configuration.rb +11 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/billing_portal/configuration_test.rb +37 -0
- data/test/stripe/connection_manager_test.rb +4 -0
- data/test/stripe/customer_test.rb +3 -3
- data/test/stripe/payout_test.rb +15 -0
- data/test/stripe/stripe_configuration_test.rb +3 -0
- data/test/stripe_test.rb +13 -0
- data/test/test_helper.rb +3 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b4a8dbe95f87dd3e9c668af66d7a4254559109e4981b84f7b16dda44306ae7
|
4
|
+
data.tar.gz: 31eabe48b83cfa290878954d5deb22f7c0df3819f895b0331de21ae123c99410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb166be37a738fab2bbbd0d04af4f09eee035e221ea2c33fe41b763ac8a3ed1f4162843e27aed561779cfe86e1c71b6f8efba7a906b12f3500b3cb36d3e1e11
|
7
|
+
data.tar.gz: e0edb450045a26287e48b98561dd9274a07e43a52e65a5b55bc7754879faa3358cea22cfd40cf9ce7164e8b1b8d5236fa9cad7c56bb16439a9a15a3a7474df88
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.30.0 - 2021-02-22
|
4
|
+
* [#965](https://github.com/stripe/stripe-ruby/pull/965) Add support for the Billing Portal Configuration API
|
5
|
+
|
6
|
+
## 5.29.1 - 2021-02-09
|
7
|
+
* [#964](https://github.com/stripe/stripe-ruby/pull/964) Fix return value of `Customer#delete_discount`
|
8
|
+
|
9
|
+
## 5.29.0 - 2021-01-05
|
10
|
+
* [#952](https://github.com/stripe/stripe-ruby/pull/952) Allow client_id configuration on instance config
|
11
|
+
|
12
|
+
## 5.28.0 - 2020-10-14
|
13
|
+
* [#950](https://github.com/stripe/stripe-ruby/pull/950) Add configuration option for `write_timeout` for connections on Ruby 2.6+
|
14
|
+
|
15
|
+
## 5.27.0 - 2020-10-14
|
16
|
+
* [#951](https://github.com/stripe/stripe-ruby/pull/951) Add support for the Payout Reverse API
|
17
|
+
|
3
18
|
## 5.26.0 - 2020-09-29
|
4
19
|
* [#949](https://github.com/stripe/stripe-ruby/pull/949) Add support for the `SetupAttempt` resource and List API
|
5
20
|
|
data/README.md
CHANGED
@@ -21,6 +21,9 @@ The library also provides other features. For example:
|
|
21
21
|
|
22
22
|
See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
|
23
23
|
|
24
|
+
See [video demonstrations][youtube-playlist] covering how to use the library.
|
25
|
+
|
26
|
+
|
24
27
|
## Installation
|
25
28
|
|
26
29
|
You don't need this source code unless you want to modify the gem. If you just
|
@@ -186,11 +189,12 @@ retries are safe.
|
|
186
189
|
|
187
190
|
### Configuring Timeouts
|
188
191
|
|
189
|
-
Open and
|
192
|
+
Open, read and write timeouts are configurable:
|
190
193
|
|
191
194
|
```ruby
|
192
195
|
Stripe.open_timeout = 30 # in seconds
|
193
196
|
Stripe.read_timeout = 80
|
197
|
+
Stripe.write_timeout = 30 # only supported on Ruby 2.6+
|
194
198
|
```
|
195
199
|
|
196
200
|
Please take care to set conservative read timeouts. Some API requests can take
|
@@ -339,6 +343,7 @@ Update the bundled [stripe-mock] by editing the version number found in
|
|
339
343
|
[idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
|
340
344
|
[stripe-mock]: https://github.com/stripe/stripe-mock
|
341
345
|
[versioning]: https://stripe.com/docs/api/ruby#versioning
|
346
|
+
[youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M50RmP6ie-gdcSnfOuQCRYk
|
342
347
|
|
343
348
|
<!--
|
344
349
|
# vim: set tw=79:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.30.0
|
data/lib/stripe.rb
CHANGED
@@ -71,6 +71,7 @@ module Stripe
|
|
71
71
|
def_delegators :@configuration, :connect_base, :connect_base=
|
72
72
|
def_delegators :@configuration, :open_timeout, :open_timeout=
|
73
73
|
def_delegators :@configuration, :read_timeout, :read_timeout=
|
74
|
+
def_delegators :@configuration, :write_timeout, :write_timeout=
|
74
75
|
def_delegators :@configuration, :proxy, :proxy=
|
75
76
|
def_delegators :@configuration, :verify_ssl_certs, :verify_ssl_certs=
|
76
77
|
def_delegators :@configuration, :ca_bundle_path, :ca_bundle_path=
|
@@ -78,13 +79,12 @@ module Stripe
|
|
78
79
|
def_delegators :@configuration, :logger, :logger=
|
79
80
|
def_delegators :@configuration, :max_network_retries, :max_network_retries=
|
80
81
|
def_delegators :@configuration, :enable_telemetry=, :enable_telemetry?
|
82
|
+
def_delegators :@configuration, :client_id=, :client_id
|
81
83
|
|
82
84
|
# Internal configurations
|
83
85
|
def_delegators :@configuration, :max_network_retry_delay
|
84
86
|
def_delegators :@configuration, :initial_network_retry_delay
|
85
87
|
def_delegators :@configuration, :ca_store
|
86
|
-
|
87
|
-
attr_accessor :client_id
|
88
88
|
end
|
89
89
|
|
90
90
|
# Gets the application for a plugin that's identified some. See
|
@@ -119,6 +119,9 @@ module Stripe
|
|
119
119
|
|
120
120
|
connection.open_timeout = Stripe.open_timeout
|
121
121
|
connection.read_timeout = Stripe.read_timeout
|
122
|
+
if connection.respond_to?(:write_timeout=)
|
123
|
+
connection.write_timeout = Stripe.write_timeout
|
124
|
+
end
|
122
125
|
|
123
126
|
connection.use_ssl = uri.scheme == "https"
|
124
127
|
|
data/lib/stripe/object_types.rb
CHANGED
@@ -19,6 +19,7 @@ module Stripe
|
|
19
19
|
Balance::OBJECT_NAME => Balance,
|
20
20
|
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
|
21
21
|
BankAccount::OBJECT_NAME => BankAccount,
|
22
|
+
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
|
22
23
|
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
|
23
24
|
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
|
24
25
|
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
data/lib/stripe/resources.rb
CHANGED
@@ -9,6 +9,7 @@ require "stripe/resources/application_fee_refund"
|
|
9
9
|
require "stripe/resources/balance"
|
10
10
|
require "stripe/resources/balance_transaction"
|
11
11
|
require "stripe/resources/bank_account"
|
12
|
+
require "stripe/resources/billing_portal/configuration"
|
12
13
|
require "stripe/resources/billing_portal/session"
|
13
14
|
require "stripe/resources/bitcoin_receiver"
|
14
15
|
require "stripe/resources/bitcoin_transaction"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module BillingPortal
|
6
|
+
class Configuration < APIResource
|
7
|
+
extend Stripe::APIOperations::Create
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
include Stripe::APIOperations::Save
|
10
|
+
|
11
|
+
OBJECT_NAME = "billing_portal.configuration"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -28,9 +28,14 @@ module Stripe
|
|
28
28
|
alias detach_source delete_source
|
29
29
|
end
|
30
30
|
|
31
|
+
# Deletes a discount associated with the customer.
|
32
|
+
#
|
33
|
+
# Returns the deleted discount. The customer object is not updated,
|
34
|
+
# so you must call `refresh` on it to get a new version with the
|
35
|
+
# discount removed.
|
31
36
|
def delete_discount
|
32
37
|
resp, opts = execute_resource_request(:delete, resource_url + "/discount")
|
33
|
-
|
38
|
+
Util.convert_to_stripe_object(resp.data, opts)
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -10,6 +10,7 @@ module Stripe
|
|
10
10
|
OBJECT_NAME = "payout"
|
11
11
|
|
12
12
|
custom_method :cancel, http_verb: :post
|
13
|
+
custom_method :reverse, http_verb: :post
|
13
14
|
|
14
15
|
def cancel(params = {}, opts = {})
|
15
16
|
request_stripe_object(
|
@@ -19,5 +20,14 @@ module Stripe
|
|
19
20
|
opts: opts
|
20
21
|
)
|
21
22
|
end
|
23
|
+
|
24
|
+
def reverse(params = {}, opts = {})
|
25
|
+
request_stripe_object(
|
26
|
+
method: :post,
|
27
|
+
path: resource_url + "/reverse",
|
28
|
+
params: params,
|
29
|
+
opts: opts
|
30
|
+
)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
@@ -42,6 +42,7 @@ module Stripe
|
|
42
42
|
attr_reader :max_network_retry_delay
|
43
43
|
attr_reader :open_timeout
|
44
44
|
attr_reader :read_timeout
|
45
|
+
attr_reader :write_timeout
|
45
46
|
attr_reader :proxy
|
46
47
|
attr_reader :verify_ssl_certs
|
47
48
|
|
@@ -72,6 +73,7 @@ module Stripe
|
|
72
73
|
|
73
74
|
@open_timeout = 30
|
74
75
|
@read_timeout = 80
|
76
|
+
@write_timeout = 30
|
75
77
|
|
76
78
|
@api_base = "https://api.stripe.com"
|
77
79
|
@connect_base = "https://connect.stripe.com"
|
@@ -109,6 +111,15 @@ module Stripe
|
|
109
111
|
StripeClient.clear_all_connection_managers
|
110
112
|
end
|
111
113
|
|
114
|
+
def write_timeout=(write_timeout)
|
115
|
+
unless Net::HTTP.instance_methods.include?(:write_timeout=)
|
116
|
+
raise NotImplementedError
|
117
|
+
end
|
118
|
+
|
119
|
+
@write_timeout = write_timeout
|
120
|
+
StripeClient.clear_all_connection_managers
|
121
|
+
end
|
122
|
+
|
112
123
|
def proxy=(proxy)
|
113
124
|
@proxy = proxy
|
114
125
|
StripeClient.clear_all_connection_managers
|
data/lib/stripe/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
module BillingPortal
|
7
|
+
class ConfigurationTest < Test::Unit::TestCase
|
8
|
+
should "be creatable" do
|
9
|
+
session = Stripe::BillingPortal::Configuration.create({
|
10
|
+
business_profile: {
|
11
|
+
privacy_policy_url: "https://example.com/privacy",
|
12
|
+
terms_of_service_url: "https://example.com/tos",
|
13
|
+
},
|
14
|
+
features: { customer_update: { allowed_updates: ["address"], enabled: true } },
|
15
|
+
})
|
16
|
+
assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/configurations"
|
17
|
+
assert session.is_a?(Stripe::BillingPortal::Configuration)
|
18
|
+
end
|
19
|
+
should "be retrievable" do
|
20
|
+
session = Stripe::BillingPortal::Configuration.retrieve("bpc_xyz")
|
21
|
+
assert_requested :get, "#{Stripe.api_base}/v1/billing_portal/configurations/bpc_xyz"
|
22
|
+
assert session.is_a?(Stripe::BillingPortal::Configuration)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "be updateable" do
|
26
|
+
session = Stripe::BillingPortal::Configuration.update("bpc_xyz", { active: false })
|
27
|
+
assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/configurations/bpc_xyz"
|
28
|
+
assert session.is_a?(Stripe::BillingPortal::Configuration)
|
29
|
+
end
|
30
|
+
should "be listable" do
|
31
|
+
sessions = Stripe::BillingPortal::Configuration.list
|
32
|
+
assert_requested :get, "#{Stripe.api_base}/v1/billing_portal/configurations"
|
33
|
+
assert sessions.data[0].is_a?(Stripe::BillingPortal::Configuration)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -39,6 +39,7 @@ module Stripe
|
|
39
39
|
|
40
40
|
old_open_timeout = Stripe.open_timeout
|
41
41
|
old_read_timeout = Stripe.read_timeout
|
42
|
+
old_write_timeout = Stripe.write_timeout
|
42
43
|
|
43
44
|
begin
|
44
45
|
# Make sure any global initialization here is undone in the `ensure`
|
@@ -47,6 +48,7 @@ module Stripe
|
|
47
48
|
|
48
49
|
Stripe.open_timeout = 123
|
49
50
|
Stripe.read_timeout = 456
|
51
|
+
Stripe.write_timeout = 789 if WRITE_TIMEOUT_SUPPORTED
|
50
52
|
|
51
53
|
conn = @manager.connection_for("https://stripe.com")
|
52
54
|
|
@@ -63,6 +65,7 @@ module Stripe
|
|
63
65
|
# Timeouts
|
64
66
|
assert_equal 123, conn.open_timeout
|
65
67
|
assert_equal 456, conn.read_timeout
|
68
|
+
assert_equal 789, conn.write_timeout if WRITE_TIMEOUT_SUPPORTED
|
66
69
|
|
67
70
|
assert_equal true, conn.use_ssl?
|
68
71
|
assert_equal OpenSSL::SSL::VERIFY_PEER, conn.verify_mode
|
@@ -72,6 +75,7 @@ module Stripe
|
|
72
75
|
|
73
76
|
Stripe.open_timeout = old_open_timeout
|
74
77
|
Stripe.read_timeout = old_read_timeout
|
78
|
+
Stripe.write_timeout = old_write_timeout if WRITE_TIMEOUT_SUPPORTED
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
@@ -56,9 +56,9 @@ module Stripe
|
|
56
56
|
context "#delete_discount" do
|
57
57
|
should "delete a discount" do
|
58
58
|
customer = Stripe::Customer.retrieve("cus_123")
|
59
|
-
|
60
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/customers
|
61
|
-
assert
|
59
|
+
discount = customer.delete_discount
|
60
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/discount"
|
61
|
+
assert discount.is_a?(Stripe::Discount)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/test/stripe/payout_test.rb
CHANGED
@@ -53,5 +53,20 @@ module Stripe
|
|
53
53
|
assert payout.is_a?(Stripe::Payout)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context "#reverse" do
|
58
|
+
should "reverse a payout" do
|
59
|
+
payout = Stripe::Payout.retrieve("tr_123")
|
60
|
+
payout = payout.reverse
|
61
|
+
assert payout.is_a?(Stripe::Payout)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context ".reverse" do
|
66
|
+
should "reverse a payout" do
|
67
|
+
payout = Stripe::Payout.reverse("pm_123")
|
68
|
+
assert payout.is_a?(Stripe::Payout)
|
69
|
+
end
|
70
|
+
end
|
56
71
|
end
|
57
72
|
end
|
@@ -16,6 +16,7 @@ module Stripe
|
|
16
16
|
assert_equal 0, config.max_network_retries
|
17
17
|
assert_equal 30, config.open_timeout
|
18
18
|
assert_equal 80, config.read_timeout
|
19
|
+
assert_equal 30, config.write_timeout
|
19
20
|
assert_equal "https://api.stripe.com", config.api_base
|
20
21
|
assert_equal "https://connect.stripe.com", config.connect_base
|
21
22
|
assert_equal "https://files.stripe.com", config.uploads_base
|
@@ -25,10 +26,12 @@ module Stripe
|
|
25
26
|
config = Stripe::StripeConfiguration.setup do |c|
|
26
27
|
c.open_timeout = 100
|
27
28
|
c.read_timeout = 100
|
29
|
+
c.write_timeout = 100 if WRITE_TIMEOUT_SUPPORTED
|
28
30
|
end
|
29
31
|
|
30
32
|
assert_equal 100, config.open_timeout
|
31
33
|
assert_equal 100, config.read_timeout
|
34
|
+
assert_equal 100, config.write_timeout if WRITE_TIMEOUT_SUPPORTED
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
data/test/stripe_test.rb
CHANGED
@@ -54,6 +54,19 @@ class StripeTest < Test::Unit::TestCase
|
|
54
54
|
assert_equal 10, Stripe.read_timeout
|
55
55
|
end
|
56
56
|
|
57
|
+
if WRITE_TIMEOUT_SUPPORTED
|
58
|
+
should "allow write timeout to be configured" do
|
59
|
+
Stripe.write_timeout = 10
|
60
|
+
assert_equal 10, Stripe.write_timeout
|
61
|
+
end
|
62
|
+
else
|
63
|
+
should "raise when write timeout to be configured is not supported" do
|
64
|
+
assert_raises NotImplementedError do
|
65
|
+
Stripe.write_timeout = 10
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
57
70
|
should "allow api_key to be configured" do
|
58
71
|
Stripe.api_key = "sk_local_test"
|
59
72
|
assert_equal "sk_local_test", Stripe.api_key
|
data/test/test_helper.rb
CHANGED
@@ -16,7 +16,7 @@ require ::File.expand_path("test_data", __dir__)
|
|
16
16
|
require ::File.expand_path("stripe_mock", __dir__)
|
17
17
|
|
18
18
|
# If changing this number, please also change it in `.travis.yml`.
|
19
|
-
MOCK_MINIMUM_VERSION = "0.
|
19
|
+
MOCK_MINIMUM_VERSION = "0.103.0"
|
20
20
|
MOCK_PORT = Stripe::StripeMock.start
|
21
21
|
|
22
22
|
# Disable all real network connections except those that are outgoing to
|
@@ -56,6 +56,8 @@ module Test
|
|
56
56
|
include Stripe::TestData
|
57
57
|
include Mocha
|
58
58
|
|
59
|
+
WRITE_TIMEOUT_SUPPORTED = Net::HTTP.instance_methods.include?(:write_timeout=)
|
60
|
+
|
59
61
|
setup do
|
60
62
|
Stripe.api_key = "sk_test_123"
|
61
63
|
Stripe.api_base = "http://localhost:#{MOCK_PORT}"
|
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: 5.
|
4
|
+
version: 5.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
14
14
|
for details.
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/stripe/resources/balance.rb
|
65
65
|
- lib/stripe/resources/balance_transaction.rb
|
66
66
|
- lib/stripe/resources/bank_account.rb
|
67
|
+
- lib/stripe/resources/billing_portal/configuration.rb
|
67
68
|
- lib/stripe/resources/billing_portal/session.rb
|
68
69
|
- lib/stripe/resources/bitcoin_receiver.rb
|
69
70
|
- lib/stripe/resources/bitcoin_transaction.rb
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- test/stripe/balance_test.rb
|
159
160
|
- test/stripe/balance_transaction_test.rb
|
160
161
|
- test/stripe/bank_account_test.rb
|
162
|
+
- test/stripe/billing_portal/configuration_test.rb
|
161
163
|
- test/stripe/billing_portal/session_test.rb
|
162
164
|
- test/stripe/capability_test.rb
|
163
165
|
- test/stripe/charge_test.rb
|
@@ -278,6 +280,7 @@ test_files:
|
|
278
280
|
- test/stripe/balance_test.rb
|
279
281
|
- test/stripe/balance_transaction_test.rb
|
280
282
|
- test/stripe/bank_account_test.rb
|
283
|
+
- test/stripe/billing_portal/configuration_test.rb
|
281
284
|
- test/stripe/billing_portal/session_test.rb
|
282
285
|
- test/stripe/capability_test.rb
|
283
286
|
- test/stripe/charge_test.rb
|