stripe 5.23.1 → 5.28.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 +4 -4
- data/.travis.yml +1 -3
- data/CHANGELOG.md +16 -0
- data/README.md +24 -23
- data/VERSION +1 -1
- data/lib/stripe.rb +33 -166
- 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/issuing/dispute.rb +11 -0
- data/lib/stripe/resources/payout.rb +10 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/stripe_configuration.rb +178 -0
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +7 -7
- data/test/stripe/connection_manager_test.rb +4 -0
- data/test/stripe/customer_card_test.rb +6 -0
- data/test/stripe/customer_test.rb +1 -1
- data/test/stripe/issuing/dispute_test.rb +20 -1
- data/test/stripe/payout_test.rb +15 -0
- data/test/stripe/product_test.rb +1 -2
- data/test/stripe/setup_attempt_test.rb +16 -0
- data/test/stripe/stripe_configuration_test.rb +131 -0
- data/test/stripe_test.rb +101 -19
- data/test/test_helper.rb +3 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc768f1967f8b5d8d925a101dffc820bd4dfa96155cecc9bd86926cb30f07cbe
|
|
4
|
+
data.tar.gz: 7dcd29fb83035f6f6af335bf3a4acde40ea4ce7e0e097413b9f76c696bb3e529
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e911a5c3138805c0aeb5abe270186e4d4219b8414e3336579cda3caa02ad32797d0d088cce8468156f4dff27a6ff55ac107419e7a0b01040eec36be8684073d7
|
|
7
|
+
data.tar.gz: 6fd38cd5ffde35f1065ce18104382f106eec79fb3494099e49723745ada158f7f63df1164653a6ada3fe0c62ae0ed764cbf9e40e878f4e3bb4dbd6c799cffbfa
|
data/.travis.yml
CHANGED
|
@@ -12,12 +12,10 @@ notifications:
|
|
|
12
12
|
email:
|
|
13
13
|
on_success: never
|
|
14
14
|
|
|
15
|
-
sudo: false
|
|
16
|
-
|
|
17
15
|
env:
|
|
18
16
|
global:
|
|
19
17
|
# If changing this number, please also change it in `test/test_helper.rb`.
|
|
20
|
-
- STRIPE_MOCK_VERSION=0.
|
|
18
|
+
- STRIPE_MOCK_VERSION=0.101.0
|
|
21
19
|
|
|
22
20
|
cache:
|
|
23
21
|
directories:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.28.0 - 2020-10-14
|
|
4
|
+
* [#950](https://github.com/stripe/stripe-ruby/pull/950) Add configuration option for `write_timeout` for connections on Ruby 2.6+
|
|
5
|
+
|
|
6
|
+
## 5.27.0 - 2020-10-14
|
|
7
|
+
* [#951](https://github.com/stripe/stripe-ruby/pull/951) Add support for the Payout Reverse API
|
|
8
|
+
|
|
9
|
+
## 5.26.0 - 2020-09-29
|
|
10
|
+
* [#949](https://github.com/stripe/stripe-ruby/pull/949) Add support for the `SetupAttempt` resource and List API
|
|
11
|
+
|
|
12
|
+
## 5.25.0 - 2020-09-02
|
|
13
|
+
* [#944](https://github.com/stripe/stripe-ruby/pull/944) Add support for the Issuing Dispute Submit API
|
|
14
|
+
|
|
15
|
+
## 5.24.0 - 2020-08-26
|
|
16
|
+
* [#939](https://github.com/stripe/stripe-ruby/pull/939) Extract configurations into separate object
|
|
17
|
+
* [#940](https://github.com/stripe/stripe-ruby/pull/940) Fix typo in documentation of `stripe_object.rb`
|
|
18
|
+
|
|
3
19
|
## 5.23.1 - 2020-08-05
|
|
4
20
|
* [#936](https://github.com/stripe/stripe-ruby/pull/936) Rename API resource's `request` method
|
|
5
21
|
|
data/README.md
CHANGED
|
@@ -60,14 +60,14 @@ available in your [Stripe Dashboard][api-keys]. Set `Stripe.api_key` to its
|
|
|
60
60
|
value:
|
|
61
61
|
|
|
62
62
|
```ruby
|
|
63
|
-
require
|
|
64
|
-
Stripe.api_key =
|
|
63
|
+
require 'stripe'
|
|
64
|
+
Stripe.api_key = 'sk_test_...'
|
|
65
65
|
|
|
66
66
|
# list customers
|
|
67
67
|
Stripe::Customer.list()
|
|
68
68
|
|
|
69
69
|
# retrieve single customer
|
|
70
|
-
Stripe::Customer.retrieve(
|
|
70
|
+
Stripe::Customer.retrieve('cus_123456789')
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### Per-request Configuration
|
|
@@ -82,38 +82,38 @@ require "stripe"
|
|
|
82
82
|
Stripe::Customer.list(
|
|
83
83
|
{},
|
|
84
84
|
{
|
|
85
|
-
api_key:
|
|
86
|
-
stripe_account:
|
|
87
|
-
stripe_version:
|
|
85
|
+
api_key: 'sk_test_...',
|
|
86
|
+
stripe_account: 'acct_...',
|
|
87
|
+
stripe_version: '2018-02-28',
|
|
88
88
|
}
|
|
89
89
|
)
|
|
90
90
|
|
|
91
91
|
Stripe::Customer.retrieve(
|
|
92
|
-
|
|
92
|
+
'cus_123456789',
|
|
93
93
|
{
|
|
94
|
-
api_key:
|
|
95
|
-
stripe_account:
|
|
96
|
-
stripe_version:
|
|
94
|
+
api_key: 'sk_test_...',
|
|
95
|
+
stripe_account: 'acct_...',
|
|
96
|
+
stripe_version: '2018-02-28',
|
|
97
97
|
}
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
Stripe::Customer.retrieve(
|
|
101
101
|
{
|
|
102
|
-
id:
|
|
102
|
+
id: 'cus_123456789',
|
|
103
103
|
expand: %w(balance_transaction)
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
|
-
stripe_version:
|
|
107
|
-
api_key:
|
|
106
|
+
stripe_version: '2018-02-28',
|
|
107
|
+
api_key: 'sk_test_...',
|
|
108
108
|
}
|
|
109
109
|
)
|
|
110
110
|
|
|
111
111
|
Stripe::Customer.capture(
|
|
112
|
-
|
|
112
|
+
'cus_123456789',
|
|
113
113
|
{},
|
|
114
114
|
{
|
|
115
|
-
stripe_version:
|
|
116
|
-
api_key:
|
|
115
|
+
stripe_version: '2018-02-28',
|
|
116
|
+
api_key: 'sk_test_...',
|
|
117
117
|
}
|
|
118
118
|
)
|
|
119
119
|
```
|
|
@@ -136,7 +136,7 @@ method:
|
|
|
136
136
|
```ruby
|
|
137
137
|
client = Stripe::StripeClient.new
|
|
138
138
|
customer, resp = client.request do
|
|
139
|
-
Stripe::Customer.retrieve(
|
|
139
|
+
Stripe::Customer.retrieve('cus_123456789',)
|
|
140
140
|
end
|
|
141
141
|
puts resp.request_id
|
|
142
142
|
```
|
|
@@ -146,7 +146,7 @@ puts resp.request_id
|
|
|
146
146
|
A proxy can be configured with `Stripe.proxy`:
|
|
147
147
|
|
|
148
148
|
```ruby
|
|
149
|
-
Stripe.proxy =
|
|
149
|
+
Stripe.proxy = 'https://user:pass@example.com:1234'
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
### Configuring an API Version
|
|
@@ -155,7 +155,7 @@ By default, the library will use the API version pinned to the account making
|
|
|
155
155
|
a request. This can be overridden with this global option:
|
|
156
156
|
|
|
157
157
|
```ruby
|
|
158
|
-
Stripe.api_version =
|
|
158
|
+
Stripe.api_version = '2018-02-28'
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
See [versioning in the API reference][versioning] for more information.
|
|
@@ -166,7 +166,7 @@ By default, the library will use its own internal bundle of known CA
|
|
|
166
166
|
certificates, but it's possible to configure your own:
|
|
167
167
|
|
|
168
168
|
```ruby
|
|
169
|
-
Stripe.ca_bundle_path =
|
|
169
|
+
Stripe.ca_bundle_path = 'path/to/ca/bundle'
|
|
170
170
|
```
|
|
171
171
|
|
|
172
172
|
### Configuring Automatic Retries
|
|
@@ -186,11 +186,12 @@ retries are safe.
|
|
|
186
186
|
|
|
187
187
|
### Configuring Timeouts
|
|
188
188
|
|
|
189
|
-
Open and
|
|
189
|
+
Open, read and write timeouts are configurable:
|
|
190
190
|
|
|
191
191
|
```ruby
|
|
192
192
|
Stripe.open_timeout = 30 # in seconds
|
|
193
193
|
Stripe.read_timeout = 80
|
|
194
|
+
Stripe.write_timeout = 30 # only supported on Ruby 2.6+
|
|
194
195
|
```
|
|
195
196
|
|
|
196
197
|
Please take care to set conservative read timeouts. Some API requests can take
|
|
@@ -258,7 +259,7 @@ For example:
|
|
|
258
259
|
Stripe::Instrumentation.subscribe(:request_end) do |request_event|
|
|
259
260
|
tags = {
|
|
260
261
|
method: request_event.method,
|
|
261
|
-
resource: request_event.path.split(
|
|
262
|
+
resource: request_event.path.split('/')[2],
|
|
262
263
|
code: request_event.http_status,
|
|
263
264
|
retries: request_event.num_retries
|
|
264
265
|
}
|
|
@@ -272,7 +273,7 @@ If you're writing a plugin that uses the library, we'd appreciate it if you
|
|
|
272
273
|
identified using `#set_app_info`:
|
|
273
274
|
|
|
274
275
|
```ruby
|
|
275
|
-
Stripe.set_app_info(
|
|
276
|
+
Stripe.set_app_info('MyAwesomePlugin', version: '1.2.34', url: 'https://myawesomeplugin.info')
|
|
276
277
|
```
|
|
277
278
|
|
|
278
279
|
This information is passed along when the library makes calls to the Stripe
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.
|
|
1
|
+
5.28.0
|
data/lib/stripe.rb
CHANGED
|
@@ -12,6 +12,7 @@ require "securerandom"
|
|
|
12
12
|
require "set"
|
|
13
13
|
require "socket"
|
|
14
14
|
require "uri"
|
|
15
|
+
require "forwardable"
|
|
15
16
|
|
|
16
17
|
# Version
|
|
17
18
|
require "stripe/version"
|
|
@@ -38,6 +39,7 @@ require "stripe/error_object"
|
|
|
38
39
|
require "stripe/api_resource"
|
|
39
40
|
require "stripe/singleton_api_resource"
|
|
40
41
|
require "stripe/webhook"
|
|
42
|
+
require "stripe/stripe_configuration"
|
|
41
43
|
|
|
42
44
|
# Named API resources
|
|
43
45
|
require "stripe/resources"
|
|
@@ -48,47 +50,42 @@ require "stripe/oauth"
|
|
|
48
50
|
module Stripe
|
|
49
51
|
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@uploads_base = "https://files.stripe.com"
|
|
56
|
-
|
|
57
|
-
@log_level = nil
|
|
58
|
-
@logger = nil
|
|
59
|
-
|
|
60
|
-
@proxy = nil
|
|
61
|
-
|
|
62
|
-
@max_network_retries = 0
|
|
63
|
-
@max_network_retry_delay = 2
|
|
64
|
-
@initial_network_retry_delay = 0.5
|
|
65
|
-
|
|
66
|
-
@ca_bundle_path = DEFAULT_CA_BUNDLE_PATH
|
|
67
|
-
@ca_store = nil
|
|
68
|
-
@verify_ssl_certs = true
|
|
53
|
+
# map to the same values as the standard library's logger
|
|
54
|
+
LEVEL_DEBUG = Logger::DEBUG
|
|
55
|
+
LEVEL_ERROR = Logger::ERROR
|
|
56
|
+
LEVEL_INFO = Logger::INFO
|
|
69
57
|
|
|
70
|
-
@
|
|
71
|
-
@read_timeout = 80
|
|
58
|
+
@app_info = nil
|
|
72
59
|
|
|
73
|
-
@
|
|
60
|
+
@configuration = Stripe::StripeConfiguration.setup
|
|
74
61
|
|
|
75
62
|
class << self
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
extend Forwardable
|
|
64
|
+
|
|
65
|
+
# User configurable options
|
|
66
|
+
def_delegators :@configuration, :api_key, :api_key=
|
|
67
|
+
def_delegators :@configuration, :api_version, :api_version=
|
|
68
|
+
def_delegators :@configuration, :stripe_account, :stripe_account=
|
|
69
|
+
def_delegators :@configuration, :api_base, :api_base=
|
|
70
|
+
def_delegators :@configuration, :uploads_base, :uploads_base=
|
|
71
|
+
def_delegators :@configuration, :connect_base, :connect_base=
|
|
72
|
+
def_delegators :@configuration, :open_timeout, :open_timeout=
|
|
73
|
+
def_delegators :@configuration, :read_timeout, :read_timeout=
|
|
74
|
+
def_delegators :@configuration, :write_timeout, :write_timeout=
|
|
75
|
+
def_delegators :@configuration, :proxy, :proxy=
|
|
76
|
+
def_delegators :@configuration, :verify_ssl_certs, :verify_ssl_certs=
|
|
77
|
+
def_delegators :@configuration, :ca_bundle_path, :ca_bundle_path=
|
|
78
|
+
def_delegators :@configuration, :log_level, :log_level=
|
|
79
|
+
def_delegators :@configuration, :logger, :logger=
|
|
80
|
+
def_delegators :@configuration, :max_network_retries, :max_network_retries=
|
|
81
|
+
def_delegators :@configuration, :enable_telemetry=, :enable_telemetry?
|
|
82
|
+
|
|
83
|
+
# Internal configurations
|
|
84
|
+
def_delegators :@configuration, :max_network_retry_delay
|
|
85
|
+
def_delegators :@configuration, :initial_network_retry_delay
|
|
86
|
+
def_delegators :@configuration, :ca_store
|
|
87
|
+
|
|
78
88
|
attr_accessor :client_id
|
|
79
|
-
attr_accessor :stripe_account
|
|
80
|
-
|
|
81
|
-
# These all get manual attribute writers so that we can reset connections
|
|
82
|
-
# if they change.
|
|
83
|
-
attr_reader :api_base
|
|
84
|
-
attr_reader :connect_base
|
|
85
|
-
attr_reader :open_timeout
|
|
86
|
-
attr_reader :proxy
|
|
87
|
-
attr_reader :read_timeout
|
|
88
|
-
attr_reader :uploads_base
|
|
89
|
-
attr_reader :verify_ssl_certs
|
|
90
|
-
|
|
91
|
-
attr_reader :max_network_retry_delay, :initial_network_retry_delay
|
|
92
89
|
end
|
|
93
90
|
|
|
94
91
|
# Gets the application for a plugin that's identified some. See
|
|
@@ -101,126 +98,6 @@ module Stripe
|
|
|
101
98
|
@app_info = info
|
|
102
99
|
end
|
|
103
100
|
|
|
104
|
-
def self.api_base=(api_base)
|
|
105
|
-
@api_base = api_base
|
|
106
|
-
StripeClient.clear_all_connection_managers
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# The location of a file containing a bundle of CA certificates. By default
|
|
110
|
-
# the library will use an included bundle that can successfully validate
|
|
111
|
-
# Stripe certificates.
|
|
112
|
-
def self.ca_bundle_path
|
|
113
|
-
@ca_bundle_path
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def self.ca_bundle_path=(path)
|
|
117
|
-
@ca_bundle_path = path
|
|
118
|
-
|
|
119
|
-
# empty this field so a new store is initialized
|
|
120
|
-
@ca_store = nil
|
|
121
|
-
|
|
122
|
-
StripeClient.clear_all_connection_managers
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
|
126
|
-
# which is used to validate TLS on every request.
|
|
127
|
-
#
|
|
128
|
-
# This was added to the give the gem "pseudo thread safety" in that it seems
|
|
129
|
-
# when initiating many parallel requests marshaling the certificate store is
|
|
130
|
-
# the most likely point of failure (see issue #382). Any program attempting
|
|
131
|
-
# to leverage this pseudo safety should make a call to this method (i.e.
|
|
132
|
-
# `Stripe.ca_store`) in their initialization code because it marshals lazily
|
|
133
|
-
# and is itself not thread safe.
|
|
134
|
-
def self.ca_store
|
|
135
|
-
@ca_store ||= begin
|
|
136
|
-
store = OpenSSL::X509::Store.new
|
|
137
|
-
store.add_file(ca_bundle_path)
|
|
138
|
-
store
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def self.connect_base=(connect_base)
|
|
143
|
-
@connect_base = connect_base
|
|
144
|
-
StripeClient.clear_all_connection_managers
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def self.enable_telemetry?
|
|
148
|
-
@enable_telemetry
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def self.enable_telemetry=(val)
|
|
152
|
-
@enable_telemetry = val
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
# map to the same values as the standard library's logger
|
|
156
|
-
LEVEL_DEBUG = Logger::DEBUG
|
|
157
|
-
LEVEL_ERROR = Logger::ERROR
|
|
158
|
-
LEVEL_INFO = Logger::INFO
|
|
159
|
-
|
|
160
|
-
# When set prompts the library to log some extra information to $stdout and
|
|
161
|
-
# $stderr about what it's doing. For example, it'll produce information about
|
|
162
|
-
# requests, responses, and errors that are received. Valid log levels are
|
|
163
|
-
# `debug` and `info`, with `debug` being a little more verbose in places.
|
|
164
|
-
#
|
|
165
|
-
# Use of this configuration is only useful when `.logger` is _not_ set. When
|
|
166
|
-
# it is, the decision what levels to print is entirely deferred to the logger.
|
|
167
|
-
def self.log_level
|
|
168
|
-
@log_level
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
def self.log_level=(val)
|
|
172
|
-
# Backwards compatibility for values that we briefly allowed
|
|
173
|
-
if val == "debug"
|
|
174
|
-
val = LEVEL_DEBUG
|
|
175
|
-
elsif val == "info"
|
|
176
|
-
val = LEVEL_INFO
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
|
|
180
|
-
raise ArgumentError,
|
|
181
|
-
"log_level should only be set to `nil`, `debug` or `info`"
|
|
182
|
-
end
|
|
183
|
-
@log_level = val
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# Sets a logger to which logging output will be sent. The logger should
|
|
187
|
-
# support the same interface as the `Logger` class that's part of Ruby's
|
|
188
|
-
# standard library (hint, anything in `Rails.logger` will likely be
|
|
189
|
-
# suitable).
|
|
190
|
-
#
|
|
191
|
-
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
|
|
192
|
-
# what levels to print is entirely deferred to the logger.
|
|
193
|
-
def self.logger
|
|
194
|
-
@logger
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
def self.logger=(val)
|
|
198
|
-
@logger = val
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def self.max_network_retries
|
|
202
|
-
@max_network_retries
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def self.max_network_retries=(val)
|
|
206
|
-
@max_network_retries = val.to_i
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def self.open_timeout=(open_timeout)
|
|
210
|
-
@open_timeout = open_timeout
|
|
211
|
-
StripeClient.clear_all_connection_managers
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def self.proxy=(proxy)
|
|
215
|
-
@proxy = proxy
|
|
216
|
-
StripeClient.clear_all_connection_managers
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def self.read_timeout=(read_timeout)
|
|
220
|
-
@read_timeout = read_timeout
|
|
221
|
-
StripeClient.clear_all_connection_managers
|
|
222
|
-
end
|
|
223
|
-
|
|
224
101
|
# Sets some basic information about the running application that's sent along
|
|
225
102
|
# with API requests. Useful for plugin authors to identify their plugin when
|
|
226
103
|
# communicating with Stripe.
|
|
@@ -234,16 +111,6 @@ module Stripe
|
|
|
234
111
|
version: version,
|
|
235
112
|
}
|
|
236
113
|
end
|
|
237
|
-
|
|
238
|
-
def self.uploads_base=(uploads_base)
|
|
239
|
-
@uploads_base = uploads_base
|
|
240
|
-
StripeClient.clear_all_connection_managers
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
def self.verify_ssl_certs=(verify_ssl_certs)
|
|
244
|
-
@verify_ssl_certs = verify_ssl_certs
|
|
245
|
-
StripeClient.clear_all_connection_managers
|
|
246
|
-
end
|
|
247
114
|
end
|
|
248
115
|
|
|
249
116
|
Stripe.log_level = ENV["STRIPE_LOG"] unless ENV["STRIPE_LOG"].nil?
|
|
@@ -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
|
@@ -73,6 +73,7 @@ module Stripe
|
|
|
73
73
|
Reversal::OBJECT_NAME => Reversal,
|
|
74
74
|
Review::OBJECT_NAME => Review,
|
|
75
75
|
SKU::OBJECT_NAME => SKU,
|
|
76
|
+
SetupAttempt::OBJECT_NAME => SetupAttempt,
|
|
76
77
|
SetupIntent::OBJECT_NAME => SetupIntent,
|
|
77
78
|
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
|
78
79
|
Source::OBJECT_NAME => Source,
|
data/lib/stripe/resources.rb
CHANGED
|
@@ -61,6 +61,7 @@ require "stripe/resources/reporting/report_run"
|
|
|
61
61
|
require "stripe/resources/reporting/report_type"
|
|
62
62
|
require "stripe/resources/reversal"
|
|
63
63
|
require "stripe/resources/review"
|
|
64
|
+
require "stripe/resources/setup_attempt"
|
|
64
65
|
require "stripe/resources/setup_intent"
|
|
65
66
|
require "stripe/resources/sigma/scheduled_query_run"
|
|
66
67
|
require "stripe/resources/sku"
|
|
@@ -9,6 +9,17 @@ module Stripe
|
|
|
9
9
|
include Stripe::APIOperations::Save
|
|
10
10
|
|
|
11
11
|
OBJECT_NAME = "issuing.dispute"
|
|
12
|
+
|
|
13
|
+
custom_method :submit, http_verb: :post
|
|
14
|
+
|
|
15
|
+
def submit(params = {}, opts = {})
|
|
16
|
+
request_stripe_object(
|
|
17
|
+
method: :post,
|
|
18
|
+
path: resource_url + "/submit",
|
|
19
|
+
params: params,
|
|
20
|
+
opts: opts
|
|
21
|
+
)
|
|
22
|
+
end
|
|
12
23
|
end
|
|
13
24
|
end
|
|
14
25
|
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
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stripe
|
|
4
|
+
# Configurable options:
|
|
5
|
+
#
|
|
6
|
+
# =ca_bundle_path=
|
|
7
|
+
# The location of a file containing a bundle of CA certificates. By default
|
|
8
|
+
# the library will use an included bundle that can successfully validate
|
|
9
|
+
# Stripe certificates.
|
|
10
|
+
#
|
|
11
|
+
# =log_level=
|
|
12
|
+
# When set prompts the library to log some extra information to $stdout and
|
|
13
|
+
# $stderr about what it's doing. For example, it'll produce information about
|
|
14
|
+
# requests, responses, and errors that are received. Valid log levels are
|
|
15
|
+
# `debug` and `info`, with `debug` being a little more verbose in places.
|
|
16
|
+
#
|
|
17
|
+
# Use of this configuration is only useful when `.logger` is _not_ set. When
|
|
18
|
+
# it is, the decision what levels to print is entirely deferred to the logger.
|
|
19
|
+
#
|
|
20
|
+
# =logger=
|
|
21
|
+
# The logger should support the same interface as the `Logger` class that's
|
|
22
|
+
# part of Ruby's standard library (hint, anything in `Rails.logger` will
|
|
23
|
+
# likely be suitable).
|
|
24
|
+
#
|
|
25
|
+
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
|
|
26
|
+
# what levels to print is entirely deferred to the logger.
|
|
27
|
+
class StripeConfiguration
|
|
28
|
+
attr_accessor :api_key
|
|
29
|
+
attr_accessor :api_version
|
|
30
|
+
attr_accessor :client_id
|
|
31
|
+
attr_accessor :enable_telemetry
|
|
32
|
+
attr_accessor :logger
|
|
33
|
+
attr_accessor :stripe_account
|
|
34
|
+
|
|
35
|
+
attr_reader :api_base
|
|
36
|
+
attr_reader :uploads_base
|
|
37
|
+
attr_reader :connect_base
|
|
38
|
+
attr_reader :ca_bundle_path
|
|
39
|
+
attr_reader :log_level
|
|
40
|
+
attr_reader :initial_network_retry_delay
|
|
41
|
+
attr_reader :max_network_retries
|
|
42
|
+
attr_reader :max_network_retry_delay
|
|
43
|
+
attr_reader :open_timeout
|
|
44
|
+
attr_reader :read_timeout
|
|
45
|
+
attr_reader :write_timeout
|
|
46
|
+
attr_reader :proxy
|
|
47
|
+
attr_reader :verify_ssl_certs
|
|
48
|
+
|
|
49
|
+
def self.setup
|
|
50
|
+
new.tap do |instance|
|
|
51
|
+
yield(instance) if block_given?
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Create a new config based off an existing one. This is useful when the
|
|
56
|
+
# caller wants to override the global configuration
|
|
57
|
+
def reverse_duplicate_merge(hash)
|
|
58
|
+
dup.tap do |instance|
|
|
59
|
+
hash.each do |option, value|
|
|
60
|
+
instance.public_send("#{option}=", value)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def initialize
|
|
66
|
+
@ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
|
|
67
|
+
@enable_telemetry = true
|
|
68
|
+
@verify_ssl_certs = true
|
|
69
|
+
|
|
70
|
+
@max_network_retries = 0
|
|
71
|
+
@initial_network_retry_delay = 0.5
|
|
72
|
+
@max_network_retry_delay = 2
|
|
73
|
+
|
|
74
|
+
@open_timeout = 30
|
|
75
|
+
@read_timeout = 80
|
|
76
|
+
@write_timeout = 30
|
|
77
|
+
|
|
78
|
+
@api_base = "https://api.stripe.com"
|
|
79
|
+
@connect_base = "https://connect.stripe.com"
|
|
80
|
+
@uploads_base = "https://files.stripe.com"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def log_level=(val)
|
|
84
|
+
# Backwards compatibility for values that we briefly allowed
|
|
85
|
+
if val == "debug"
|
|
86
|
+
val = Stripe::LEVEL_DEBUG
|
|
87
|
+
elsif val == "info"
|
|
88
|
+
val = Stripe::LEVEL_INFO
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
levels = [Stripe::LEVEL_INFO, Stripe::LEVEL_DEBUG, Stripe::LEVEL_ERROR]
|
|
92
|
+
|
|
93
|
+
if !val.nil? && !levels.include?(val)
|
|
94
|
+
raise ArgumentError,
|
|
95
|
+
"log_level should only be set to `nil`, `debug` or `info`"
|
|
96
|
+
end
|
|
97
|
+
@log_level = val
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def max_network_retries=(val)
|
|
101
|
+
@max_network_retries = val.to_i
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def open_timeout=(open_timeout)
|
|
105
|
+
@open_timeout = open_timeout
|
|
106
|
+
StripeClient.clear_all_connection_managers
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def read_timeout=(read_timeout)
|
|
110
|
+
@read_timeout = read_timeout
|
|
111
|
+
StripeClient.clear_all_connection_managers
|
|
112
|
+
end
|
|
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
|
+
|
|
123
|
+
def proxy=(proxy)
|
|
124
|
+
@proxy = proxy
|
|
125
|
+
StripeClient.clear_all_connection_managers
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def verify_ssl_certs=(verify_ssl_certs)
|
|
129
|
+
@verify_ssl_certs = verify_ssl_certs
|
|
130
|
+
StripeClient.clear_all_connection_managers
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def uploads_base=(uploads_base)
|
|
134
|
+
@uploads_base = uploads_base
|
|
135
|
+
StripeClient.clear_all_connection_managers
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def connect_base=(connect_base)
|
|
139
|
+
@connect_base = connect_base
|
|
140
|
+
StripeClient.clear_all_connection_managers
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def api_base=(api_base)
|
|
144
|
+
@api_base = api_base
|
|
145
|
+
StripeClient.clear_all_connection_managers
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def ca_bundle_path=(path)
|
|
149
|
+
@ca_bundle_path = path
|
|
150
|
+
|
|
151
|
+
# empty this field so a new store is initialized
|
|
152
|
+
@ca_store = nil
|
|
153
|
+
|
|
154
|
+
StripeClient.clear_all_connection_managers
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
|
158
|
+
# which is used to validate TLS on every request.
|
|
159
|
+
#
|
|
160
|
+
# This was added to the give the gem "pseudo thread safety" in that it seems
|
|
161
|
+
# when initiating many parallel requests marshaling the certificate store is
|
|
162
|
+
# the most likely point of failure (see issue #382). Any program attempting
|
|
163
|
+
# to leverage this pseudo safety should make a call to this method (i.e.
|
|
164
|
+
# `Stripe.ca_store`) in their initialization code because it marshals lazily
|
|
165
|
+
# and is itself not thread safe.
|
|
166
|
+
def ca_store
|
|
167
|
+
@ca_store ||= begin
|
|
168
|
+
store = OpenSSL::X509::Store.new
|
|
169
|
+
store.add_file(ca_bundle_path)
|
|
170
|
+
store
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def enable_telemetry?
|
|
175
|
+
enable_telemetry
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
data/lib/stripe/stripe_object.rb
CHANGED
|
@@ -375,7 +375,7 @@ module Stripe
|
|
|
375
375
|
begin
|
|
376
376
|
super
|
|
377
377
|
rescue NoMethodError => e
|
|
378
|
-
# If we notice the accessed name
|
|
378
|
+
# If we notice the accessed name of our set of transient values we can
|
|
379
379
|
# give the user a slightly more helpful error message. If not, just
|
|
380
380
|
# raise right away.
|
|
381
381
|
raise unless @transient_values.include?(name)
|
data/lib/stripe/version.rb
CHANGED
|
@@ -111,15 +111,15 @@ module Stripe
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
should "send expand when fetching through ListObject" do
|
|
114
|
-
stub_request(:get, "#{Stripe.api_base}/v1/
|
|
115
|
-
.to_return(body: JSON.generate(
|
|
114
|
+
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
|
115
|
+
.to_return(body: JSON.generate(charge_fixture))
|
|
116
116
|
|
|
117
|
-
stub_request(:get, "#{Stripe.api_base}/v1/
|
|
118
|
-
.with(query: { "expand" => ["
|
|
119
|
-
.to_return(body: JSON.generate(
|
|
117
|
+
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123/refunds/re_123")
|
|
118
|
+
.with(query: { "expand" => ["balance_transaction"] })
|
|
119
|
+
.to_return(body: JSON.generate(charge_fixture))
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
|
122
|
+
charge.refunds.retrieve(id: "re_123", expand: [:balance_transaction])
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
context "when specifying per-object credentials" do
|
|
@@ -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
|
|
|
@@ -5,6 +5,12 @@ require ::File.expand_path("../test_helper", __dir__)
|
|
|
5
5
|
module Stripe
|
|
6
6
|
class CustomerCardTest < Test::Unit::TestCase
|
|
7
7
|
setup do
|
|
8
|
+
# Unfortunately, the OpenAPI spec has an issue where the sources list has the wrong
|
|
9
|
+
# url so we need to mock this call instead.
|
|
10
|
+
customer_json = { id: "cus_123", object: "customer", sources: { object: "list", data: [], has_more: true, url: "/v1/customers/cus_123/sources" } }
|
|
11
|
+
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
|
|
12
|
+
.to_return(body: JSON.generate(customer_json))
|
|
13
|
+
|
|
8
14
|
@customer = Stripe::Customer.retrieve("cus_123")
|
|
9
15
|
end
|
|
10
16
|
|
|
@@ -57,7 +57,7 @@ module Stripe
|
|
|
57
57
|
should "delete a discount" do
|
|
58
58
|
customer = Stripe::Customer.retrieve("cus_123")
|
|
59
59
|
customer = customer.delete_discount
|
|
60
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/customers
|
|
60
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/discount"
|
|
61
61
|
assert customer.is_a?(Stripe::Customer)
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -6,7 +6,7 @@ module Stripe
|
|
|
6
6
|
module Issuing
|
|
7
7
|
class DisputeTest < Test::Unit::TestCase
|
|
8
8
|
should "be creatable" do
|
|
9
|
-
dispute = Stripe::Issuing::Dispute.create
|
|
9
|
+
dispute = Stripe::Issuing::Dispute.create(transaction: "ipi_123")
|
|
10
10
|
|
|
11
11
|
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes"
|
|
12
12
|
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
|
@@ -30,6 +30,25 @@ module Stripe
|
|
|
30
30
|
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/ich_123"
|
|
31
31
|
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
context "#submit" do
|
|
35
|
+
should "submit the dispute" do
|
|
36
|
+
dispute = Stripe::Issuing::Dispute.retrieve("idp_123")
|
|
37
|
+
dispute = dispute.submit
|
|
38
|
+
assert_requested :post,
|
|
39
|
+
"#{Stripe.api_base}/v1/issuing/disputes/idp_123/submit"
|
|
40
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context ".submit" do
|
|
45
|
+
should "submit the dispute" do
|
|
46
|
+
dispute = Stripe::Issuing::Dispute.submit("idp_123")
|
|
47
|
+
assert_requested :post,
|
|
48
|
+
"#{Stripe.api_base}/v1/issuing/disputes/idp_123/submit"
|
|
49
|
+
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
33
52
|
end
|
|
34
53
|
end
|
|
35
54
|
end
|
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
|
data/test/stripe/product_test.rb
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
+
|
|
5
|
+
module Stripe
|
|
6
|
+
class SetupAttemptTest < Test::Unit::TestCase
|
|
7
|
+
should "be listable" do
|
|
8
|
+
setup_attempts = Stripe::SetupAttempt.list({
|
|
9
|
+
setup_intent: "seti_123",
|
|
10
|
+
})
|
|
11
|
+
assert_requested :get, "#{Stripe.api_base}/v1/setup_attempts?setup_intent=seti_123"
|
|
12
|
+
assert setup_attempts.data.is_a?(Array)
|
|
13
|
+
assert setup_attempts.data[0].is_a?(Stripe::SetupAttempt)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
+
|
|
5
|
+
module Stripe
|
|
6
|
+
class StripeConfigurationTest < Test::Unit::TestCase
|
|
7
|
+
context ".setup" do
|
|
8
|
+
should "initialize a new configuration with defaults" do
|
|
9
|
+
config = Stripe::StripeConfiguration.setup
|
|
10
|
+
|
|
11
|
+
assert_equal Stripe::DEFAULT_CA_BUNDLE_PATH, config.ca_bundle_path
|
|
12
|
+
assert_equal true, config.enable_telemetry
|
|
13
|
+
assert_equal true, config.verify_ssl_certs
|
|
14
|
+
assert_equal 2, config.max_network_retry_delay
|
|
15
|
+
assert_equal 0.5, config.initial_network_retry_delay
|
|
16
|
+
assert_equal 0, config.max_network_retries
|
|
17
|
+
assert_equal 30, config.open_timeout
|
|
18
|
+
assert_equal 80, config.read_timeout
|
|
19
|
+
assert_equal 30, config.write_timeout
|
|
20
|
+
assert_equal "https://api.stripe.com", config.api_base
|
|
21
|
+
assert_equal "https://connect.stripe.com", config.connect_base
|
|
22
|
+
assert_equal "https://files.stripe.com", config.uploads_base
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "allow for overrides when a block is passed" do
|
|
26
|
+
config = Stripe::StripeConfiguration.setup do |c|
|
|
27
|
+
c.open_timeout = 100
|
|
28
|
+
c.read_timeout = 100
|
|
29
|
+
c.write_timeout = 100 if WRITE_TIMEOUT_SUPPORTED
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
assert_equal 100, config.open_timeout
|
|
33
|
+
assert_equal 100, config.read_timeout
|
|
34
|
+
assert_equal 100, config.write_timeout if WRITE_TIMEOUT_SUPPORTED
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "#reverse_duplicate_merge" do
|
|
39
|
+
should "return a duplicate object with overrides" do
|
|
40
|
+
config = Stripe::StripeConfiguration.setup do |c|
|
|
41
|
+
c.open_timeout = 100
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
duped_config = config.reverse_duplicate_merge(read_timeout: 500)
|
|
45
|
+
|
|
46
|
+
assert_equal config.open_timeout, duped_config.open_timeout
|
|
47
|
+
assert_equal 500, duped_config.read_timeout
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "#max_network_retries=" do
|
|
52
|
+
should "coerce the option into an integer" do
|
|
53
|
+
config = Stripe::StripeConfiguration.setup
|
|
54
|
+
|
|
55
|
+
config.max_network_retries = "10"
|
|
56
|
+
assert_equal 10, config.max_network_retries
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context "#log_level=" do
|
|
61
|
+
should "be backwards compatible with old values" do
|
|
62
|
+
config = Stripe::StripeConfiguration.setup
|
|
63
|
+
|
|
64
|
+
config.log_level = "debug"
|
|
65
|
+
assert_equal Stripe::LEVEL_DEBUG, config.log_level
|
|
66
|
+
|
|
67
|
+
config.log_level = "info"
|
|
68
|
+
assert_equal Stripe::LEVEL_INFO, config.log_level
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
should "raise an error if the value isn't valid" do
|
|
72
|
+
config = Stripe::StripeConfiguration.setup
|
|
73
|
+
|
|
74
|
+
assert_raises ArgumentError do
|
|
75
|
+
config.log_level = "Foo"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "options that require all connection managers to be cleared" do
|
|
81
|
+
should "clear when setting allow ca_bundle_path" do
|
|
82
|
+
config = Stripe::StripeConfiguration.setup
|
|
83
|
+
|
|
84
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
85
|
+
config.ca_bundle_path = "/path/to/ca/bundle"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
should "clear when setting open timeout" do
|
|
89
|
+
config = Stripe::StripeConfiguration.setup
|
|
90
|
+
|
|
91
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
92
|
+
config.open_timeout = 10
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
should "clear when setting read timeout" do
|
|
96
|
+
config = Stripe::StripeConfiguration.setup
|
|
97
|
+
|
|
98
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
99
|
+
config.read_timeout = 10
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
should "clear when setting uploads_base" do
|
|
103
|
+
config = Stripe::StripeConfiguration.setup
|
|
104
|
+
|
|
105
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
106
|
+
config.uploads_base = "https://other.stripe.com"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
should "clearn when setting api_base to be configured" do
|
|
110
|
+
config = Stripe::StripeConfiguration.setup
|
|
111
|
+
|
|
112
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
113
|
+
config.api_base = "https://other.stripe.com"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
should "clear when setting connect_base" do
|
|
117
|
+
config = Stripe::StripeConfiguration.setup
|
|
118
|
+
|
|
119
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
120
|
+
config.connect_base = "https://other.stripe.com"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
should "clear when setting verify_ssl_certs" do
|
|
124
|
+
config = Stripe::StripeConfiguration.setup
|
|
125
|
+
|
|
126
|
+
StripeClient.expects(:clear_all_connection_managers)
|
|
127
|
+
config.verify_ssl_certs = false
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
data/test/stripe_test.rb
CHANGED
|
@@ -23,28 +23,110 @@ class StripeTest < Test::Unit::TestCase
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
context "forwardable configurations" do
|
|
27
|
+
context "internal configurations" do
|
|
28
|
+
should "return the certificate store" do
|
|
29
|
+
assert Stripe.ca_store.is_a?(OpenSSL::X509::Store)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
should "return the max_network_retry_delay" do
|
|
33
|
+
assert_equal 2, Stripe.max_network_retry_delay
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "return the initial_network_retry_delay" do
|
|
37
|
+
assert_equal 0.5, Stripe.initial_network_retry_delay
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
|
-
end
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Stripe.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
should "allow ca_bundle_path to be configured" do
|
|
42
|
+
Stripe::StripeClient.expects(:clear_all_connection_managers)
|
|
43
|
+
Stripe.ca_bundle_path = "/path/to/ca/bundle"
|
|
44
|
+
assert_equal "/path/to/ca/bundle", Stripe.ca_bundle_path
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should "allow open timeout to be configured" do
|
|
48
|
+
Stripe.open_timeout = 10
|
|
49
|
+
assert_equal 10, Stripe.open_timeout
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
should "allow read timeout to be configured" do
|
|
53
|
+
Stripe.read_timeout = 10
|
|
54
|
+
assert_equal 10, Stripe.read_timeout
|
|
55
|
+
end
|
|
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
|
+
|
|
70
|
+
should "allow api_key to be configured" do
|
|
71
|
+
Stripe.api_key = "sk_local_test"
|
|
72
|
+
assert_equal "sk_local_test", Stripe.api_key
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
should "allow stripe_account to be configured" do
|
|
76
|
+
Stripe.stripe_account = "acct_1234"
|
|
77
|
+
assert_equal "acct_1234", Stripe.stripe_account
|
|
43
78
|
end
|
|
44
|
-
end
|
|
45
79
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
80
|
+
should "allow enable_telemetry to be configured" do
|
|
81
|
+
begin
|
|
82
|
+
old = Stripe.enable_telemetry?
|
|
83
|
+
|
|
84
|
+
Stripe.enable_telemetry = false
|
|
85
|
+
assert_equal false, Stripe.enable_telemetry?
|
|
86
|
+
ensure
|
|
87
|
+
Stripe.enable_telemetry = old
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
should "allow log_level to be configured" do
|
|
92
|
+
Stripe.log_level = "debug"
|
|
93
|
+
assert_equal ::Logger::DEBUG, Stripe.log_level
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
should "allow logger to be configured" do
|
|
97
|
+
logger = Object.new
|
|
98
|
+
Stripe.logger = logger
|
|
99
|
+
assert_equal logger, Stripe.logger
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
should "allow proxy to be configured" do
|
|
103
|
+
Stripe.proxy = "http://proxy"
|
|
104
|
+
assert_equal "http://proxy", Stripe.proxy
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
should "allow uploads_base to be configured" do
|
|
108
|
+
Stripe.uploads_base = "https://other.stripe.com"
|
|
109
|
+
assert_equal "https://other.stripe.com", Stripe.uploads_base
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
should "allow api_base to be configured" do
|
|
113
|
+
Stripe.api_base = "https://other.stripe.com"
|
|
114
|
+
assert_equal "https://other.stripe.com", Stripe.api_base
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
should "allow connect_base to be configured" do
|
|
118
|
+
Stripe.connect_base = "https://other.stripe.com"
|
|
119
|
+
assert_equal "https://other.stripe.com", Stripe.connect_base
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
should "allow verify_ssl_certs to be configured" do
|
|
123
|
+
Stripe.verify_ssl_certs = false
|
|
124
|
+
assert_equal false, Stripe.verify_ssl_certs
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
should "allow client_id to be configured" do
|
|
128
|
+
Stripe.client_id = "client"
|
|
129
|
+
assert_equal "client", Stripe.client_id
|
|
130
|
+
end
|
|
49
131
|
end
|
|
50
132
|
end
|
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.101.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.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-10-14 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.
|
|
@@ -116,6 +116,7 @@ files:
|
|
|
116
116
|
- lib/stripe/resources/reporting/report_type.rb
|
|
117
117
|
- lib/stripe/resources/reversal.rb
|
|
118
118
|
- lib/stripe/resources/review.rb
|
|
119
|
+
- lib/stripe/resources/setup_attempt.rb
|
|
119
120
|
- lib/stripe/resources/setup_intent.rb
|
|
120
121
|
- lib/stripe/resources/sigma/scheduled_query_run.rb
|
|
121
122
|
- lib/stripe/resources/sku.rb
|
|
@@ -138,6 +139,7 @@ files:
|
|
|
138
139
|
- lib/stripe/resources/webhook_endpoint.rb
|
|
139
140
|
- lib/stripe/singleton_api_resource.rb
|
|
140
141
|
- lib/stripe/stripe_client.rb
|
|
142
|
+
- lib/stripe/stripe_configuration.rb
|
|
141
143
|
- lib/stripe/stripe_object.rb
|
|
142
144
|
- lib/stripe/stripe_response.rb
|
|
143
145
|
- lib/stripe/util.rb
|
|
@@ -206,11 +208,13 @@ files:
|
|
|
206
208
|
- test/stripe/reporting/report_type_test.rb
|
|
207
209
|
- test/stripe/reversal_test.rb
|
|
208
210
|
- test/stripe/review_test.rb
|
|
211
|
+
- test/stripe/setup_attempt_test.rb
|
|
209
212
|
- test/stripe/setup_intent_test.rb
|
|
210
213
|
- test/stripe/sigma/scheduled_query_run_test.rb
|
|
211
214
|
- test/stripe/sku_test.rb
|
|
212
215
|
- test/stripe/source_test.rb
|
|
213
216
|
- test/stripe/stripe_client_test.rb
|
|
217
|
+
- test/stripe/stripe_configuration_test.rb
|
|
214
218
|
- test/stripe/stripe_object_test.rb
|
|
215
219
|
- test/stripe/stripe_response_test.rb
|
|
216
220
|
- test/stripe/subscription_item_test.rb
|
|
@@ -324,11 +328,13 @@ test_files:
|
|
|
324
328
|
- test/stripe/reporting/report_type_test.rb
|
|
325
329
|
- test/stripe/reversal_test.rb
|
|
326
330
|
- test/stripe/review_test.rb
|
|
331
|
+
- test/stripe/setup_attempt_test.rb
|
|
327
332
|
- test/stripe/setup_intent_test.rb
|
|
328
333
|
- test/stripe/sigma/scheduled_query_run_test.rb
|
|
329
334
|
- test/stripe/sku_test.rb
|
|
330
335
|
- test/stripe/source_test.rb
|
|
331
336
|
- test/stripe/stripe_client_test.rb
|
|
337
|
+
- test/stripe/stripe_configuration_test.rb
|
|
332
338
|
- test/stripe/stripe_object_test.rb
|
|
333
339
|
- test/stripe/stripe_response_test.rb
|
|
334
340
|
- test/stripe/subscription_item_test.rb
|