stripe 5.22.0 → 5.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +142 -0
- data/Gemfile +0 -1
- data/Makefile +7 -0
- data/README.md +32 -27
- data/VERSION +1 -1
- 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 +54 -5
- data/lib/stripe/api_operations/save.rb +7 -4
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +13 -19
- data/lib/stripe/api_resource_test_helpers.rb +47 -0
- data/lib/stripe/connection_manager.rb +51 -10
- data/lib/stripe/error_object.rb +2 -3
- data/lib/stripe/instrumentation.rb +3 -1
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/oauth.rb +7 -6
- data/lib/stripe/object_types.rb +21 -1
- data/lib/stripe/resources/account.rb +5 -9
- 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/application_fee_refund.rb +2 -1
- 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/configuration.rb +14 -0
- data/lib/stripe/resources/billing_portal/session.rb +1 -0
- data/lib/stripe/resources/bitcoin_receiver.rb +1 -0
- data/lib/stripe/resources/bitcoin_transaction.rb +3 -2
- data/lib/stripe/resources/capability.rb +2 -1
- data/lib/stripe/resources/card.rb +1 -0
- data/lib/stripe/resources/cash_balance.rb +22 -0
- data/lib/stripe/resources/charge.rb +10 -0
- data/lib/stripe/resources/checkout/session.rb +12 -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/credit_note_line_item.rb +1 -0
- data/lib/stripe/resources/customer.rb +41 -2
- data/lib/stripe/resources/customer_balance_transaction.rb +3 -2
- data/lib/stripe/resources/discount.rb +1 -0
- 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 +3 -1
- data/lib/stripe/resources/file_link.rb +1 -0
- data/lib/stripe/resources/financial_connections/account.rb +31 -0
- data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
- data/lib/stripe/resources/financial_connections/session.rb +12 -0
- data/lib/stripe/resources/funding_instructions.rb +16 -0
- data/lib/stripe/resources/identity/verification_report.rb +12 -0
- data/lib/stripe/resources/identity/verification_session.rb +35 -0
- data/lib/stripe/resources/invoice.rb +12 -2
- data/lib/stripe/resources/invoice_item.rb +1 -0
- data/lib/stripe/resources/invoice_line_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/card_details.rb +2 -1
- 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/line_item.rb +1 -0
- data/lib/stripe/resources/login_link.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 +40 -0
- data/lib/stripe/resources/payment_link.rb +23 -0
- data/lib/stripe/resources/payment_method.rb +1 -0
- data/lib/stripe/resources/payout.rb +11 -0
- data/lib/stripe/resources/person.rb +1 -0
- data/lib/stripe/resources/plan.rb +1 -0
- data/lib/stripe/resources/price.rb +10 -0
- data/lib/stripe/resources/product.rb +10 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -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 +31 -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/reversal.rb +3 -2
- data/lib/stripe/resources/review.rb +1 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +11 -0
- data/lib/stripe/resources/shipping_rate.rb +12 -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/source_transaction.rb +1 -0
- data/lib/stripe/resources/subscription.rb +10 -0
- data/lib/stripe/resources/subscription_item.rb +2 -1
- data/lib/stripe/resources/subscription_schedule.rb +1 -0
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/resources/tax_id.rb +1 -0
- data/lib/stripe/resources/tax_rate.rb +1 -0
- data/lib/stripe/resources/terminal/configuration.rb +15 -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 +61 -0
- data/lib/stripe/resources/test_helpers/test_clock.rb +25 -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/usage_record.rb +1 -0
- data/lib/stripe/resources/usage_record_summary.rb +1 -0
- data/lib/stripe/resources/webhook_endpoint.rb +1 -0
- data/lib/stripe/resources.rb +18 -0
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/stripe_client.rb +252 -114
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +24 -1
- data/lib/stripe/stripe_response.rb +80 -52
- data/lib/stripe/util.rb +62 -7
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +39 -168
- data/stripe.gemspec +12 -5
- metadata +29 -190
- data/.editorconfig +0 -10
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -80
- data/.rubocop_todo.yml +0 -33
- data/.travis.yml +0 -40
- data/.vscode/extensions.json +0 -7
- data/.vscode/settings.json +0 -8
- data/test/openapi/README.md +0 -9
- data/test/stripe/account_link_test.rb +0 -18
- data/test/stripe/account_test.rb +0 -412
- data/test/stripe/alipay_account_test.rb +0 -37
- data/test/stripe/api_operations_test.rb +0 -80
- data/test/stripe/api_resource_test.rb +0 -646
- data/test/stripe/apple_pay_domain_test.rb +0 -46
- data/test/stripe/application_fee_refund_test.rb +0 -37
- data/test/stripe/application_fee_test.rb +0 -58
- data/test/stripe/balance_test.rb +0 -13
- data/test/stripe/balance_transaction_test.rb +0 -20
- data/test/stripe/bank_account_test.rb +0 -36
- data/test/stripe/billing_portal/session_test.rb +0 -18
- data/test/stripe/capability_test.rb +0 -45
- data/test/stripe/charge_test.rb +0 -64
- data/test/stripe/checkout/session_test.rb +0 -53
- data/test/stripe/connection_manager_test.rb +0 -163
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -61
- data/test/stripe/credit_note_test.rb +0 -90
- data/test/stripe/customer_balance_transaction_test.rb +0 -37
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_test.rb +0 -226
- data/test/stripe/dispute_test.rb +0 -51
- data/test/stripe/ephemeral_key_test.rb +0 -93
- data/test/stripe/errors_test.rb +0 -53
- data/test/stripe/exchange_rate_test.rb +0 -20
- data/test/stripe/file_link_test.rb +0 -41
- data/test/stripe/file_test.rb +0 -87
- data/test/stripe/instrumentation_test.rb +0 -74
- data/test/stripe/invoice_item_test.rb +0 -66
- data/test/stripe/invoice_line_item_test.rb +0 -8
- data/test/stripe/invoice_test.rb +0 -229
- data/test/stripe/issuing/authorization_test.rb +0 -72
- data/test/stripe/issuing/card_test.rb +0 -74
- data/test/stripe/issuing/cardholder_test.rb +0 -53
- data/test/stripe/issuing/dispute_test.rb +0 -35
- data/test/stripe/issuing/transaction_test.rb +0 -48
- data/test/stripe/list_object_test.rb +0 -202
- data/test/stripe/login_link_test.rb +0 -37
- data/test/stripe/mandate_test.rb +0 -14
- data/test/stripe/multipart_encoder_test.rb +0 -130
- data/test/stripe/oauth_test.rb +0 -104
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -82
- data/test/stripe/payment_intent_test.rb +0 -107
- data/test/stripe/payment_method_test.rb +0 -84
- data/test/stripe/payout_test.rb +0 -57
- data/test/stripe/person_test.rb +0 -46
- data/test/stripe/plan_test.rb +0 -98
- data/test/stripe/price_test.rb +0 -48
- data/test/stripe/product_test.rb +0 -59
- data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
- data/test/stripe/radar/value_list_item_test.rb +0 -48
- data/test/stripe/radar/value_list_test.rb +0 -61
- data/test/stripe/recipient_test.rb +0 -62
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reporting/report_run_test.rb +0 -33
- data/test/stripe/reporting/report_type_test.rb +0 -22
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/review_test.rb +0 -27
- data/test/stripe/setup_intent_test.rb +0 -84
- data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
- data/test/stripe/sku_test.rb +0 -60
- data/test/stripe/source_test.rb +0 -119
- data/test/stripe/stripe_client_test.rb +0 -1291
- data/test/stripe/stripe_object_test.rb +0 -500
- data/test/stripe/stripe_response_test.rb +0 -95
- data/test/stripe/subscription_item_test.rb +0 -84
- data/test/stripe/subscription_schedule_test.rb +0 -82
- data/test/stripe/subscription_test.rb +0 -80
- data/test/stripe/tax_id_test.rb +0 -31
- data/test/stripe/tax_rate_test.rb +0 -43
- data/test/stripe/terminal/connection_token_test.rb +0 -16
- data/test/stripe/terminal/location_test.rb +0 -68
- data/test/stripe/terminal/reader_test.rb +0 -62
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/topup_test.rb +0 -62
- data/test/stripe/transfer_test.rb +0 -88
- data/test/stripe/usage_record_summary_test.rb +0 -29
- data/test/stripe/util_test.rb +0 -402
- data/test/stripe/webhook_endpoint_test.rb +0 -59
- data/test/stripe/webhook_test.rb +0 -135
- data/test/stripe_mock.rb +0 -78
- data/test/stripe_test.rb +0 -50
- data/test/test_data.rb +0 -61
- data/test/test_helper.rb +0 -75
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
# The base class for nested TestHelpers classes in resource objects.
|
5
|
+
# The APIResourceTestHelpers handles URL generation and custom method
|
6
|
+
# support for test-helper methods.
|
7
|
+
#
|
8
|
+
# class MyAPIResource < APIResource
|
9
|
+
# class TestHelpers < APIResourceTestHelpers
|
10
|
+
class APIResourceTestHelpers
|
11
|
+
def initialize(resource)
|
12
|
+
@resource = resource
|
13
|
+
end
|
14
|
+
|
15
|
+
# Adds a custom method to a test helper. This is used to add support for
|
16
|
+
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
|
17
|
+
# following parameters:
|
18
|
+
# - name: the name of the custom method to create (as a symbol)
|
19
|
+
# - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
|
20
|
+
# - http_path: the path to append to the resource's URL. If not provided,
|
21
|
+
# the name is used as the path
|
22
|
+
#
|
23
|
+
# For example, this call:
|
24
|
+
# custom_method :capture, http_verb: post
|
25
|
+
# adds a `capture` class method to the resource class that, when called,
|
26
|
+
# will send a POST request to `/v1/<object_name>/capture`.
|
27
|
+
def self.custom_method(name, http_verb:, http_path: nil)
|
28
|
+
Util.custom_method self::RESOURCE_CLASS, self, name, http_verb, http_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.resource_url
|
32
|
+
"/v1/test_helpers/"\
|
33
|
+
"#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
|
34
|
+
end
|
35
|
+
|
36
|
+
def resource_url
|
37
|
+
unless (id = @resource["id"])
|
38
|
+
raise InvalidRequestError.new(
|
39
|
+
"Could not determine which URL to request: #{self.class} instance " \
|
40
|
+
"has invalid ID: #{id.inspect}",
|
41
|
+
"id"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -15,8 +15,10 @@ module Stripe
|
|
15
15
|
# by `StripeClient` to determine whether a connection manager should be
|
16
16
|
# garbage collected or not.
|
17
17
|
attr_reader :last_used
|
18
|
+
attr_reader :config
|
18
19
|
|
19
|
-
def initialize
|
20
|
+
def initialize(config = Stripe.config)
|
21
|
+
@config = config
|
20
22
|
@active_connections = {}
|
21
23
|
@last_used = Util.monotonic_time
|
22
24
|
|
@@ -64,7 +66,8 @@ module Stripe
|
|
64
66
|
|
65
67
|
# Executes an HTTP request to the given URI with the given method. Also
|
66
68
|
# allows a request body, headers, and query string to be specified.
|
67
|
-
def execute_request(method, uri, body: nil, headers: nil, query: nil
|
69
|
+
def execute_request(method, uri, body: nil, headers: nil, query: nil,
|
70
|
+
&block)
|
68
71
|
# Perform some basic argument validation because it's easy to get
|
69
72
|
# confused between strings and hashes for things like body and query
|
70
73
|
# parameters.
|
@@ -90,9 +93,44 @@ module Stripe
|
|
90
93
|
u.path
|
91
94
|
end
|
92
95
|
|
93
|
-
|
94
|
-
|
96
|
+
method_name = method.to_s.upcase
|
97
|
+
has_response_body = method_name != "HEAD"
|
98
|
+
request = Net::HTTPGenericRequest.new(
|
99
|
+
method_name,
|
100
|
+
(body ? true : false),
|
101
|
+
has_response_body,
|
102
|
+
path,
|
103
|
+
headers
|
104
|
+
)
|
105
|
+
|
106
|
+
Util.log_debug("ConnectionManager starting request",
|
107
|
+
method_name: method_name,
|
108
|
+
path: path,
|
109
|
+
process_id: Process.pid,
|
110
|
+
thread_object_id: Thread.current.object_id,
|
111
|
+
connection_manager_object_id: object_id,
|
112
|
+
connection_object_id: connection.object_id,
|
113
|
+
log_timestamp: Util.monotonic_time)
|
114
|
+
|
115
|
+
resp = @mutex.synchronize do
|
116
|
+
# The block parameter is special here. If a block is provided, the block
|
117
|
+
# is invoked with the Net::HTTPResponse. However, the body will not have
|
118
|
+
# been read yet in the block, and can be streamed by calling
|
119
|
+
# HTTPResponse#read_body.
|
120
|
+
connection.request(request, body, &block)
|
95
121
|
end
|
122
|
+
|
123
|
+
Util.log_debug("ConnectionManager request complete",
|
124
|
+
method_name: method_name,
|
125
|
+
path: path,
|
126
|
+
process_id: Process.pid,
|
127
|
+
thread_object_id: Thread.current.object_id,
|
128
|
+
connection_manager_object_id: object_id,
|
129
|
+
connection_object_id: connection.object_id,
|
130
|
+
response_object_id: resp.object_id,
|
131
|
+
log_timestamp: Util.monotonic_time)
|
132
|
+
|
133
|
+
resp
|
96
134
|
end
|
97
135
|
|
98
136
|
#
|
@@ -117,14 +155,17 @@ module Stripe
|
|
117
155
|
# reused Go's default for `DefaultTransport`.
|
118
156
|
connection.keep_alive_timeout = 30
|
119
157
|
|
120
|
-
connection.open_timeout =
|
121
|
-
connection.read_timeout =
|
158
|
+
connection.open_timeout = config.open_timeout
|
159
|
+
connection.read_timeout = config.read_timeout
|
160
|
+
if connection.respond_to?(:write_timeout=)
|
161
|
+
connection.write_timeout = config.write_timeout
|
162
|
+
end
|
122
163
|
|
123
164
|
connection.use_ssl = uri.scheme == "https"
|
124
165
|
|
125
|
-
if
|
166
|
+
if config.verify_ssl_certs
|
126
167
|
connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
127
|
-
connection.cert_store =
|
168
|
+
connection.cert_store = config.ca_store
|
128
169
|
else
|
129
170
|
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
130
171
|
warn_ssl_verify_none
|
@@ -138,10 +179,10 @@ module Stripe
|
|
138
179
|
# out those pieces to make passing them into a new connection a little less
|
139
180
|
# ugly.
|
140
181
|
private def proxy_parts
|
141
|
-
if
|
182
|
+
if config.proxy.nil?
|
142
183
|
[nil, nil, nil, nil]
|
143
184
|
else
|
144
|
-
u = URI.parse(
|
185
|
+
u = URI.parse(config.proxy)
|
145
186
|
[u.host, u.port, u.user, u.password]
|
146
187
|
end
|
147
188
|
end
|
data/lib/stripe/error_object.rb
CHANGED
@@ -69,9 +69,8 @@ module Stripe
|
|
69
69
|
@values[:source]
|
70
70
|
end
|
71
71
|
|
72
|
-
# The type of error returned. One of `
|
73
|
-
# `
|
74
|
-
# `invalid_request_error`, or `rate_limit_error`.
|
72
|
+
# The type of error returned. One of `api_error`, `card_error`,
|
73
|
+
# `idempotency_error`, or `invalid_request_error`.
|
75
74
|
def type
|
76
75
|
@values[:type]
|
77
76
|
end
|
@@ -32,6 +32,7 @@ module Stripe
|
|
32
32
|
attr_reader :method
|
33
33
|
attr_reader :num_retries
|
34
34
|
attr_reader :path
|
35
|
+
attr_reader :request_id
|
35
36
|
|
36
37
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
37
38
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -40,12 +41,13 @@ module Stripe
|
|
40
41
|
attr_reader :user_data
|
41
42
|
|
42
43
|
def initialize(duration:, http_status:, method:, num_retries:, path:,
|
43
|
-
user_data: nil)
|
44
|
+
request_id:, user_data: nil)
|
44
45
|
@duration = duration
|
45
46
|
@http_status = http_status
|
46
47
|
@method = method
|
47
48
|
@num_retries = num_retries
|
48
49
|
@path = path
|
50
|
+
@request_id = request_id
|
49
51
|
@user_data = user_data
|
50
52
|
freeze
|
51
53
|
end
|
data/lib/stripe/list_object.rb
CHANGED
@@ -92,8 +92,8 @@ module Stripe
|
|
92
92
|
|
93
93
|
def retrieve(id, opts = {})
|
94
94
|
id, retrieve_params = Util.normalize_id(id)
|
95
|
-
|
96
|
-
|
95
|
+
url = "#{resource_url}/#{CGI.escape(id)}"
|
96
|
+
resp, opts = execute_resource_request(:get, url, retrieve_params, opts)
|
97
97
|
Util.convert_to_stripe_object(resp.data, opts)
|
98
98
|
end
|
99
99
|
|
data/lib/stripe/oauth.rb
CHANGED
@@ -5,10 +5,10 @@ module Stripe
|
|
5
5
|
module OAuthOperations
|
6
6
|
extend APIOperations::Request::ClassMethods
|
7
7
|
|
8
|
-
def self.
|
8
|
+
def self.execute_resource_request(method, url, params, opts)
|
9
9
|
opts = Util.normalize_opts(opts)
|
10
|
-
opts[:client] ||= StripeClient.active_client
|
11
|
-
opts[:api_base] ||=
|
10
|
+
opts[:client] ||= opts[:client] || StripeClient.active_client
|
11
|
+
opts[:api_base] ||= opts[:client].config.connect_base
|
12
12
|
|
13
13
|
super(method, url, params, opts)
|
14
14
|
end
|
@@ -29,7 +29,8 @@ module Stripe
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.authorize_url(params = {}, opts = {})
|
32
|
-
|
32
|
+
client = opts[:client] || StripeClient.active_client
|
33
|
+
base = opts[:connect_base] || client.config.connect_base
|
33
34
|
|
34
35
|
path = "/oauth/authorize"
|
35
36
|
path = "/express" + path if opts[:express]
|
@@ -44,7 +45,7 @@ module Stripe
|
|
44
45
|
def self.token(params = {}, opts = {})
|
45
46
|
opts = Util.normalize_opts(opts)
|
46
47
|
opts[:api_key] = params[:client_secret] if params[:client_secret]
|
47
|
-
resp, opts = OAuthOperations.
|
48
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
48
49
|
:post, "/oauth/token", params, opts
|
49
50
|
)
|
50
51
|
# This is just going to return a generic StripeObject, but that's okay
|
@@ -54,7 +55,7 @@ module Stripe
|
|
54
55
|
def self.deauthorize(params = {}, opts = {})
|
55
56
|
opts = Util.normalize_opts(opts)
|
56
57
|
params[:client_id] = get_client_id(params)
|
57
|
-
resp, opts = OAuthOperations.
|
58
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
58
59
|
:post, "/oauth/deauthorize", params, opts
|
59
60
|
)
|
60
61
|
# This is just going to return a generic StripeObject, but that's okay
|
data/lib/stripe/object_types.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# rubocop:disable Metrics/MethodLength
|
@@ -8,6 +9,7 @@ module Stripe
|
|
8
9
|
{
|
9
10
|
# data structures
|
10
11
|
ListObject::OBJECT_NAME => ListObject,
|
12
|
+
SearchResultObject::OBJECT_NAME => SearchResultObject,
|
11
13
|
|
12
14
|
# business objects
|
13
15
|
Account::OBJECT_NAME => Account,
|
@@ -19,11 +21,13 @@ module Stripe
|
|
19
21
|
Balance::OBJECT_NAME => Balance,
|
20
22
|
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
|
21
23
|
BankAccount::OBJECT_NAME => BankAccount,
|
24
|
+
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
|
22
25
|
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
|
23
26
|
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
|
24
27
|
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
25
28
|
Capability::OBJECT_NAME => Capability,
|
26
29
|
Card::OBJECT_NAME => Card,
|
30
|
+
CashBalance::OBJECT_NAME => CashBalance,
|
27
31
|
Charge::OBJECT_NAME => Charge,
|
28
32
|
Checkout::Session::OBJECT_NAME => Checkout::Session,
|
29
33
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
@@ -40,6 +44,14 @@ module Stripe
|
|
40
44
|
File::OBJECT_NAME => File,
|
41
45
|
File::OBJECT_NAME_ALT => File,
|
42
46
|
FileLink::OBJECT_NAME => FileLink,
|
47
|
+
FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
|
48
|
+
FinancialConnections::AccountOwner::OBJECT_NAME => FinancialConnections::AccountOwner,
|
49
|
+
FinancialConnections::AccountOwnership::OBJECT_NAME =>
|
50
|
+
FinancialConnections::AccountOwnership,
|
51
|
+
FinancialConnections::Session::OBJECT_NAME => FinancialConnections::Session,
|
52
|
+
FundingInstructions::OBJECT_NAME => FundingInstructions,
|
53
|
+
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
|
54
|
+
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
|
43
55
|
Invoice::OBJECT_NAME => Invoice,
|
44
56
|
InvoiceItem::OBJECT_NAME => InvoiceItem,
|
45
57
|
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
@@ -55,12 +67,15 @@ module Stripe
|
|
55
67
|
Order::OBJECT_NAME => Order,
|
56
68
|
OrderReturn::OBJECT_NAME => OrderReturn,
|
57
69
|
PaymentIntent::OBJECT_NAME => PaymentIntent,
|
70
|
+
PaymentLink::OBJECT_NAME => PaymentLink,
|
58
71
|
PaymentMethod::OBJECT_NAME => PaymentMethod,
|
59
72
|
Payout::OBJECT_NAME => Payout,
|
60
73
|
Person::OBJECT_NAME => Person,
|
61
74
|
Plan::OBJECT_NAME => Plan,
|
62
75
|
Price::OBJECT_NAME => Price,
|
63
76
|
Product::OBJECT_NAME => Product,
|
77
|
+
PromotionCode::OBJECT_NAME => PromotionCode,
|
78
|
+
Quote::OBJECT_NAME => Quote,
|
64
79
|
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
|
65
80
|
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
|
66
81
|
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
|
@@ -71,19 +86,24 @@ module Stripe
|
|
71
86
|
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
|
72
87
|
Reversal::OBJECT_NAME => Reversal,
|
73
88
|
Review::OBJECT_NAME => Review,
|
74
|
-
|
89
|
+
SetupAttempt::OBJECT_NAME => SetupAttempt,
|
75
90
|
SetupIntent::OBJECT_NAME => SetupIntent,
|
91
|
+
ShippingRate::OBJECT_NAME => ShippingRate,
|
76
92
|
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
93
|
+
SKU::OBJECT_NAME => SKU,
|
77
94
|
Source::OBJECT_NAME => Source,
|
78
95
|
SourceTransaction::OBJECT_NAME => SourceTransaction,
|
79
96
|
Subscription::OBJECT_NAME => Subscription,
|
80
97
|
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
|
81
98
|
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
|
99
|
+
TaxCode::OBJECT_NAME => TaxCode,
|
82
100
|
TaxId::OBJECT_NAME => TaxId,
|
83
101
|
TaxRate::OBJECT_NAME => TaxRate,
|
102
|
+
Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
|
84
103
|
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
|
85
104
|
Terminal::Location::OBJECT_NAME => Terminal::Location,
|
86
105
|
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
|
106
|
+
TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
|
87
107
|
ThreeDSecure::OBJECT_NAME => ThreeDSecure,
|
88
108
|
Token::OBJECT_NAME => Token,
|
89
109
|
Topup::OBJECT_NAME => Topup,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -44,12 +45,8 @@ module Stripe
|
|
44
45
|
end
|
45
46
|
|
46
47
|
# @override To make id optional
|
47
|
-
def self.retrieve(id =
|
48
|
-
id
|
49
|
-
nil
|
50
|
-
else
|
51
|
-
Util.check_string_argument!(id)
|
52
|
-
end
|
48
|
+
def self.retrieve(id = nil, opts = {})
|
49
|
+
Util.check_string_argument!(id) if id
|
53
50
|
|
54
51
|
# Account used to be a singleton, where this method's signature was
|
55
52
|
# `(opts={})`. For the sake of not breaking folks who pass in an OAuth
|
@@ -64,7 +61,7 @@ module Stripe
|
|
64
61
|
end
|
65
62
|
|
66
63
|
def persons(params = {}, opts = {})
|
67
|
-
resp, opts =
|
64
|
+
resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
|
68
65
|
Util.convert_to_stripe_object(resp.data, opts)
|
69
66
|
end
|
70
67
|
|
@@ -135,11 +132,10 @@ module Stripe
|
|
135
132
|
client_id: client_id,
|
136
133
|
stripe_user_id: id,
|
137
134
|
}
|
135
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
138
136
|
OAuth.deauthorize(params, opts)
|
139
137
|
end
|
140
138
|
|
141
|
-
ARGUMENT_NOT_PROVIDED = Object.new
|
142
|
-
|
143
139
|
private def serialize_additional_owners(legal_entity, additional_owners)
|
144
140
|
original_value =
|
145
141
|
legal_entity
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class ApplicationFeeRefund < APIResource
|
5
|
-
include Stripe::APIOperations::Save
|
6
6
|
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
7
8
|
|
8
9
|
OBJECT_NAME = "fee_refund"
|
9
10
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -9,7 +10,7 @@ module Stripe
|
|
9
10
|
OBJECT_NAME = "bank_account"
|
10
11
|
|
11
12
|
def verify(params = {}, opts = {})
|
12
|
-
resp, opts =
|
13
|
+
resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
|
13
14
|
initialize_from(resp.data, opts)
|
14
15
|
end
|
15
16
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module BillingPortal
|
6
|
+
class Configuration < APIResource
|
7
|
+
extend Stripe::APIOperations::Create
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
include Stripe::APIOperations::Save
|
10
|
+
|
11
|
+
OBJECT_NAME = "billing_portal.configuration"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
5
|
+
# Directly retrieving BitcoinTransactions is deprecated. Please use
|
6
|
+
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
4
7
|
class BitcoinTransaction < APIResource
|
5
|
-
# Directly retrieving BitcoinTransactions is deprecated. Please use the
|
6
|
-
# Sources API instead: https://stripe.com/docs/sources/bitcoin
|
7
8
|
extend Stripe::APIOperations::List
|
8
9
|
|
9
10
|
OBJECT_NAME = "bitcoin_transaction"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -26,7 +27,7 @@ module Stripe
|
|
26
27
|
def self.update(_id, _params = nil, _opts = nil)
|
27
28
|
raise NotImplementedError,
|
28
29
|
"Capabilities cannot be updated without an account ID. Update a " \
|
29
|
-
"capability using Account.update_capability('account_id', " \
|
30
|
+
"capability using `Account.update_capability('account_id', " \
|
30
31
|
"'capability_id', update_params)`"
|
31
32
|
end
|
32
33
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
class CashBalance < APIResource
|
6
|
+
OBJECT_NAME = "cash_balance"
|
7
|
+
|
8
|
+
def resource_url
|
9
|
+
if !respond_to?(:customer) || customer.nil?
|
10
|
+
raise NotImplementedError,
|
11
|
+
"Customer Cash Balance cannot be accessed without a customer ID."
|
12
|
+
end
|
13
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/cash_balance"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.retrieve(_id, _opts = {})
|
17
|
+
raise NotImplementedError,
|
18
|
+
"Customer Cash Balance cannot be retrieved without a customer ID. " \
|
19
|
+
"Retrieve a Customer Cash Balance using `Customer.retrieve_cash_balance('cus_123')`"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class Charge < APIResource
|
5
6
|
extend Stripe::APIOperations::Create
|
6
7
|
extend Stripe::APIOperations::List
|
8
|
+
extend Stripe::APIOperations::Search
|
7
9
|
include Stripe::APIOperations::Save
|
8
10
|
|
9
11
|
OBJECT_NAME = "charge"
|
@@ -18,5 +20,13 @@ module Stripe
|
|
18
20
|
opts: opts
|
19
21
|
)
|
20
22
|
end
|
23
|
+
|
24
|
+
def self.search(params = {}, opts = {})
|
25
|
+
_search("/v1/charges/search", params, opts)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.search_auto_paging_each(params = {}, opts = {}, &blk)
|
29
|
+
search(params, opts).auto_paging_each(&blk)
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -9,7 +10,18 @@ module Stripe
|
|
9
10
|
|
10
11
|
OBJECT_NAME = "checkout.session"
|
11
12
|
|
13
|
+
custom_method :expire, http_verb: :post
|
14
|
+
|
12
15
|
nested_resource_class_methods :line_item, operations: %i[list]
|
16
|
+
|
17
|
+
def expire(params = {}, opts = {})
|
18
|
+
request_stripe_object(
|
19
|
+
method: :post,
|
20
|
+
path: resource_url + "/expire",
|
21
|
+
params: params,
|
22
|
+
opts: opts
|
23
|
+
)
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -20,12 +21,12 @@ module Stripe
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def self.preview(params, opts = {})
|
23
|
-
resp, opts =
|
24
|
+
resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
|
24
25
|
Util.convert_to_stripe_object(resp.data, opts)
|
25
26
|
end
|
26
27
|
|
27
28
|
def self.list_preview_line_items(params, opts = {})
|
28
|
-
resp, opts =
|
29
|
+
resp, opts = execute_resource_request(:get, resource_url + "/preview/lines", params, opts)
|
29
30
|
Util.convert_to_stripe_object(resp.data, opts)
|
30
31
|
end
|
31
32
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -5,16 +6,41 @@ module Stripe
|
|
5
6
|
extend Stripe::APIOperations::Create
|
6
7
|
include Stripe::APIOperations::Delete
|
7
8
|
extend Stripe::APIOperations::List
|
9
|
+
extend Stripe::APIOperations::Search
|
8
10
|
include Stripe::APIOperations::Save
|
9
11
|
extend Stripe::APIOperations::NestedResource
|
10
12
|
|
11
13
|
OBJECT_NAME = "customer"
|
12
14
|
|
15
|
+
custom_method :create_funding_instructions, http_verb: :post, http_path: "funding_instructions"
|
16
|
+
custom_method :list_payment_methods, http_verb: :get, http_path: "payment_methods"
|
17
|
+
|
18
|
+
nested_resource_class_methods :cash_balance,
|
19
|
+
operations: %i[retrieve update],
|
20
|
+
resource_plural: "cash_balance"
|
13
21
|
nested_resource_class_methods :balance_transaction,
|
14
22
|
operations: %i[create retrieve update list]
|
15
23
|
nested_resource_class_methods :tax_id,
|
16
24
|
operations: %i[create retrieve delete list]
|
17
25
|
|
26
|
+
def create_funding_instructions(params = {}, opts = {})
|
27
|
+
request_stripe_object(
|
28
|
+
method: :post,
|
29
|
+
path: resource_url + "/funding_instructions",
|
30
|
+
params: params,
|
31
|
+
opts: opts
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_payment_methods(params = {}, opts = {})
|
36
|
+
request_stripe_object(
|
37
|
+
method: :get,
|
38
|
+
path: resource_url + "/payment_methods",
|
39
|
+
params: params,
|
40
|
+
opts: opts
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
18
44
|
custom_method :delete_discount, http_verb: :delete, http_path: "discount"
|
19
45
|
|
20
46
|
save_nested_resource :source
|
@@ -27,9 +53,22 @@ module Stripe
|
|
27
53
|
alias detach_source delete_source
|
28
54
|
end
|
29
55
|
|
56
|
+
# Deletes a discount associated with the customer.
|
57
|
+
#
|
58
|
+
# Returns the deleted discount. The customer object is not updated,
|
59
|
+
# so you must call `refresh` on it to get a new version with the
|
60
|
+
# discount removed.
|
30
61
|
def delete_discount
|
31
|
-
resp, opts =
|
32
|
-
|
62
|
+
resp, opts = execute_resource_request(:delete, resource_url + "/discount")
|
63
|
+
Util.convert_to_stripe_object(resp.data, opts)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.search(params = {}, opts = {})
|
67
|
+
_search("/v1/customers/search", params, opts)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.search_auto_paging_each(params = {}, opts = {}, &blk)
|
71
|
+
search(params, opts).auto_paging_each(&blk)
|
33
72
|
end
|
34
73
|
end
|
35
74
|
end
|