stripe 10.1.0 → 10.2.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 +13 -0
- data/Gemfile +5 -2
- data/OPENAPI_VERSION +1 -1
- data/Rakefile +7 -5
- data/VERSION +1 -1
- data/bin/stripe-console +1 -1
- data/lib/stripe/api_operations/request.rb +3 -5
- data/lib/stripe/api_operations/save.rb +5 -7
- data/lib/stripe/api_resource_test_helpers.rb +2 -2
- data/lib/stripe/connection_manager.rb +4 -6
- data/lib/stripe/errors.rb +3 -11
- data/lib/stripe/instrumentation.rb +5 -21
- data/lib/stripe/multipart_encoder.rb +7 -7
- data/lib/stripe/oauth.rb +6 -6
- data/lib/stripe/object_types.rb +3 -0
- data/lib/stripe/resources/account.rb +6 -10
- data/lib/stripe/resources/alipay_account.rb +1 -1
- data/lib/stripe/resources/application_fee_refund.rb +1 -1
- data/lib/stripe/resources/bank_account.rb +2 -2
- data/lib/stripe/resources/capability.rb +1 -1
- data/lib/stripe/resources/climate/order.rb +34 -0
- data/lib/stripe/resources/climate/product.rb +14 -0
- data/lib/stripe/resources/climate/supplier.rb +13 -0
- data/lib/stripe/resources/event.rb +2 -2
- data/lib/stripe/resources/file.rb +2 -4
- data/lib/stripe/resources/reversal.rb +1 -1
- data/lib/stripe/resources/tax_id.rb +1 -1
- data/lib/stripe/resources.rb +3 -0
- data/lib/stripe/stripe_client.rb +25 -42
- data/lib/stripe/stripe_configuration.rb +13 -29
- data/lib/stripe/stripe_object.rb +15 -18
- data/lib/stripe/stripe_response.rb +1 -3
- data/lib/stripe/util.rb +10 -12
- data/lib/stripe/version.rb +1 -1
- data/stripe.gemspec +3 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1175af77634044ef0ef6efda0626ace1431bdb4ad52eb78c643af4eba8982faf
|
4
|
+
data.tar.gz: 19863ceeab18b449560dc647213d5873eadb190db544015e88749b5e79414528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24f1e67f729c964e150bf991140467c85d2b85430da3a7d736cd6b6ae5a9ce8afac2664e27fb3df51d472eb23b1ae67f5933e019e8c6fd9c7639d32e4713a334
|
7
|
+
data.tar.gz: 28dee05f7251e400ba32ace17cb0e8e78f63bfa156ba36c9d6f3baa7cc6d361d0e86826a962a117e70cd774628183eddf70d0379c9c485a74192b9844c3855c5
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
# Changelog
|
2
|
+
## 10.2.0 - 2023-11-30
|
3
|
+
* [#1292](https://github.com/stripe/stripe-ruby/pull/1292) Update generated code
|
4
|
+
* Add support for new resources `Climate.Order`, `Climate.Product`, and `Climate.Supplier`
|
5
|
+
* Add support for `cancel`, `create`, `list`, `retrieve`, and `update` methods on resource `Order`
|
6
|
+
* Add support for `list` and `retrieve` methods on resources `Product` and `Supplier`
|
7
|
+
* [#1295](https://github.com/stripe/stripe-ruby/pull/1295) Upgrade rubocop
|
8
|
+
* [#1291](https://github.com/stripe/stripe-ruby/pull/1291) Update generated code
|
9
|
+
|
10
|
+
* [#1290](https://github.com/stripe/stripe-ruby/pull/1290) Update generated code
|
11
|
+
|
12
|
+
* [#1288](https://github.com/stripe/stripe-ruby/pull/1288) Update generated code
|
13
|
+
|
14
|
+
|
2
15
|
## 10.1.0 - 2023-11-02
|
3
16
|
* [#1286](https://github.com/stripe/stripe-ruby/pull/1286) Update generated code
|
4
17
|
* Add support for new resource `Tax.Registration`
|
data/Gemfile
CHANGED
@@ -23,10 +23,13 @@ group :development do
|
|
23
23
|
# `Gemfile.lock` checked in, so to prevent good builds from suddenly going
|
24
24
|
# bad, pin to a specific version number here. Try to keep this relatively
|
25
25
|
# up-to-date, but it's not the end of the world if it's not.
|
26
|
-
|
26
|
+
#
|
27
|
+
# The latest version of rubocop is only compatible with Ruby 2.7+
|
28
|
+
gem "rubocop", "1.57.2" if RUBY_VERSION >= "2.7"
|
27
29
|
|
28
30
|
# jaro_winkler 1.5.5 installation fails for jruby
|
29
|
-
|
31
|
+
# don't install on truffleruby
|
32
|
+
gem "jaro_winkler", "1.5.4" unless RUBY_ENGINE == "truffleruby"
|
30
33
|
|
31
34
|
platforms :mri do
|
32
35
|
gem "byebug"
|
data/OPENAPI_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
v682
|
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rake/testtask"
|
4
|
-
require "rubocop/rake_task"
|
5
4
|
|
6
5
|
task default: %i[test rubocop]
|
7
6
|
|
@@ -9,7 +8,10 @@ Rake::TestTask.new do |t|
|
|
9
8
|
t.pattern = "./test/**/*_test.rb"
|
10
9
|
end
|
11
10
|
|
12
|
-
|
11
|
+
if RUBY_VERSION >= "2.7.0"
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
RuboCop::RakeTask.new
|
14
|
+
end
|
13
15
|
|
14
16
|
desc "Update bundled certs"
|
15
17
|
task :update_certs do
|
@@ -17,7 +19,7 @@ task :update_certs do
|
|
17
19
|
require "uri"
|
18
20
|
|
19
21
|
fetch_file "https://curl.haxx.se/ca/cacert.pem",
|
20
|
-
|
22
|
+
File.expand_path("lib/data/ca-certificates.crt", __dir__)
|
21
23
|
end
|
22
24
|
|
23
25
|
#
|
@@ -25,11 +27,11 @@ end
|
|
25
27
|
#
|
26
28
|
|
27
29
|
def fetch_file(uri, dest)
|
28
|
-
|
30
|
+
File.open(dest, "w") do |file|
|
29
31
|
resp = Net::HTTP.get_response(URI.parse(uri))
|
30
32
|
unless resp.code.to_i == 200
|
31
33
|
abort("bad response when fetching: #{uri}\n" \
|
32
|
-
|
34
|
+
"Status #{resp.code}: #{resp.body}")
|
33
35
|
end
|
34
36
|
file.write(resp.body)
|
35
37
|
puts "Successfully fetched: #{uri}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
10.
|
1
|
+
10.2.0
|
data/bin/stripe-console
CHANGED
@@ -87,7 +87,7 @@ module Stripe
|
|
87
87
|
|
88
88
|
raise ArgumentError,
|
89
89
|
"request option '#{opt}' should be a string value " \
|
90
|
-
|
90
|
+
"(was a #{val.class})"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -96,14 +96,12 @@ module Stripe
|
|
96
96
|
|
97
97
|
raise ArgumentError,
|
98
98
|
"request params should be either a Hash or nil " \
|
99
|
-
|
99
|
+
"(was a #{params.class})"
|
100
100
|
end
|
101
101
|
|
102
102
|
private def warn_on_opts_in_params(params)
|
103
103
|
Util::OPTS_USER_SPECIFIED.each do |opt|
|
104
|
-
if params.key?(opt)
|
105
|
-
warn("WARNING: '#{opt}' should be in opts instead of params.")
|
106
|
-
end
|
104
|
+
warn("WARNING: '#{opt}' should be in opts instead of params.") if params.key?(opt)
|
107
105
|
end
|
108
106
|
end
|
109
107
|
end
|
@@ -19,9 +19,7 @@ module Stripe
|
|
19
19
|
# {APIOperations::Request.execute_resource_request}.
|
20
20
|
def update(id, params = {}, opts = {})
|
21
21
|
params.each_key do |k|
|
22
|
-
if protected_fields.include?(k)
|
23
|
-
raise ArgumentError, "Cannot update protected field: #{k}"
|
24
|
-
end
|
22
|
+
raise ArgumentError, "Cannot update protected field: #{k}" if protected_fields.include?(k)
|
25
23
|
end
|
26
24
|
|
27
25
|
request_stripe_object(
|
@@ -64,7 +62,7 @@ module Stripe
|
|
64
62
|
|
65
63
|
values = serialize_params(self).merge(params)
|
66
64
|
|
67
|
-
# note that id gets removed here our call to #url above has already
|
65
|
+
# Please note that id gets removed here our call to #url above has already
|
68
66
|
# generated a uri for this object with an identifier baked in
|
69
67
|
values.delete(:id)
|
70
68
|
|
@@ -72,9 +70,9 @@ module Stripe
|
|
72
70
|
initialize_from(resp.data, opts)
|
73
71
|
end
|
74
72
|
extend Gem::Deprecate
|
75
|
-
deprecate :save, "the `update` class method (for examples"\
|
76
|
-
|
77
|
-
|
73
|
+
deprecate :save, "the `update` class method (for examples " \
|
74
|
+
"see https://github.com/stripe/stripe-ruby" \
|
75
|
+
"/wiki/Migration-guide-for-v8)", 2022, 11
|
78
76
|
|
79
77
|
def self.included(base)
|
80
78
|
# Set `metadata` as additive so that when it's set directly we remember
|
@@ -31,8 +31,8 @@ module Stripe
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.resource_url
|
34
|
-
"/v1/test_helpers/"\
|
35
|
-
|
34
|
+
"/v1/test_helpers/" \
|
35
|
+
"#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
|
36
36
|
end
|
37
37
|
|
38
38
|
def resource_url
|
@@ -157,9 +157,7 @@ module Stripe
|
|
157
157
|
|
158
158
|
connection.open_timeout = config.open_timeout
|
159
159
|
connection.read_timeout = config.read_timeout
|
160
|
-
if connection.respond_to?(:write_timeout=)
|
161
|
-
connection.write_timeout = config.write_timeout
|
162
|
-
end
|
160
|
+
connection.write_timeout = config.write_timeout if connection.respond_to?(:write_timeout=)
|
163
161
|
|
164
162
|
connection.use_ssl = uri.scheme == "https"
|
165
163
|
|
@@ -192,9 +190,9 @@ module Stripe
|
|
192
190
|
|
193
191
|
@verify_ssl_warned = true
|
194
192
|
warn("WARNING: Running without SSL cert verification. " \
|
195
|
-
|
196
|
-
|
197
|
-
|
193
|
+
"You should never do this in production. " \
|
194
|
+
"Execute `Stripe.verify_ssl_certs = true` to enable " \
|
195
|
+
"verification.")
|
198
196
|
end
|
199
197
|
end
|
200
198
|
end
|
data/lib/stripe/errors.rb
CHANGED
@@ -4,22 +4,14 @@ module Stripe
|
|
4
4
|
# StripeError is the base error from which all other more specific Stripe
|
5
5
|
# errors derive.
|
6
6
|
class StripeError < StandardError
|
7
|
-
attr_reader :message
|
7
|
+
attr_reader :message, :code, :error, :http_body, :http_headers, :http_status, :json_body, :request_id
|
8
8
|
|
9
9
|
# Response contains a StripeResponse object that has some basic information
|
10
10
|
# about the response that conveyed the error.
|
11
|
-
attr_accessor :response
|
12
|
-
|
13
|
-
attr_reader :code
|
14
|
-
attr_reader :error
|
15
|
-
attr_reader :http_body
|
16
|
-
attr_reader :http_headers
|
17
|
-
attr_reader :http_status
|
18
|
-
attr_reader :json_body # equivalent to #data
|
19
|
-
attr_reader :request_id
|
11
|
+
attr_accessor :response # equivalent to #data
|
20
12
|
|
21
13
|
# Initializes a StripeError.
|
22
|
-
def initialize(message = nil, http_status: nil, http_body: nil,
|
14
|
+
def initialize(message = nil, http_status: nil, http_body: nil, # rubocop:todo Lint/MissingSuper
|
23
15
|
json_body: nil, http_headers: nil, code: nil)
|
24
16
|
@message = message
|
25
17
|
@http_status = http_status
|
@@ -4,8 +4,7 @@ module Stripe
|
|
4
4
|
class Instrumentation
|
5
5
|
# Event emitted on `request_begin` callback.
|
6
6
|
class RequestBeginEvent
|
7
|
-
attr_reader :method
|
8
|
-
attr_reader :path
|
7
|
+
attr_reader :method, :path
|
9
8
|
|
10
9
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
11
10
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -27,16 +26,8 @@ module Stripe
|
|
27
26
|
|
28
27
|
# Event emitted on `request_end` callback.
|
29
28
|
class RequestEndEvent
|
30
|
-
attr_reader :duration
|
31
|
-
|
32
|
-
attr_reader :method
|
33
|
-
attr_reader :num_retries
|
34
|
-
attr_reader :path
|
35
|
-
attr_reader :request_id
|
36
|
-
attr_reader :response_header
|
37
|
-
attr_reader :response_body
|
38
|
-
attr_reader :request_header
|
39
|
-
attr_reader :request_body
|
29
|
+
attr_reader :duration, :http_status, :method, :num_retries, :path, :request_id, :response_header, :response_body,
|
30
|
+
:request_header, :request_body
|
40
31
|
|
41
32
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
42
33
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -62,12 +53,7 @@ module Stripe
|
|
62
53
|
end
|
63
54
|
|
64
55
|
class RequestContext
|
65
|
-
attr_reader :duration
|
66
|
-
attr_reader :method
|
67
|
-
attr_reader :path
|
68
|
-
attr_reader :request_id
|
69
|
-
attr_reader :body
|
70
|
-
attr_reader :header
|
56
|
+
attr_reader :duration, :method, :path, :request_id, :body, :header
|
71
57
|
|
72
58
|
def initialize(duration:, context:, header:)
|
73
59
|
@duration = duration
|
@@ -80,9 +66,7 @@ module Stripe
|
|
80
66
|
end
|
81
67
|
|
82
68
|
class ResponseContext
|
83
|
-
attr_reader :http_status
|
84
|
-
attr_reader :body
|
85
|
-
attr_reader :header
|
69
|
+
attr_reader :http_status, :body, :header
|
86
70
|
|
87
71
|
def initialize(http_status:, response:)
|
88
72
|
@http_status = http_status
|
@@ -106,22 +106,22 @@ module Stripe
|
|
106
106
|
end
|
107
107
|
|
108
108
|
private def write_field(name, data, filename:)
|
109
|
-
if
|
110
|
-
@body << "\r\n"
|
111
|
-
else
|
109
|
+
if @first_field
|
112
110
|
@first_field = false
|
111
|
+
else
|
112
|
+
@body << "\r\n"
|
113
113
|
end
|
114
114
|
|
115
115
|
@body << "--#{@boundary}\r\n"
|
116
116
|
|
117
117
|
if filename
|
118
|
-
@body << %(Content-Disposition: form-data) +
|
118
|
+
@body << (%(Content-Disposition: form-data) +
|
119
119
|
%(; name="#{escape(name.to_s)}") +
|
120
|
-
%(; filename="#{escape(filename)}"\r\n)
|
120
|
+
%(; filename="#{escape(filename)}"\r\n))
|
121
121
|
@body << %(Content-Type: application/octet-stream\r\n)
|
122
122
|
else
|
123
|
-
@body << %(Content-Disposition: form-data) +
|
124
|
-
%(; name="#{escape(name.to_s)}"\r\n)
|
123
|
+
@body << (%(Content-Disposition: form-data) +
|
124
|
+
%(; name="#{escape(name.to_s)}"\r\n))
|
125
125
|
end
|
126
126
|
|
127
127
|
@body << "\r\n"
|
data/lib/stripe/oauth.rb
CHANGED
@@ -18,12 +18,12 @@ module Stripe
|
|
18
18
|
client_id = params[:client_id] || Stripe.client_id
|
19
19
|
unless client_id
|
20
20
|
raise AuthenticationError, "No client_id provided. " \
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
'Set your client_id using "Stripe.client_id = <CLIENT-ID>". ' \
|
22
|
+
"You can find your client_ids in your Stripe dashboard at " \
|
23
|
+
"https://dashboard.stripe.com/account/applications/settings, " \
|
24
|
+
"after registering your account as a platform. See " \
|
25
|
+
"https://stripe.com/docs/connect/standalone-accounts for details, " \
|
26
|
+
"or email support@stripe.com if you have any questions."
|
27
27
|
end
|
28
28
|
client_id
|
29
29
|
end
|
data/lib/stripe/object_types.rb
CHANGED
@@ -29,6 +29,9 @@ module Stripe
|
|
29
29
|
CashBalance::OBJECT_NAME => CashBalance,
|
30
30
|
Charge::OBJECT_NAME => Charge,
|
31
31
|
Checkout::Session::OBJECT_NAME => Checkout::Session,
|
32
|
+
Climate::Order::OBJECT_NAME => Climate::Order,
|
33
|
+
Climate::Product::OBJECT_NAME => Climate::Product,
|
34
|
+
Climate::Supplier::OBJECT_NAME => Climate::Supplier,
|
32
35
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
33
36
|
Coupon::OBJECT_NAME => Coupon,
|
34
37
|
CreditNote::OBJECT_NAME => CreditNote,
|
@@ -123,17 +123,13 @@ module Stripe
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def serialize_params_account(_obj, update_hash, options = {})
|
126
|
-
if (entity = @values[:legal_entity])
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
serialize_additional_owners(entity, owners)
|
131
|
-
end
|
126
|
+
if (entity = @values[:legal_entity]) && (owners = entity[:additional_owners])
|
127
|
+
entity_update = update_hash[:legal_entity] ||= {}
|
128
|
+
entity_update[:additional_owners] =
|
129
|
+
serialize_additional_owners(entity, owners)
|
132
130
|
end
|
133
|
-
if (individual = @values[:individual])
|
134
|
-
|
135
|
-
update_hash[:individual] = individual.serialize_params(options)
|
136
|
-
end
|
131
|
+
if (individual = @values[:individual]) && (individual.is_a?(Person) && !update_hash.key?(:individual))
|
132
|
+
update_hash[:individual] = individual.serialize_params(options)
|
137
133
|
end
|
138
134
|
update_hash
|
139
135
|
end
|
@@ -31,8 +31,8 @@ module Stripe
|
|
31
31
|
|
32
32
|
def self.update(_id, _params = nil, _opts = nil)
|
33
33
|
raise NotImplementedError,
|
34
|
-
"Bank accounts cannot be updated without a customer ID or an
|
35
|
-
"
|
34
|
+
"Bank accounts cannot be updated without a customer ID or an " \
|
35
|
+
"account ID. Update a bank account using " \
|
36
36
|
"`Customer.update_source('customer_id', 'bank_account_id', " \
|
37
37
|
"update_params)` or `Account.update_external_account(" \
|
38
38
|
"'account_id', 'bank_account_id', update_params)`"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Climate
|
6
|
+
# Orders represent your intent to purchase a particular Climate product. When you create an order, the
|
7
|
+
# payment is deducted from your merchant balance.
|
8
|
+
class Order < APIResource
|
9
|
+
extend Stripe::APIOperations::Create
|
10
|
+
extend Stripe::APIOperations::List
|
11
|
+
include Stripe::APIOperations::Save
|
12
|
+
|
13
|
+
OBJECT_NAME = "climate.order"
|
14
|
+
|
15
|
+
def cancel(params = {}, opts = {})
|
16
|
+
request_stripe_object(
|
17
|
+
method: :post,
|
18
|
+
path: format("/v1/climate/orders/%<order>s/cancel", { order: CGI.escape(self["id"]) }),
|
19
|
+
params: params,
|
20
|
+
opts: opts
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.cancel(order, params = {}, opts = {})
|
25
|
+
request_stripe_object(
|
26
|
+
method: :post,
|
27
|
+
path: format("/v1/climate/orders/%<order>s/cancel", { order: CGI.escape(order) }),
|
28
|
+
params: params,
|
29
|
+
opts: opts
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Climate
|
6
|
+
# A Climate product represents a type of carbon removal unit available for reservation.
|
7
|
+
# You can retrieve it to see the current price and availability.
|
8
|
+
class Product < APIResource
|
9
|
+
extend Stripe::APIOperations::List
|
10
|
+
|
11
|
+
OBJECT_NAME = "climate.product"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Climate
|
6
|
+
# A supplier of carbon removal.
|
7
|
+
class Supplier < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "climate.supplier"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -23,8 +23,8 @@ module Stripe
|
|
23
23
|
# `Event` objects directly to an endpoint on your server. You can manage
|
24
24
|
# webhooks in your
|
25
25
|
# [account settings](https://dashboard.stripe.com/account/webhooks). Learn how
|
26
|
-
# to [listen for events]
|
27
|
-
#
|
26
|
+
# to [listen for events](https://stripe.com/docs/webhooks)
|
27
|
+
# so that your integration can automatically trigger reactions.
|
28
28
|
#
|
29
29
|
# When using [Connect](https://stripe.com/docs/connect), you can also receive event notifications
|
30
30
|
# that occur in connected accounts. For these events, there's an
|
@@ -26,10 +26,8 @@ module Stripe
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.create(params = {}, opts = {})
|
29
|
-
if params[:file] && !params[:file].is_a?(String)
|
30
|
-
|
31
|
-
raise ArgumentError, "file must respond to `#read`"
|
32
|
-
end
|
29
|
+
if params[:file] && !params[:file].is_a?(String) && !params[:file].respond_to?(:read)
|
30
|
+
raise ArgumentError, "file must respond to `#read`"
|
33
31
|
end
|
34
32
|
|
35
33
|
config = opts[:client]&.config || Stripe.config
|
data/lib/stripe/resources.rb
CHANGED
@@ -18,6 +18,9 @@ require "stripe/resources/card"
|
|
18
18
|
require "stripe/resources/cash_balance"
|
19
19
|
require "stripe/resources/charge"
|
20
20
|
require "stripe/resources/checkout/session"
|
21
|
+
require "stripe/resources/climate/order"
|
22
|
+
require "stripe/resources/climate/product"
|
23
|
+
require "stripe/resources/climate/supplier"
|
21
24
|
require "stripe/resources/country_spec"
|
22
25
|
require "stripe/resources/coupon"
|
23
26
|
require "stripe/resources/credit_note"
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -36,8 +36,7 @@ module Stripe
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
attr_reader :config
|
40
|
-
attr_reader :options
|
39
|
+
attr_reader :config, :options
|
41
40
|
|
42
41
|
# Gets a currently active `StripeClient`. Set for the current thread when
|
43
42
|
# `StripeClient#request` is being run so that API operations being executed
|
@@ -80,9 +79,7 @@ module Stripe
|
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
|
-
if thread_context.default_connection_managers.empty?
|
84
|
-
pruned_contexts << thread_context
|
85
|
-
end
|
82
|
+
pruned_contexts << thread_context if thread_context.default_connection_managers.empty?
|
86
83
|
end
|
87
84
|
|
88
85
|
@thread_contexts_with_connection_managers.subtract(pruned_contexts)
|
@@ -120,7 +117,7 @@ module Stripe
|
|
120
117
|
when Net::OpenTimeout, Net::ReadTimeout
|
121
118
|
# Retry on timeout-related problems (either on open or read).
|
122
119
|
true
|
123
|
-
when EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET,
|
120
|
+
when EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, # rubocop:todo Lint/DuplicateBranch
|
124
121
|
Errno::EHOSTUNREACH, Errno::ETIMEDOUT, SocketError
|
125
122
|
# Destination refused the connection, the connection was reset, or a
|
126
123
|
# variety of other connection failures. This could occur from a single
|
@@ -287,21 +284,21 @@ module Stripe
|
|
287
284
|
|
288
285
|
ERROR_MESSAGE_CONNECTION =
|
289
286
|
"Unexpected error communicating when trying to connect to " \
|
290
|
-
|
291
|
-
|
292
|
-
|
287
|
+
"Stripe (%s). You may be seeing this message because your DNS is not " \
|
288
|
+
"working or you don't have an internet connection. To check, try " \
|
289
|
+
"running `host stripe.com` from the command line."
|
293
290
|
ERROR_MESSAGE_SSL =
|
294
291
|
"Could not establish a secure connection to Stripe (%s), you " \
|
295
|
-
|
296
|
-
|
297
|
-
|
292
|
+
"may need to upgrade your OpenSSL version. To check, try running " \
|
293
|
+
"`openssl s_client -connect api.stripe.com:443` from the command " \
|
294
|
+
"line."
|
298
295
|
|
299
296
|
# Common error suffix sared by both connect and read timeout messages.
|
300
297
|
ERROR_MESSAGE_TIMEOUT_SUFFIX =
|
301
298
|
"Please check your internet connection and try again. " \
|
302
|
-
|
303
|
-
|
304
|
-
|
299
|
+
"If this problem persists, you should check Stripe's service " \
|
300
|
+
"status at https://status.stripe.com, or let us know at " \
|
301
|
+
"support@stripe.com."
|
305
302
|
|
306
303
|
ERROR_MESSAGE_TIMEOUT_CONNECT = (
|
307
304
|
"Timed out connecting to Stripe (%s). " +
|
@@ -488,9 +485,7 @@ module Stripe
|
|
488
485
|
response_block =
|
489
486
|
if block_given?
|
490
487
|
lambda do |response|
|
491
|
-
unless should_handle_as_error(response.code.to_i)
|
492
|
-
response.read_body(&read_body_chunk_block)
|
493
|
-
end
|
488
|
+
response.read_body(&read_body_chunk_block) unless should_handle_as_error(response.code.to_i)
|
494
489
|
end
|
495
490
|
end
|
496
491
|
|
@@ -515,18 +510,18 @@ module Stripe
|
|
515
510
|
private def check_api_key!(api_key)
|
516
511
|
unless api_key
|
517
512
|
raise AuthenticationError, "No API key provided. " \
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
513
|
+
'Set your API key using "Stripe.api_key = <API-KEY>". ' \
|
514
|
+
"You can generate API keys from the Stripe web interface. " \
|
515
|
+
"See https://stripe.com/api for details, or email " \
|
516
|
+
"support@stripe.com if you have any questions."
|
522
517
|
end
|
523
518
|
|
524
519
|
return unless api_key =~ /\s/
|
525
520
|
|
526
521
|
raise AuthenticationError, "Your API key is invalid, as it contains " \
|
527
|
-
|
528
|
-
|
529
|
-
|
522
|
+
"whitespace. (HINT: You can double-check your API key from the " \
|
523
|
+
"Stripe web interface. See https://stripe.com/api for details, or " \
|
524
|
+
"email support@stripe.com if you have any questions.)"
|
530
525
|
end
|
531
526
|
|
532
527
|
# Encodes a set of body parameters using multipart if `Content-Type` is set
|
@@ -582,9 +577,7 @@ module Stripe
|
|
582
577
|
http_status = resp.code.to_i
|
583
578
|
context = context.dup_from_response_headers(resp)
|
584
579
|
|
585
|
-
if should_handle_as_error(http_status)
|
586
|
-
handle_error_response(resp, context)
|
587
|
-
end
|
580
|
+
handle_error_response(resp, context) if should_handle_as_error(http_status)
|
588
581
|
|
589
582
|
log_response(context, request_start, http_status, resp.body, resp)
|
590
583
|
notify_request_end(context, request_duration, http_status,
|
@@ -634,7 +627,7 @@ module Stripe
|
|
634
627
|
|
635
628
|
# Only handle errors when we know we can do so, and re-raise otherwise.
|
636
629
|
# This should be pretty infrequent.
|
637
|
-
else
|
630
|
+
else # rubocop:todo Lint/DuplicateBranch
|
638
631
|
raise
|
639
632
|
end
|
640
633
|
end
|
@@ -844,7 +837,7 @@ module Stripe
|
|
844
837
|
|
845
838
|
if errors.nil?
|
846
839
|
message = "Unexpected error #{error.class.name} communicating " \
|
847
|
-
|
840
|
+
"with Stripe. Please let us know at support@stripe.com."
|
848
841
|
end
|
849
842
|
|
850
843
|
api_base ||= config.api_base
|
@@ -858,9 +851,7 @@ module Stripe
|
|
858
851
|
|
859
852
|
private def request_headers(api_key, method)
|
860
853
|
user_agent = "Stripe/v1 RubyBindings/#{Stripe::VERSION}"
|
861
|
-
unless Stripe.app_info.nil?
|
862
|
-
user_agent += " " + format_app_info(Stripe.app_info)
|
863
|
-
end
|
854
|
+
user_agent += " " + format_app_info(Stripe.app_info) unless Stripe.app_info.nil?
|
864
855
|
|
865
856
|
headers = {
|
866
857
|
"User-Agent" => user_agent,
|
@@ -963,15 +954,7 @@ module Stripe
|
|
963
954
|
# that we can log certain information. It's useful because it means that we
|
964
955
|
# don't have to pass around as many parameters.
|
965
956
|
class RequestLogContext
|
966
|
-
attr_accessor :body
|
967
|
-
attr_accessor :account
|
968
|
-
attr_accessor :api_key
|
969
|
-
attr_accessor :api_version
|
970
|
-
attr_accessor :idempotency_key
|
971
|
-
attr_accessor :method
|
972
|
-
attr_accessor :path
|
973
|
-
attr_accessor :query
|
974
|
-
attr_accessor :request_id
|
957
|
+
attr_accessor :body, :account, :api_key, :api_version, :idempotency_key, :method, :path, :query, :request_id
|
975
958
|
|
976
959
|
# The idea with this method is that we might want to update some of
|
977
960
|
# context information because a response that we've received from the API
|
@@ -25,26 +25,12 @@ module Stripe
|
|
25
25
|
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
|
26
26
|
# what levels to print is entirely deferred to the logger.
|
27
27
|
class StripeConfiguration
|
28
|
-
attr_accessor :api_key
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
28
|
+
attr_accessor :api_key, :api_version, :client_id, :enable_telemetry, :logger, :stripe_account
|
29
|
+
|
30
|
+
attr_reader :api_base, :uploads_base, :connect_base, :ca_bundle_path, :log_level, :initial_network_retry_delay,
|
31
|
+
# rubocop:todo Layout/LineLength
|
32
|
+
:max_network_retries, :max_network_retry_delay, :open_timeout, :read_timeout, :write_timeout, :proxy, :verify_ssl_certs
|
33
|
+
# rubocop:enable Layout/LineLength
|
48
34
|
|
49
35
|
def self.setup
|
50
36
|
new.tap do |instance|
|
@@ -95,8 +81,8 @@ module Stripe
|
|
95
81
|
|
96
82
|
if !val.nil? && !levels.include?(val)
|
97
83
|
raise ArgumentError,
|
98
|
-
"log_level should only be set to `nil`, `debug`, `info`," \
|
99
|
-
"
|
84
|
+
"log_level should only be set to `nil`, `debug`, `info`, " \
|
85
|
+
"or `error`"
|
100
86
|
end
|
101
87
|
@log_level = val
|
102
88
|
end
|
@@ -124,9 +110,7 @@ module Stripe
|
|
124
110
|
end
|
125
111
|
|
126
112
|
def write_timeout=(write_timeout)
|
127
|
-
unless Net::HTTP.instance_methods.include?(:write_timeout=)
|
128
|
-
raise NotImplementedError
|
129
|
-
end
|
113
|
+
raise NotImplementedError unless Net::HTTP.instance_methods.include?(:write_timeout=)
|
130
114
|
|
131
115
|
@write_timeout = write_timeout
|
132
116
|
StripeClient.clear_all_connection_managers(config: self)
|
@@ -177,10 +161,10 @@ module Stripe
|
|
177
161
|
# and is itself not thread safe.
|
178
162
|
def ca_store
|
179
163
|
@ca_store ||= begin
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
164
|
+
store = OpenSSL::X509::Store.new
|
165
|
+
store.add_file(ca_bundle_path)
|
166
|
+
store
|
167
|
+
end
|
184
168
|
end
|
185
169
|
|
186
170
|
def enable_telemetry?
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -320,8 +320,8 @@ module Stripe
|
|
320
320
|
# Here we swallow that error and issue a warning so at least
|
321
321
|
# the program doesn't crash.
|
322
322
|
warn("WARNING: Unable to remove method `#{method_name}`; " \
|
323
|
-
|
324
|
-
|
323
|
+
"if custom, please consider renaming to a name that doesn't " \
|
324
|
+
"collide with an API property name.")
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
@@ -351,17 +351,15 @@ module Stripe
|
|
351
351
|
define_method(:"#{k}=") do |v|
|
352
352
|
if v == ""
|
353
353
|
raise ArgumentError, "You cannot set #{k} to an empty string. " \
|
354
|
-
|
355
|
-
|
354
|
+
"We interpret empty strings as nil in requests. " \
|
355
|
+
"You may set (object).#{k} = nil to delete the property."
|
356
356
|
end
|
357
357
|
@values[k] = Util.convert_to_stripe_object(v, @opts)
|
358
358
|
dirty_value!(@values[k])
|
359
359
|
@unsaved_values.add(k)
|
360
360
|
end
|
361
361
|
|
362
|
-
if [FalseClass, TrueClass].include?(values[k].class)
|
363
|
-
define_method(:"#{k}?") { @values[k] }
|
364
|
-
end
|
362
|
+
define_method(:"#{k}?") { @values[k] } if [FalseClass, TrueClass].include?(values[k].class)
|
365
363
|
end
|
366
364
|
end
|
367
365
|
end
|
@@ -369,7 +367,6 @@ module Stripe
|
|
369
367
|
# Disabling the cop because it's confused by the fact that the methods are
|
370
368
|
# protected, but we do define `#respond_to_missing?` just below. Hopefully
|
371
369
|
# this is fixed in more recent Rubocop versions.
|
372
|
-
# rubocop:disable Style/MissingRespondToMissing
|
373
370
|
protected def method_missing(name, *args)
|
374
371
|
# TODO: only allow setting in updateable classes.
|
375
372
|
if name.to_s.end_with?("=")
|
@@ -405,16 +402,14 @@ module Stripe
|
|
405
402
|
|
406
403
|
raise NoMethodError,
|
407
404
|
e.message + ". HINT: The '#{name}' attribute was set in the " \
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
405
|
+
"past, however. It was then wiped when refreshing the object " \
|
406
|
+
"with the result returned by Stripe's API, probably as a " \
|
407
|
+
"result of a save(). The attributes currently available on " \
|
408
|
+
"this object are: #{@values.keys.join(', ')}"
|
412
409
|
end
|
413
410
|
end
|
414
|
-
# rubocop:enable Style/MissingRespondToMissing
|
415
|
-
|
416
411
|
protected def respond_to_missing?(symbol, include_private = false)
|
417
|
-
@values && @values.key?(symbol) || super
|
412
|
+
(@values && @values.key?(symbol)) || super
|
418
413
|
end
|
419
414
|
|
420
415
|
# Re-initializes the object based on a hash of values (usually one that's
|
@@ -460,7 +455,8 @@ module Stripe
|
|
460
455
|
self
|
461
456
|
end
|
462
457
|
|
463
|
-
|
458
|
+
# rubocop:todo Metrics/PerceivedComplexity
|
459
|
+
protected def serialize_params_value(value, original, unsaved, force, # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
464
460
|
key: nil)
|
465
461
|
if value.nil?
|
466
462
|
""
|
@@ -494,8 +490,8 @@ module Stripe
|
|
494
490
|
value
|
495
491
|
else
|
496
492
|
raise ArgumentError, "Cannot save property `#{key}` containing " \
|
497
|
-
|
498
|
-
|
493
|
+
"an API resource. It doesn't appear to be persisted and is " \
|
494
|
+
"not marked as `save_with_parent`."
|
499
495
|
end
|
500
496
|
|
501
497
|
elsif value.is_a?(Array)
|
@@ -535,6 +531,7 @@ module Stripe
|
|
535
531
|
value
|
536
532
|
end
|
537
533
|
end
|
534
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
538
535
|
|
539
536
|
# Produces a deep copy of the given object including support for arrays,
|
540
537
|
# hashes, and StripeObjects.
|
@@ -41,9 +41,7 @@ module Stripe
|
|
41
41
|
|
42
42
|
def [](name)
|
43
43
|
values = @hash[name.downcase]
|
44
|
-
if values && values.count > 1
|
45
|
-
warn("Duplicate header values for `#{name}`; returning only first")
|
46
|
-
end
|
44
|
+
warn("Duplicate header values for `#{name}`; returning only first") if values && values.count > 1
|
47
45
|
values ? values.first : nil
|
48
46
|
end
|
49
47
|
end
|
data/lib/stripe/util.rb
CHANGED
@@ -79,8 +79,8 @@ module Stripe
|
|
79
79
|
"id should be a string representing the ID of an API resource"
|
80
80
|
end
|
81
81
|
|
82
|
-
url = "#{target.resource_url}/"\
|
83
|
-
"#{CGI.escape(id)}/"\
|
82
|
+
url = "#{target.resource_url}/" \
|
83
|
+
"#{CGI.escape(id)}/" \
|
84
84
|
"#{CGI.escape(http_path)}"
|
85
85
|
|
86
86
|
resp, opts = resource.execute_resource_request(
|
@@ -139,9 +139,7 @@ module Stripe
|
|
139
139
|
|
140
140
|
# set filters so that we can fetch the same limit, expansions, and
|
141
141
|
# predicates when accessing the next and previous pages
|
142
|
-
if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
|
143
|
-
obj.filters = params.dup
|
144
|
-
end
|
142
|
+
obj.filters = params.dup if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
|
145
143
|
|
146
144
|
obj
|
147
145
|
else
|
@@ -153,7 +151,7 @@ module Stripe
|
|
153
151
|
config = data.delete(:config) || Stripe.config
|
154
152
|
logger = config.logger || Stripe.logger
|
155
153
|
if !logger.nil? ||
|
156
|
-
!config.log_level.nil? && config.log_level <= Stripe::LEVEL_ERROR
|
154
|
+
(!config.log_level.nil? && config.log_level <= Stripe::LEVEL_ERROR)
|
157
155
|
log_internal(message, data, color: :cyan, level: Stripe::LEVEL_ERROR,
|
158
156
|
logger: Stripe.logger, out: $stderr)
|
159
157
|
end
|
@@ -163,7 +161,7 @@ module Stripe
|
|
163
161
|
config = data.delete(:config) || Stripe.config
|
164
162
|
logger = config.logger || Stripe.logger
|
165
163
|
if !logger.nil? ||
|
166
|
-
!config.log_level.nil? && config.log_level <= Stripe::LEVEL_INFO
|
164
|
+
(!config.log_level.nil? && config.log_level <= Stripe::LEVEL_INFO)
|
167
165
|
log_internal(message, data, color: :cyan, level: Stripe::LEVEL_INFO,
|
168
166
|
logger: Stripe.logger, out: $stdout)
|
169
167
|
end
|
@@ -173,7 +171,7 @@ module Stripe
|
|
173
171
|
config = data.delete(:config) || Stripe.config
|
174
172
|
logger = config.logger || Stripe.logger
|
175
173
|
if !logger.nil? ||
|
176
|
-
!config.log_level.nil? && config.log_level <= Stripe::LEVEL_DEBUG
|
174
|
+
(!config.log_level.nil? && config.log_level <= Stripe::LEVEL_DEBUG)
|
177
175
|
log_internal(message, data, color: :blue, level: Stripe::LEVEL_DEBUG,
|
178
176
|
logger: Stripe.logger, out: $stdout)
|
179
177
|
end
|
@@ -185,10 +183,10 @@ module Stripe
|
|
185
183
|
new_hash = {}
|
186
184
|
object.each do |key, value|
|
187
185
|
key = (begin
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
186
|
+
key.to_sym
|
187
|
+
rescue StandardError
|
188
|
+
key
|
189
|
+
end) || key
|
192
190
|
new_hash[key] = symbolize_names(value)
|
193
191
|
end
|
194
192
|
new_hash
|
data/lib/stripe/version.rb
CHANGED
data/stripe.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
|
4
4
|
|
5
5
|
require "stripe/version"
|
6
6
|
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"github_repo" => "ssh://github.com/stripe/stripe-ruby",
|
25
25
|
"homepage_uri" => "https://stripe.com/docs/api?lang=ruby",
|
26
26
|
"source_code_uri" => "https://github.com/stripe/stripe-ruby",
|
27
|
+
"rubygems_mfa_required" => "false",
|
27
28
|
}
|
28
29
|
|
29
30
|
ignored = Regexp.union(
|
@@ -36,6 +37,6 @@ Gem::Specification.new do |s|
|
|
36
37
|
)
|
37
38
|
s.files = `git ls-files`.split("\n").reject { |f| ignored.match(f) }
|
38
39
|
s.executables = `git ls-files -- bin/*`.split("\n")
|
39
|
-
.map { |f|
|
40
|
+
.map { |f| File.basename(f) }
|
40
41
|
s.require_paths = ["lib"]
|
41
42
|
end
|
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: 10.
|
4
|
+
version: 10.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-30 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.
|
@@ -69,6 +69,9 @@ files:
|
|
69
69
|
- lib/stripe/resources/cash_balance.rb
|
70
70
|
- lib/stripe/resources/charge.rb
|
71
71
|
- lib/stripe/resources/checkout/session.rb
|
72
|
+
- lib/stripe/resources/climate/order.rb
|
73
|
+
- lib/stripe/resources/climate/product.rb
|
74
|
+
- lib/stripe/resources/climate/supplier.rb
|
72
75
|
- lib/stripe/resources/country_spec.rb
|
73
76
|
- lib/stripe/resources/coupon.rb
|
74
77
|
- lib/stripe/resources/credit_note.rb
|
@@ -183,6 +186,7 @@ metadata:
|
|
183
186
|
github_repo: ssh://github.com/stripe/stripe-ruby
|
184
187
|
homepage_uri: https://stripe.com/docs/api?lang=ruby
|
185
188
|
source_code_uri: https://github.com/stripe/stripe-ruby
|
189
|
+
rubygems_mfa_required: 'false'
|
186
190
|
post_install_message:
|
187
191
|
rdoc_options: []
|
188
192
|
require_paths:
|