stripe 5.22.0 → 5.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -4
- data/.travis.yml +1 -3
- data/CHANGELOG.md +16 -0
- data/README.md +22 -22
- data/VERSION +1 -1
- data/lib/stripe.rb +32 -166
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +7 -3
- data/lib/stripe/api_operations/list.rb +1 -1
- data/lib/stripe/api_operations/nested_resource.rb +6 -5
- data/lib/stripe/api_operations/request.rb +19 -3
- data/lib/stripe/api_operations/save.rb +7 -4
- data/lib/stripe/api_resource.rb +4 -3
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/oauth.rb +3 -3
- data/lib/stripe/object_types.rb +2 -0
- data/lib/stripe/resources.rb +2 -0
- data/lib/stripe/resources/account.rb +2 -1
- data/lib/stripe/resources/account_link.rb +1 -0
- data/lib/stripe/resources/apple_pay_domain.rb +1 -0
- data/lib/stripe/resources/application_fee.rb +1 -0
- data/lib/stripe/resources/balance.rb +1 -0
- data/lib/stripe/resources/balance_transaction.rb +1 -0
- data/lib/stripe/resources/bank_account.rb +2 -1
- data/lib/stripe/resources/billing_portal/session.rb +1 -0
- data/lib/stripe/resources/bitcoin_receiver.rb +1 -0
- data/lib/stripe/resources/card.rb +1 -0
- data/lib/stripe/resources/charge.rb +1 -0
- data/lib/stripe/resources/checkout/session.rb +1 -0
- data/lib/stripe/resources/country_spec.rb +1 -0
- data/lib/stripe/resources/coupon.rb +1 -0
- data/lib/stripe/resources/credit_note.rb +3 -2
- data/lib/stripe/resources/customer.rb +2 -1
- data/lib/stripe/resources/dispute.rb +1 -0
- data/lib/stripe/resources/ephemeral_key.rb +1 -0
- data/lib/stripe/resources/event.rb +1 -0
- data/lib/stripe/resources/exchange_rate.rb +1 -0
- data/lib/stripe/resources/file.rb +1 -0
- data/lib/stripe/resources/file_link.rb +1 -0
- data/lib/stripe/resources/invoice.rb +3 -2
- data/lib/stripe/resources/invoice_item.rb +1 -0
- data/lib/stripe/resources/issuing/authorization.rb +1 -0
- data/lib/stripe/resources/issuing/card.rb +1 -0
- data/lib/stripe/resources/issuing/cardholder.rb +1 -0
- data/lib/stripe/resources/issuing/dispute.rb +12 -0
- data/lib/stripe/resources/issuing/transaction.rb +1 -0
- data/lib/stripe/resources/mandate.rb +1 -0
- data/lib/stripe/resources/order.rb +1 -0
- data/lib/stripe/resources/order_return.rb +1 -0
- data/lib/stripe/resources/payment_intent.rb +1 -0
- data/lib/stripe/resources/payment_method.rb +1 -0
- data/lib/stripe/resources/payout.rb +1 -0
- data/lib/stripe/resources/plan.rb +1 -0
- data/lib/stripe/resources/price.rb +1 -0
- data/lib/stripe/resources/product.rb +1 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -0
- data/lib/stripe/resources/radar/value_list.rb +1 -0
- data/lib/stripe/resources/radar/value_list_item.rb +1 -0
- data/lib/stripe/resources/recipient.rb +1 -0
- data/lib/stripe/resources/refund.rb +1 -0
- data/lib/stripe/resources/reporting/report_run.rb +1 -0
- data/lib/stripe/resources/reporting/report_type.rb +1 -0
- data/lib/stripe/resources/review.rb +1 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +1 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -0
- data/lib/stripe/resources/sku.rb +1 -0
- data/lib/stripe/resources/source.rb +4 -3
- data/lib/stripe/resources/subscription.rb +1 -0
- data/lib/stripe/resources/subscription_item.rb +2 -1
- data/lib/stripe/resources/subscription_schedule.rb +1 -0
- data/lib/stripe/resources/tax_rate.rb +1 -0
- data/lib/stripe/resources/terminal/connection_token.rb +1 -0
- data/lib/stripe/resources/terminal/location.rb +1 -0
- data/lib/stripe/resources/terminal/reader.rb +1 -0
- data/lib/stripe/resources/three_d_secure.rb +1 -0
- data/lib/stripe/resources/token.rb +1 -0
- data/lib/stripe/resources/topup.rb +1 -0
- data/lib/stripe/resources/transfer.rb +1 -0
- data/lib/stripe/resources/webhook_endpoint.rb +1 -0
- data/lib/stripe/stripe_configuration.rb +167 -0
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_link_test.rb +3 -3
- data/test/stripe/api_resource_test.rb +7 -7
- data/test/stripe/customer_card_test.rb +6 -0
- data/test/stripe/issuing/dispute_test.rb +20 -1
- data/test/stripe/product_test.rb +1 -2
- data/test/stripe/promotion_code_test.rb +42 -0
- data/test/stripe/setup_attempt_test.rb +16 -0
- data/test/stripe/stripe_configuration_test.rb +128 -0
- data/test/stripe/subscription_item_test.rb +1 -1
- data/test/stripe_test.rb +88 -19
- data/test/test_helper.rb +1 -1
- metadata +11 -2
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -8,6 +9,17 @@ module Stripe
|
|
8
9
|
include Stripe::APIOperations::Save
|
9
10
|
|
10
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
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
class PromotionCode < APIResource
|
6
|
+
extend Stripe::APIOperations::Create
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
include Stripe::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "promotion_code"
|
11
|
+
end
|
12
|
+
end
|
data/lib/stripe/resources/sku.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -31,13 +32,13 @@ module Stripe
|
|
31
32
|
|
32
33
|
url = "#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
|
33
34
|
"/#{CGI.escape(id)}"
|
34
|
-
resp, opts =
|
35
|
+
resp, opts = execute_resource_request(:delete, url, params, opts)
|
35
36
|
initialize_from(resp.data, opts)
|
36
37
|
end
|
37
38
|
|
38
39
|
def source_transactions(params = {}, opts = {})
|
39
|
-
resp, opts =
|
40
|
-
|
40
|
+
resp, opts = execute_resource_request(:get, resource_url + "/source_transactions", params,
|
41
|
+
opts)
|
41
42
|
Util.convert_to_stripe_object(resp.data, opts)
|
42
43
|
end
|
43
44
|
extend Gem::Deprecate
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -16,7 +17,7 @@ module Stripe
|
|
16
17
|
resource_plural: "usage_record_summaries"
|
17
18
|
|
18
19
|
def usage_record_summaries(params = {}, opts = {})
|
19
|
-
resp, opts =
|
20
|
+
resp, opts = execute_resource_request(:get, resource_url + "/usage_record_summaries", params, opts)
|
20
21
|
Util.convert_to_stripe_object(resp.data, opts)
|
21
22
|
end
|
22
23
|
extend Gem::Deprecate
|
@@ -0,0 +1,167 @@
|
|
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 :proxy
|
46
|
+
attr_reader :verify_ssl_certs
|
47
|
+
|
48
|
+
def self.setup
|
49
|
+
new.tap do |instance|
|
50
|
+
yield(instance) if block_given?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create a new config based off an existing one. This is useful when the
|
55
|
+
# caller wants to override the global configuration
|
56
|
+
def reverse_duplicate_merge(hash)
|
57
|
+
dup.tap do |instance|
|
58
|
+
hash.each do |option, value|
|
59
|
+
instance.public_send("#{option}=", value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize
|
65
|
+
@ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
|
66
|
+
@enable_telemetry = true
|
67
|
+
@verify_ssl_certs = true
|
68
|
+
|
69
|
+
@max_network_retries = 0
|
70
|
+
@initial_network_retry_delay = 0.5
|
71
|
+
@max_network_retry_delay = 2
|
72
|
+
|
73
|
+
@open_timeout = 30
|
74
|
+
@read_timeout = 80
|
75
|
+
|
76
|
+
@api_base = "https://api.stripe.com"
|
77
|
+
@connect_base = "https://connect.stripe.com"
|
78
|
+
@uploads_base = "https://files.stripe.com"
|
79
|
+
end
|
80
|
+
|
81
|
+
def log_level=(val)
|
82
|
+
# Backwards compatibility for values that we briefly allowed
|
83
|
+
if val == "debug"
|
84
|
+
val = Stripe::LEVEL_DEBUG
|
85
|
+
elsif val == "info"
|
86
|
+
val = Stripe::LEVEL_INFO
|
87
|
+
end
|
88
|
+
|
89
|
+
levels = [Stripe::LEVEL_INFO, Stripe::LEVEL_DEBUG, Stripe::LEVEL_ERROR]
|
90
|
+
|
91
|
+
if !val.nil? && !levels.include?(val)
|
92
|
+
raise ArgumentError,
|
93
|
+
"log_level should only be set to `nil`, `debug` or `info`"
|
94
|
+
end
|
95
|
+
@log_level = val
|
96
|
+
end
|
97
|
+
|
98
|
+
def max_network_retries=(val)
|
99
|
+
@max_network_retries = val.to_i
|
100
|
+
end
|
101
|
+
|
102
|
+
def open_timeout=(open_timeout)
|
103
|
+
@open_timeout = open_timeout
|
104
|
+
StripeClient.clear_all_connection_managers
|
105
|
+
end
|
106
|
+
|
107
|
+
def read_timeout=(read_timeout)
|
108
|
+
@read_timeout = read_timeout
|
109
|
+
StripeClient.clear_all_connection_managers
|
110
|
+
end
|
111
|
+
|
112
|
+
def proxy=(proxy)
|
113
|
+
@proxy = proxy
|
114
|
+
StripeClient.clear_all_connection_managers
|
115
|
+
end
|
116
|
+
|
117
|
+
def verify_ssl_certs=(verify_ssl_certs)
|
118
|
+
@verify_ssl_certs = verify_ssl_certs
|
119
|
+
StripeClient.clear_all_connection_managers
|
120
|
+
end
|
121
|
+
|
122
|
+
def uploads_base=(uploads_base)
|
123
|
+
@uploads_base = uploads_base
|
124
|
+
StripeClient.clear_all_connection_managers
|
125
|
+
end
|
126
|
+
|
127
|
+
def connect_base=(connect_base)
|
128
|
+
@connect_base = connect_base
|
129
|
+
StripeClient.clear_all_connection_managers
|
130
|
+
end
|
131
|
+
|
132
|
+
def api_base=(api_base)
|
133
|
+
@api_base = api_base
|
134
|
+
StripeClient.clear_all_connection_managers
|
135
|
+
end
|
136
|
+
|
137
|
+
def ca_bundle_path=(path)
|
138
|
+
@ca_bundle_path = path
|
139
|
+
|
140
|
+
# empty this field so a new store is initialized
|
141
|
+
@ca_store = nil
|
142
|
+
|
143
|
+
StripeClient.clear_all_connection_managers
|
144
|
+
end
|
145
|
+
|
146
|
+
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
147
|
+
# which is used to validate TLS on every request.
|
148
|
+
#
|
149
|
+
# This was added to the give the gem "pseudo thread safety" in that it seems
|
150
|
+
# when initiating many parallel requests marshaling the certificate store is
|
151
|
+
# the most likely point of failure (see issue #382). Any program attempting
|
152
|
+
# to leverage this pseudo safety should make a call to this method (i.e.
|
153
|
+
# `Stripe.ca_store`) in their initialization code because it marshals lazily
|
154
|
+
# and is itself not thread safe.
|
155
|
+
def ca_store
|
156
|
+
@ca_store ||= begin
|
157
|
+
store = OpenSSL::X509::Store.new
|
158
|
+
store.add_file(ca_bundle_path)
|
159
|
+
store
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def enable_telemetry?
|
164
|
+
enable_telemetry
|
165
|
+
end
|
166
|
+
end
|
167
|
+
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)
|