stripe 14.0.0 → 15.0.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/CHANGELOG.md +20 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/lib/stripe/api_operations/save.rb +2 -1
- data/lib/stripe/api_operations/singleton_save.rb +2 -1
- data/lib/stripe/api_requestor.rb +3 -1
- data/lib/stripe/api_resource.rb +10 -3
- data/lib/stripe/request_options.rb +2 -1
- data/lib/stripe/resources/source.rb +1 -1
- data/lib/stripe/services/v2/core/event_service.rb +5 -3
- data/lib/stripe/stripe_object.rb +14 -4
- data/lib/stripe/util.rb +11 -0
- data/lib/stripe/version.rb +1 -1
- data/rbi/stripe/services/v2/core/event_service.rbi +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ac9a4371f393b1650cd2b5198d4e2ceed046c9676183b0d339fd985c4b8b815
|
4
|
+
data.tar.gz: 3fc59d72c6450657a7797088c39f5c85d9b8bba505992cfc3fdbdc7a8d27fb7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f156649ca332eff3a2837ec1f038ebcc8ab9f5c35194d031e2610b45ef6b74cb0b651b3402d0afa98375a7ac293f0e54761e191dd6237e58e372b42b2cba681
|
7
|
+
data.tar.gz: 1cb72620268bf94d44b0ddd6090b41404efc0b25606759907c2a3d6821577b45b488738bdfdac34b6ba3a6e9fb769d9646ad1b184580d84fac3df6451a0fd172
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,24 @@
|
|
1
1
|
# Changelog
|
2
|
+
## 15.0.0 - 2025-04-09
|
3
|
+
|
4
|
+
### Breaking change
|
5
|
+
* [#1574](https://github.com/stripe/stripe-ruby/pull/1574) Rename `object_id` in V2::Core::EventService::ListParams to `object_id_`
|
6
|
+
* ⚠️ Change name of parameter from `object_id` to `object_id_` on `Stripe::V2::Core::EventService::ListParams` to avoid conflict with Ruby native attribute, as found in https://github.com/stripe/stripe-ruby/issues/1567
|
7
|
+
* This is a no-op unless you are using this specific parameter that was introduced in `v14.0.0`
|
8
|
+
|
9
|
+
* [#1576](https://github.com/stripe/stripe-ruby/pull/1576) Explicitly pass through custom headers in retrieve
|
10
|
+
* Fix custom options passing for resource-based retrieve
|
11
|
+
* [#1571](https://github.com/stripe/stripe-ruby/pull/1571) Validate all instance variable keys returned from the API
|
12
|
+
* Validate all keys returned from the API, including custom response fields, to make sure they can be set in an instance variable, as brought up in https://github.com/stripe/stripe-ruby/issues/1564
|
13
|
+
* We do not set instance variables for invalid field names (as defined by the [Ruby spec](https://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#ident)). We recommend for custom hash map response fields, use the `[]` accessor.
|
14
|
+
```ruby
|
15
|
+
c = client.v1.customers.retrieve("cus_123")
|
16
|
+
c.metadata["invalid-variable-name!"]
|
17
|
+
c.metadata["valid_key_name_works_too"]
|
18
|
+
```
|
19
|
+
* [#1575](https://github.com/stripe/stripe-ruby/pull/1575) Remove unused youtube playlist link
|
20
|
+
* [#1573](https://github.com/stripe/stripe-ruby/pull/1573) Remove link for stale youtube video playlist
|
21
|
+
|
2
22
|
## 14.0.0 - 2025-04-01
|
3
23
|
* [#1559](https://github.com/stripe/stripe-ruby/pull/1559) Add RBI annotations for fields and params
|
4
24
|
* Adds explicit field types for resources and parameters for methods, and add RBI static annotations for all resources and services
|
data/README.md
CHANGED
@@ -20,8 +20,6 @@ The library also provides other features. For example:
|
|
20
20
|
|
21
21
|
See the [Ruby API docs](https://stripe.com/docs/api?lang=ruby).
|
22
22
|
|
23
|
-
See [video demonstrations][youtube-playlist] covering how to use the library.
|
24
|
-
|
25
23
|
## Installation
|
26
24
|
|
27
25
|
You don't need this source code unless you want to modify the gem. If you just
|
@@ -158,6 +156,9 @@ print(customer.last_response.http_status) # to retrieve status code
|
|
158
156
|
print(customer.last_response.http_headers) # to retrieve headers
|
159
157
|
```
|
160
158
|
|
159
|
+
If you are accessing a response field with custom hashes provided by you, such as `Customer.metadata`,
|
160
|
+
please access your fields with the `[]` accessor.
|
161
|
+
|
161
162
|
### Configuring a proxy
|
162
163
|
|
163
164
|
A proxy can be configured with `Stripe.proxy`:
|
@@ -444,7 +445,6 @@ Update the bundled [stripe-mock] by editing the version number found in
|
|
444
445
|
[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=ruby
|
445
446
|
[stripe-mock]: https://github.com/stripe/stripe-mock
|
446
447
|
[versioning]: https://stripe.com/docs/api/versioning?lang=ruby
|
447
|
-
[youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M50RmP6ie-gdcSnfOuQCRYk
|
448
448
|
|
449
449
|
<!--
|
450
450
|
# vim: set tw=79:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
15.0.0
|
@@ -67,7 +67,8 @@ module Stripe
|
|
67
67
|
values.delete(:id)
|
68
68
|
opts = Util.normalize_opts(opts)
|
69
69
|
APIRequestor.active_requestor.execute_request_initialize_from(:post, save_url, :api, self,
|
70
|
-
params: values,
|
70
|
+
params: values,
|
71
|
+
opts: RequestOptions.extract_opts_from_hash(opts),
|
71
72
|
usage: ["save"])
|
72
73
|
end
|
73
74
|
extend Gem::Deprecate
|
@@ -64,7 +64,8 @@ module Stripe
|
|
64
64
|
opts = Util.normalize_opts(opts)
|
65
65
|
|
66
66
|
APIRequestor.active_requestor.execute_request_initialize_from(:post, resource_url, :api, self,
|
67
|
-
params: values,
|
67
|
+
params: values,
|
68
|
+
opts: RequestOptions.extract_opts_from_hash(opts),
|
68
69
|
usage: ["save"])
|
69
70
|
end
|
70
71
|
extend Gem::Deprecate
|
data/lib/stripe/api_requestor.rb
CHANGED
@@ -220,9 +220,11 @@ module Stripe
|
|
220
220
|
# with future non-major changes.
|
221
221
|
def execute_request_initialize_from(method, path, base_address, object,
|
222
222
|
params: {}, opts: {}, usage: [])
|
223
|
-
opts = RequestOptions.combine_opts(object.instance_variable_get(:@opts), opts)
|
223
|
+
opts = RequestOptions.combine_opts(object.instance_variable_get(:@opts) || {}, opts)
|
224
224
|
opts = Util.normalize_opts(opts)
|
225
|
+
|
225
226
|
params = params.to_h if params.is_a?(RequestParams)
|
227
|
+
|
226
228
|
http_resp, req_opts = execute_request_internal(
|
227
229
|
method, path, base_address, params, opts, usage
|
228
230
|
)
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -98,7 +98,10 @@ module Stripe
|
|
98
98
|
"It is not possible to refresh v2 objects. Please retrieve the object using the StripeClient instead."
|
99
99
|
end
|
100
100
|
|
101
|
-
|
101
|
+
opts = RequestOptions.extract_opts_from_hash(@retrieve_opts || {})
|
102
|
+
@retrieve_opts = {} # Make sure to clear the retrieve options
|
103
|
+
@obj = @requestor.execute_request_initialize_from(:get, resource_url, :api, self, params: @retrieve_params,
|
104
|
+
opts: opts)
|
102
105
|
initialize_from(
|
103
106
|
@obj.last_response.data,
|
104
107
|
@obj.instance_variable_get(:@opts),
|
@@ -114,8 +117,12 @@ module Stripe
|
|
114
117
|
"It is not possible to retrieve v2 objects on the resource. Please use the StripeClient instead."
|
115
118
|
end
|
116
119
|
|
117
|
-
|
118
|
-
|
120
|
+
instance = new(id)
|
121
|
+
# Explicitly send options for the retrieve call, to preserve custom headers
|
122
|
+
# This is so we can pass custom headers from this static function
|
123
|
+
# to the instance variable method call
|
124
|
+
# The custom headers will be cleaned up with the rest of the RequestOptions
|
125
|
+
instance.instance_variable_set(:@retrieve_opts, Util.normalize_opts(opts))
|
119
126
|
instance.refresh
|
120
127
|
end
|
121
128
|
|
@@ -56,7 +56,7 @@ module Stripe
|
|
56
56
|
# Merges requestor options hash on a StripeObject
|
57
57
|
# with a per-request options hash, giving precedence
|
58
58
|
# to the per-request options. Returns the merged request options.
|
59
|
-
# Expects two hashes
|
59
|
+
# Expects two hashes, expects extract_opts_from_hash to be called first!!!
|
60
60
|
def self.combine_opts(object_opts, req_opts)
|
61
61
|
merged_opts = {
|
62
62
|
api_key: req_opts[:api_key] || object_opts[:api_key],
|
@@ -64,6 +64,7 @@ module Stripe
|
|
64
64
|
stripe_account: req_opts[:stripe_account] || object_opts[:stripe_account],
|
65
65
|
stripe_context: req_opts[:stripe_context] || object_opts[:stripe_context],
|
66
66
|
stripe_version: req_opts[:stripe_version] || object_opts[:stripe_version],
|
67
|
+
headers: req_opts[:headers] || {},
|
67
68
|
}
|
68
69
|
|
69
70
|
# Remove nil values from headers
|
@@ -1270,7 +1270,7 @@ module Stripe
|
|
1270
1270
|
"/#{CGI.escape(id)}"
|
1271
1271
|
opts = Util.normalize_opts(opts)
|
1272
1272
|
APIRequestor.active_requestor.execute_request_initialize_from(:delete, url, :api, self,
|
1273
|
-
params: params, opts: opts)
|
1273
|
+
params: params, opts: RequestOptions.extract_opts_from_hash(opts))
|
1274
1274
|
end
|
1275
1275
|
|
1276
1276
|
def source_transactions(params = {}, opts = {})
|
@@ -9,11 +9,13 @@ module Stripe
|
|
9
9
|
# The page size.
|
10
10
|
attr_accessor :limit
|
11
11
|
# Primary object ID used to retrieve related events.
|
12
|
-
|
12
|
+
#
|
13
|
+
# To avoid conflict with Ruby's ':object_id', this attribute has been renamed. If using a hash parameter map instead, please use the original name ':object_id' with NO trailing underscore as the provided param key.
|
14
|
+
attr_accessor :object_id_
|
13
15
|
|
14
|
-
def initialize(limit: nil,
|
16
|
+
def initialize(limit: nil, object_id_: nil)
|
15
17
|
@limit = limit
|
16
|
-
@
|
18
|
+
@object_id_ = object_id_
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -336,7 +336,7 @@ module Stripe
|
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
|
-
protected def add_accessors(keys, values)
|
339
|
+
protected def add_accessors(keys, values) # rubocop:todo Metrics/PerceivedComplexity
|
340
340
|
# not available in the #instance_eval below
|
341
341
|
protected_fields = self.class.protected_fields
|
342
342
|
|
@@ -372,7 +372,16 @@ module Stripe
|
|
372
372
|
end
|
373
373
|
|
374
374
|
keys.each do |k|
|
375
|
-
|
375
|
+
if Util.valid_variable_name?(k)
|
376
|
+
instance_variable_set(:"@#{k}", values[k])
|
377
|
+
else
|
378
|
+
Util.log_info(<<~LOG
|
379
|
+
The variable name '#{k}' is not a valid Ruby variable name.
|
380
|
+
Use ["#{k}"] to access this field, skipping instance variable instantiation...
|
381
|
+
LOG
|
382
|
+
)
|
383
|
+
|
384
|
+
end
|
376
385
|
end
|
377
386
|
end
|
378
387
|
|
@@ -473,13 +482,14 @@ module Stripe
|
|
473
482
|
|
474
483
|
# Should only be for v2 events and lists, for now.
|
475
484
|
protected def _request(method:, path:, base_address:, params: {}, opts: {})
|
476
|
-
req_opts = RequestOptions.
|
485
|
+
req_opts = RequestOptions.extract_opts_from_hash(opts)
|
486
|
+
req_opts = RequestOptions.combine_opts(@opts, req_opts)
|
477
487
|
@requestor.execute_request(
|
478
488
|
method,
|
479
489
|
path,
|
480
490
|
base_address,
|
481
491
|
params: params,
|
482
|
-
opts:
|
492
|
+
opts: req_opts
|
483
493
|
)
|
484
494
|
end
|
485
495
|
|
data/lib/stripe/util.rb
CHANGED
@@ -4,6 +4,9 @@ require "cgi"
|
|
4
4
|
|
5
5
|
module Stripe
|
6
6
|
module Util
|
7
|
+
LEGAL_FIRST_CHARACTER = /[a-zA-Z_]/.freeze
|
8
|
+
LEGAL_VARIABLE_CHARACTER = /[a-zA-Z0-9_]/.freeze
|
9
|
+
|
7
10
|
def self.objects_to_ids(obj)
|
8
11
|
case obj
|
9
12
|
when APIResource
|
@@ -309,6 +312,14 @@ module Stripe
|
|
309
312
|
end
|
310
313
|
end
|
311
314
|
|
315
|
+
# Return false for strings that are invalid variable names
|
316
|
+
# Does NOT expect there to be a preceding '@' for instance variables
|
317
|
+
def self.valid_variable_name?(key)
|
318
|
+
return false if key.empty? || key[0] !~ LEGAL_FIRST_CHARACTER
|
319
|
+
|
320
|
+
key[1..-1].chars.all? { |char| char =~ LEGAL_VARIABLE_CHARACTER }
|
321
|
+
end
|
322
|
+
|
312
323
|
def self.check_string_argument!(key)
|
313
324
|
raise TypeError, "argument must be a string" unless key.is_a?(String)
|
314
325
|
|
data/lib/stripe/version.rb
CHANGED
@@ -11,10 +11,12 @@ module Stripe
|
|
11
11
|
sig { returns(T.nilable(Integer)) }
|
12
12
|
attr_accessor :limit
|
13
13
|
# Primary object ID used to retrieve related events.
|
14
|
+
#
|
15
|
+
# To avoid conflict with Ruby's ':object_id', this attribute has been renamed. If using a hash parameter map instead, please use the original name ':object_id' with NO trailing underscore as the provided param key.
|
14
16
|
sig { returns(String) }
|
15
|
-
attr_accessor :
|
16
|
-
sig { params(limit: T.nilable(Integer),
|
17
|
-
def initialize(limit: nil,
|
17
|
+
attr_accessor :object_id_
|
18
|
+
sig { params(limit: T.nilable(Integer), object_id_: String).void }
|
19
|
+
def initialize(limit: nil, object_id_: nil); end
|
18
20
|
end
|
19
21
|
class RetrieveParams < Stripe::RequestParams
|
20
22
|
|
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:
|
4
|
+
version: 15.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-09 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.
|