stripe 5.41.0 → 9.0.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 +256 -0
- data/Gemfile +5 -2
- data/Makefile +13 -0
- data/OPENAPI_VERSION +1 -0
- data/README.md +40 -6
- data/VERSION +1 -1
- data/lib/data/ca-certificates.crt +1241 -1937
- data/lib/stripe/api_operations/create.rb +6 -2
- data/lib/stripe/api_operations/delete.rb +12 -7
- data/lib/stripe/api_operations/list.rb +6 -9
- data/lib/stripe/api_operations/nested_resource.rb +62 -34
- data/lib/stripe/api_operations/request.rb +10 -0
- data/lib/stripe/api_operations/save.rb +13 -3
- data/lib/stripe/api_operations/search.rb +16 -0
- data/lib/stripe/api_resource.rb +3 -18
- data/lib/stripe/api_resource_test_helpers.rb +49 -0
- data/lib/stripe/api_version.rb +8 -0
- data/lib/stripe/connection_manager.rb +22 -1
- data/lib/stripe/instrumentation.rb +45 -7
- data/lib/stripe/object_types.rb +29 -10
- data/lib/stripe/resources/account.rb +36 -9
- data/lib/stripe/resources/account_link.rb +4 -0
- data/lib/stripe/resources/application_fee_refund.rb +5 -0
- data/lib/stripe/resources/apps/secret.rb +40 -0
- data/lib/stripe/resources/balance.rb +11 -0
- data/lib/stripe/resources/balance_transaction.rb +4 -0
- data/lib/stripe/resources/bank_account.rb +7 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +1 -0
- data/lib/stripe/resources/billing_portal/session.rb +14 -0
- data/lib/stripe/resources/capability.rb +3 -0
- data/lib/stripe/resources/card.rb +6 -3
- data/lib/stripe/resources/cash_balance.rb +23 -0
- data/lib/stripe/resources/charge.rb +23 -3
- data/lib/stripe/resources/checkout/session.rb +41 -5
- data/lib/stripe/resources/country_spec.rb +6 -0
- data/lib/stripe/resources/coupon.rb +3 -0
- data/lib/stripe/resources/credit_note.rb +27 -9
- data/lib/stripe/resources/credit_note_line_item.rb +1 -0
- data/lib/stripe/resources/customer.rb +124 -12
- data/lib/stripe/resources/customer_balance_transaction.rb +6 -0
- data/lib/stripe/resources/customer_cash_balance_transaction.rb +14 -0
- data/lib/stripe/resources/discount.rb +4 -0
- data/lib/stripe/resources/dispute.rb +17 -3
- data/lib/stripe/resources/event.rb +29 -0
- data/lib/stripe/resources/exchange_rate.rb +11 -0
- data/lib/stripe/resources/file.rb +7 -0
- data/lib/stripe/resources/file_link.rb +3 -0
- data/lib/stripe/resources/financial_connections/account.rb +67 -0
- data/lib/stripe/resources/financial_connections/account_owner.rb +11 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +11 -0
- data/lib/stripe/resources/financial_connections/session.rb +13 -0
- data/lib/stripe/resources/funding_instructions.rb +21 -0
- data/lib/stripe/resources/identity/verification_report.rb +11 -0
- data/lib/stripe/resources/identity/verification_session.rb +31 -5
- data/lib/stripe/resources/invoice.rb +105 -17
- data/lib/stripe/resources/invoice_item.rb +11 -0
- data/lib/stripe/resources/issuing/authorization.rb +25 -5
- data/lib/stripe/resources/issuing/card.rb +78 -8
- data/lib/stripe/resources/issuing/cardholder.rb +3 -0
- data/lib/stripe/resources/issuing/dispute.rb +13 -3
- data/lib/stripe/resources/issuing/transaction.rb +5 -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/payment_intent.rb +103 -6
- data/lib/stripe/resources/payment_link.rb +35 -0
- data/lib/stripe/resources/payment_method.rb +25 -5
- data/lib/stripe/resources/payout.rb +28 -5
- data/lib/stripe/resources/person.rb +6 -0
- data/lib/stripe/resources/plan.rb +8 -0
- data/lib/stripe/resources/price.rb +15 -0
- data/lib/stripe/resources/product.rb +17 -0
- data/lib/stripe/resources/promotion_code.rb +2 -0
- data/lib/stripe/resources/quote.rb +58 -35
- data/lib/stripe/resources/radar/early_fraud_warning.rb +4 -0
- data/lib/stripe/resources/radar/value_list.rb +3 -0
- data/lib/stripe/resources/radar/value_list_item.rb +3 -0
- data/lib/stripe/resources/refund.rb +49 -0
- data/lib/stripe/resources/reporting/report_run.rb +8 -0
- data/lib/stripe/resources/reporting/report_type.rb +8 -1
- data/lib/stripe/resources/reversal.rb +13 -0
- data/lib/stripe/resources/review.rb +14 -3
- data/lib/stripe/resources/setup_attempt.rb +4 -0
- data/lib/stripe/resources/setup_intent.rb +60 -5
- data/lib/stripe/resources/shipping_rate.rb +2 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +4 -0
- data/lib/stripe/resources/source.rb +26 -6
- data/lib/stripe/resources/source_transaction.rb +4 -0
- data/lib/stripe/resources/subscription.rb +57 -3
- data/lib/stripe/resources/subscription_item.rb +2 -7
- data/lib/stripe/resources/subscription_schedule.rb +23 -5
- data/lib/stripe/resources/tax/calculation.rb +33 -0
- data/lib/stripe/resources/tax/calculation_line_item.rb +10 -0
- data/lib/stripe/resources/tax/settings.rb +15 -0
- data/lib/stripe/resources/tax/transaction.rb +49 -0
- data/lib/stripe/resources/tax/transaction_line_item.rb +10 -0
- data/lib/stripe/resources/tax_code.rb +1 -0
- data/lib/stripe/resources/tax_id.rb +4 -0
- data/lib/stripe/resources/tax_rate.rb +3 -0
- data/lib/stripe/resources/terminal/configuration.rb +16 -0
- data/lib/stripe/resources/terminal/connection_token.rb +3 -0
- data/lib/stripe/resources/terminal/location.rb +3 -0
- data/lib/stripe/resources/terminal/reader.rb +119 -0
- data/lib/stripe/resources/test_helpers/test_clock.rb +35 -0
- data/lib/stripe/resources/token.rb +20 -0
- data/lib/stripe/resources/topup.rb +15 -3
- data/lib/stripe/resources/transfer.rb +10 -11
- data/lib/stripe/resources/treasury/credit_reversal.rb +14 -0
- data/lib/stripe/resources/treasury/debit_reversal.rb +14 -0
- data/lib/stripe/resources/treasury/financial_account.rb +52 -0
- data/lib/stripe/resources/treasury/financial_account_features.rb +12 -0
- data/lib/stripe/resources/treasury/inbound_transfer.rb +94 -0
- data/lib/stripe/resources/treasury/outbound_payment.rb +96 -0
- data/lib/stripe/resources/treasury/outbound_transfer.rb +100 -0
- data/lib/stripe/resources/treasury/received_credit.rb +30 -0
- data/lib/stripe/resources/treasury/received_debit.rb +30 -0
- data/lib/stripe/resources/treasury/transaction.rb +13 -0
- data/lib/stripe/resources/treasury/transaction_entry.rb +17 -0
- data/lib/stripe/resources/usage_record.rb +4 -0
- data/lib/stripe/resources/webhook_endpoint.rb +7 -0
- data/lib/stripe/resources.rb +27 -10
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/stripe_client.rb +37 -22
- data/lib/stripe/stripe_configuration.rb +5 -1
- data/lib/stripe/stripe_object.rb +2 -2
- data/lib/stripe/util.rb +85 -2
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +5 -1
- data/stripe.gemspec +3 -3
- metadata +39 -14
- data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
- data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
- data/lib/stripe/resources/issuing/card_details.rb +0 -10
- data/lib/stripe/resources/order.rb +0 -33
- data/lib/stripe/resources/order_return.rb +0 -10
- data/lib/stripe/resources/recipient.rb +0 -14
- data/lib/stripe/resources/sku.rb +0 -13
- data/lib/stripe/resources/three_d_secure.rb +0 -14
@@ -4,8 +4,12 @@ module Stripe
|
|
4
4
|
module APIOperations
|
5
5
|
module Create
|
6
6
|
def create(params = {}, opts = {})
|
7
|
-
|
8
|
-
|
7
|
+
request_stripe_object(
|
8
|
+
method: :post,
|
9
|
+
path: resource_url,
|
10
|
+
params: params,
|
11
|
+
opts: opts
|
12
|
+
)
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -18,17 +18,22 @@ module Stripe
|
|
18
18
|
# api_key to be overwritten. See
|
19
19
|
# {APIOperations::Request.execute_resource_request}.
|
20
20
|
def delete(id, params = {}, opts = {})
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
request_stripe_object(
|
22
|
+
method: :delete,
|
23
|
+
path: "#{resource_url}/#{id}",
|
24
|
+
params: params,
|
25
|
+
opts: opts
|
26
|
+
)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def delete(params = {}, opts = {})
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
request_stripe_object(
|
32
|
+
method: :delete,
|
33
|
+
path: resource_url,
|
34
|
+
params: params,
|
35
|
+
opts: opts
|
36
|
+
)
|
32
37
|
end
|
33
38
|
|
34
39
|
def self.included(base)
|
@@ -4,15 +4,12 @@ module Stripe
|
|
4
4
|
module APIOperations
|
5
5
|
module List
|
6
6
|
def list(filters = {}, opts = {})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# predicates when accessing the next and previous pages
|
14
|
-
obj.filters = filters.dup
|
15
|
-
obj
|
7
|
+
request_stripe_object(
|
8
|
+
method: :get,
|
9
|
+
path: resource_url,
|
10
|
+
params: filters,
|
11
|
+
opts: opts
|
12
|
+
)
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -26,46 +26,74 @@ module Stripe
|
|
26
26
|
end
|
27
27
|
|
28
28
|
operations.each do |operation|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
define_operation(
|
30
|
+
resource,
|
31
|
+
operation,
|
32
|
+
resource_url_method,
|
33
|
+
resource_plural
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private def define_operation(
|
39
|
+
resource,
|
40
|
+
operation,
|
41
|
+
resource_url_method,
|
42
|
+
resource_plural
|
43
|
+
)
|
44
|
+
case operation
|
45
|
+
when :create
|
46
|
+
define_singleton_method(:"create_#{resource}") \
|
32
47
|
do |id, params = {}, opts = {}|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
request_stripe_object(
|
49
|
+
method: :post,
|
50
|
+
path: send(resource_url_method, id),
|
51
|
+
params: params,
|
52
|
+
opts: opts
|
53
|
+
)
|
54
|
+
end
|
55
|
+
when :retrieve
|
56
|
+
define_singleton_method(:"retrieve_#{resource}") \
|
39
57
|
do |id, nested_id, opts = {}|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
58
|
+
request_stripe_object(
|
59
|
+
method: :get,
|
60
|
+
path: send(resource_url_method, id, nested_id),
|
61
|
+
params: {},
|
62
|
+
opts: opts
|
63
|
+
)
|
64
|
+
end
|
65
|
+
when :update
|
66
|
+
define_singleton_method(:"update_#{resource}") \
|
46
67
|
do |id, nested_id, params = {}, opts = {}|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
68
|
+
request_stripe_object(
|
69
|
+
method: :post,
|
70
|
+
path: send(resource_url_method, id, nested_id),
|
71
|
+
params: params,
|
72
|
+
opts: opts
|
73
|
+
)
|
74
|
+
end
|
75
|
+
when :delete
|
76
|
+
define_singleton_method(:"delete_#{resource}") \
|
53
77
|
do |id, nested_id, params = {}, opts = {}|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
78
|
+
request_stripe_object(
|
79
|
+
method: :delete,
|
80
|
+
path: send(resource_url_method, id, nested_id),
|
81
|
+
params: params,
|
82
|
+
opts: opts
|
83
|
+
)
|
84
|
+
end
|
85
|
+
when :list
|
86
|
+
define_singleton_method(:"list_#{resource_plural}") \
|
61
87
|
do |id, params = {}, opts = {}|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
88
|
+
request_stripe_object(
|
89
|
+
method: :get,
|
90
|
+
path: send(resource_url_method, id),
|
91
|
+
params: params,
|
92
|
+
opts: opts
|
93
|
+
)
|
68
94
|
end
|
95
|
+
else
|
96
|
+
raise ArgumentError, "Unknown operation: #{operation.inspect}"
|
69
97
|
end
|
70
98
|
end
|
71
99
|
end
|
@@ -24,6 +24,11 @@ module Stripe
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
27
|
+
private def request_stripe_object(method:, path:, params:, opts: {})
|
28
|
+
resp, opts = execute_resource_request(method, path, params, opts)
|
29
|
+
Util.convert_to_stripe_object_with_params(resp.data, params, opts)
|
30
|
+
end
|
31
|
+
|
27
32
|
private def execute_resource_request_internal(client_request_method_sym,
|
28
33
|
method, url,
|
29
34
|
params, opts,
|
@@ -122,6 +127,11 @@ module Stripe
|
|
122
127
|
)
|
123
128
|
end
|
124
129
|
|
130
|
+
private def request_stripe_object(method:, path:, params:, opts: {})
|
131
|
+
resp, opts = execute_resource_request(method, path, params, opts)
|
132
|
+
Util.convert_to_stripe_object_with_params(resp.data, params, opts)
|
133
|
+
end
|
134
|
+
|
125
135
|
# See notes on `alias` above.
|
126
136
|
alias request execute_resource_request
|
127
137
|
end
|
@@ -24,12 +24,18 @@ module Stripe
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
request_stripe_object(
|
28
|
+
method: :post,
|
29
|
+
path: "#{resource_url}/#{id}",
|
30
|
+
params: params,
|
31
|
+
opts: opts
|
32
|
+
)
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
36
|
+
# The `save` method is DEPRECATED and will be removed in a future major
|
37
|
+
# version of the library. Use the `update` method on the resource instead.
|
38
|
+
#
|
33
39
|
# Creates or updates an API resource.
|
34
40
|
#
|
35
41
|
# If the resource doesn't yet have an assigned ID and the resource is one
|
@@ -65,6 +71,10 @@ module Stripe
|
|
65
71
|
resp, opts = execute_resource_request(:post, save_url, values, opts)
|
66
72
|
initialize_from(resp.data, opts)
|
67
73
|
end
|
74
|
+
extend Gem::Deprecate
|
75
|
+
deprecate :save, "the `update` class method (for examples"\
|
76
|
+
" see https://github.com/stripe/stripe-ruby"\
|
77
|
+
"/wiki/Migration-guide-for-v8)", 2022, 11
|
68
78
|
|
69
79
|
def self.included(base)
|
70
80
|
# Set `metadata` as additive so that when it's set directly we remember
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
module APIOperations
|
5
|
+
module Search
|
6
|
+
def _search(search_url, filters = {}, opts = {})
|
7
|
+
request_stripe_object(
|
8
|
+
method: :get,
|
9
|
+
path: search_url,
|
10
|
+
params: filters,
|
11
|
+
opts: opts
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -63,22 +63,7 @@ module Stripe
|
|
63
63
|
# adds a `capture` class method to the resource class that, when called,
|
64
64
|
# will send a POST request to `/v1/<object_name>/capture`.
|
65
65
|
def self.custom_method(name, http_verb:, http_path: nil)
|
66
|
-
|
67
|
-
raise ArgumentError,
|
68
|
-
"Invalid http_verb value: #{http_verb.inspect}. Should be one " \
|
69
|
-
"of :get, :post or :delete."
|
70
|
-
end
|
71
|
-
http_path ||= name.to_s
|
72
|
-
define_singleton_method(name) do |id, params = {}, opts = {}|
|
73
|
-
unless id.is_a?(String)
|
74
|
-
raise ArgumentError,
|
75
|
-
"id should be a string representing the ID of an API resource"
|
76
|
-
end
|
77
|
-
|
78
|
-
url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
|
79
|
-
resp, opts = execute_resource_request(http_verb, url, params, opts)
|
80
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
81
|
-
end
|
66
|
+
Util.custom_method self, self, name, http_verb, http_path
|
82
67
|
end
|
83
68
|
|
84
69
|
def resource_url
|
@@ -105,14 +90,14 @@ module Stripe
|
|
105
90
|
instance
|
106
91
|
end
|
107
92
|
|
108
|
-
|
93
|
+
def request_stripe_object(method:, path:, params:, opts: {})
|
109
94
|
resp, opts = execute_resource_request(method, path, params, opts)
|
110
95
|
|
111
96
|
# If we're getting back this thing, update; otherwise, instantiate.
|
112
97
|
if Util.object_name_matches_class?(resp.data[:object], self.class)
|
113
98
|
initialize_from(resp.data, opts)
|
114
99
|
else
|
115
|
-
Util.
|
100
|
+
Util.convert_to_stripe_object_with_params(resp.data, params, opts)
|
116
101
|
end
|
117
102
|
end
|
118
103
|
|
@@ -0,0 +1,49 @@
|
|
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
|
+
include Stripe::APIOperations::Request
|
12
|
+
|
13
|
+
def initialize(resource)
|
14
|
+
@resource = resource
|
15
|
+
end
|
16
|
+
|
17
|
+
# Adds a custom method to a test helper. This is used to add support for
|
18
|
+
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
|
19
|
+
# following parameters:
|
20
|
+
# - name: the name of the custom method to create (as a symbol)
|
21
|
+
# - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
|
22
|
+
# - http_path: the path to append to the resource's URL. If not provided,
|
23
|
+
# the name is used as the path
|
24
|
+
#
|
25
|
+
# For example, this call:
|
26
|
+
# custom_method :capture, http_verb: post
|
27
|
+
# adds a `capture` class method to the resource class that, when called,
|
28
|
+
# will send a POST request to `/v1/<object_name>/capture`.
|
29
|
+
def self.custom_method(name, http_verb:, http_path: nil)
|
30
|
+
Util.custom_method self::RESOURCE_CLASS, self, name, http_verb, http_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.resource_url
|
34
|
+
"/v1/test_helpers/"\
|
35
|
+
"#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
|
36
|
+
end
|
37
|
+
|
38
|
+
def resource_url
|
39
|
+
unless (id = @resource["id"])
|
40
|
+
raise InvalidRequestError.new(
|
41
|
+
"Could not determine which URL to request: #{self.class} instance " \
|
42
|
+
"has invalid ID: #{id.inspect}",
|
43
|
+
"id"
|
44
|
+
)
|
45
|
+
end
|
46
|
+
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -103,13 +103,34 @@ module Stripe
|
|
103
103
|
headers
|
104
104
|
)
|
105
105
|
|
106
|
-
|
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
|
107
116
|
# The block parameter is special here. If a block is provided, the block
|
108
117
|
# is invoked with the Net::HTTPResponse. However, the body will not have
|
109
118
|
# been read yet in the block, and can be streamed by calling
|
110
119
|
# HTTPResponse#read_body.
|
111
120
|
connection.request(request, body, &block)
|
112
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
|
113
134
|
end
|
114
135
|
|
115
136
|
#
|
@@ -33,6 +33,10 @@ module Stripe
|
|
33
33
|
attr_reader :num_retries
|
34
34
|
attr_reader :path
|
35
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
|
36
40
|
|
37
41
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
38
42
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -40,19 +44,53 @@ module Stripe
|
|
40
44
|
# in `request_end`.
|
41
45
|
attr_reader :user_data
|
42
46
|
|
43
|
-
def initialize(
|
44
|
-
|
45
|
-
@duration = duration
|
46
|
-
@http_status = http_status
|
47
|
-
@method = method
|
47
|
+
def initialize(request_context:, response_context:,
|
48
|
+
num_retries:, user_data: nil)
|
49
|
+
@duration = request_context.duration
|
50
|
+
@http_status = response_context.http_status
|
51
|
+
@method = request_context.method
|
48
52
|
@num_retries = num_retries
|
49
|
-
@path = path
|
50
|
-
@request_id = request_id
|
53
|
+
@path = request_context.path
|
54
|
+
@request_id = request_context.request_id
|
51
55
|
@user_data = user_data
|
56
|
+
@response_header = response_context.header
|
57
|
+
@response_body = response_context.body
|
58
|
+
@request_header = request_context.header
|
59
|
+
@request_body = request_context.body
|
52
60
|
freeze
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
64
|
+
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
|
71
|
+
|
72
|
+
def initialize(duration:, context:, header:)
|
73
|
+
@duration = duration
|
74
|
+
@method = context.method
|
75
|
+
@path = context.path
|
76
|
+
@request_id = context.request_id
|
77
|
+
@body = context.body
|
78
|
+
@header = header
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class ResponseContext
|
83
|
+
attr_reader :http_status
|
84
|
+
attr_reader :body
|
85
|
+
attr_reader :header
|
86
|
+
|
87
|
+
def initialize(http_status:, response:)
|
88
|
+
@http_status = http_status
|
89
|
+
@header = response ? response.to_hash : nil
|
90
|
+
@body = response ? response.body : nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
56
94
|
# This class was renamed for consistency. This alias is here for backwards
|
57
95
|
# compatibility.
|
58
96
|
RequestEvent = RequestEndEvent
|
data/lib/stripe/object_types.rb
CHANGED
@@ -9,23 +9,23 @@ module Stripe
|
|
9
9
|
{
|
10
10
|
# data structures
|
11
11
|
ListObject::OBJECT_NAME => ListObject,
|
12
|
+
SearchResultObject::OBJECT_NAME => SearchResultObject,
|
12
13
|
|
13
14
|
# business objects
|
14
15
|
Account::OBJECT_NAME => Account,
|
15
16
|
AccountLink::OBJECT_NAME => AccountLink,
|
16
|
-
AlipayAccount::OBJECT_NAME => AlipayAccount,
|
17
17
|
ApplePayDomain::OBJECT_NAME => ApplePayDomain,
|
18
18
|
ApplicationFee::OBJECT_NAME => ApplicationFee,
|
19
19
|
ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
|
20
|
+
Apps::Secret::OBJECT_NAME => Apps::Secret,
|
20
21
|
Balance::OBJECT_NAME => Balance,
|
21
22
|
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
|
22
23
|
BankAccount::OBJECT_NAME => BankAccount,
|
23
24
|
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
|
24
25
|
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
|
25
|
-
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
|
26
|
-
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
27
26
|
Capability::OBJECT_NAME => Capability,
|
28
27
|
Card::OBJECT_NAME => Card,
|
28
|
+
CashBalance::OBJECT_NAME => CashBalance,
|
29
29
|
Charge::OBJECT_NAME => Charge,
|
30
30
|
Checkout::Session::OBJECT_NAME => Checkout::Session,
|
31
31
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
@@ -34,6 +34,7 @@ module Stripe
|
|
34
34
|
CreditNoteLineItem::OBJECT_NAME => CreditNoteLineItem,
|
35
35
|
Customer::OBJECT_NAME => Customer,
|
36
36
|
CustomerBalanceTransaction::OBJECT_NAME => CustomerBalanceTransaction,
|
37
|
+
CustomerCashBalanceTransaction::OBJECT_NAME => CustomerCashBalanceTransaction,
|
37
38
|
Discount::OBJECT_NAME => Discount,
|
38
39
|
Dispute::OBJECT_NAME => Dispute,
|
39
40
|
EphemeralKey::OBJECT_NAME => EphemeralKey,
|
@@ -42,6 +43,12 @@ module Stripe
|
|
42
43
|
File::OBJECT_NAME => File,
|
43
44
|
File::OBJECT_NAME_ALT => File,
|
44
45
|
FileLink::OBJECT_NAME => FileLink,
|
46
|
+
FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
|
47
|
+
FinancialConnections::AccountOwner::OBJECT_NAME => FinancialConnections::AccountOwner,
|
48
|
+
FinancialConnections::AccountOwnership::OBJECT_NAME =>
|
49
|
+
FinancialConnections::AccountOwnership,
|
50
|
+
FinancialConnections::Session::OBJECT_NAME => FinancialConnections::Session,
|
51
|
+
FundingInstructions::OBJECT_NAME => FundingInstructions,
|
45
52
|
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
|
46
53
|
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
|
47
54
|
Invoice::OBJECT_NAME => Invoice,
|
@@ -49,16 +56,14 @@ module Stripe
|
|
49
56
|
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
50
57
|
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
|
51
58
|
Issuing::Card::OBJECT_NAME => Issuing::Card,
|
52
|
-
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
|
53
59
|
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
|
54
60
|
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
|
55
61
|
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
|
56
62
|
LineItem::OBJECT_NAME => LineItem,
|
57
63
|
LoginLink::OBJECT_NAME => LoginLink,
|
58
64
|
Mandate::OBJECT_NAME => Mandate,
|
59
|
-
Order::OBJECT_NAME => Order,
|
60
|
-
OrderReturn::OBJECT_NAME => OrderReturn,
|
61
65
|
PaymentIntent::OBJECT_NAME => PaymentIntent,
|
66
|
+
PaymentLink::OBJECT_NAME => PaymentLink,
|
62
67
|
PaymentMethod::OBJECT_NAME => PaymentMethod,
|
63
68
|
Payout::OBJECT_NAME => Payout,
|
64
69
|
Person::OBJECT_NAME => Person,
|
@@ -70,8 +75,6 @@ module Stripe
|
|
70
75
|
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
|
71
76
|
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
|
72
77
|
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
|
73
|
-
Recipient::OBJECT_NAME => Recipient,
|
74
|
-
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
|
75
78
|
Refund::OBJECT_NAME => Refund,
|
76
79
|
Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
|
77
80
|
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
|
@@ -81,22 +84,38 @@ module Stripe
|
|
81
84
|
SetupIntent::OBJECT_NAME => SetupIntent,
|
82
85
|
ShippingRate::OBJECT_NAME => ShippingRate,
|
83
86
|
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
84
|
-
SKU::OBJECT_NAME => SKU,
|
85
87
|
Source::OBJECT_NAME => Source,
|
86
88
|
SourceTransaction::OBJECT_NAME => SourceTransaction,
|
87
89
|
Subscription::OBJECT_NAME => Subscription,
|
88
90
|
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
|
89
91
|
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
|
92
|
+
Tax::Calculation::OBJECT_NAME => Tax::Calculation,
|
93
|
+
Tax::CalculationLineItem::OBJECT_NAME => Tax::CalculationLineItem,
|
94
|
+
Tax::Settings::OBJECT_NAME => Tax::Settings,
|
95
|
+
Tax::Transaction::OBJECT_NAME => Tax::Transaction,
|
96
|
+
Tax::TransactionLineItem::OBJECT_NAME => Tax::TransactionLineItem,
|
90
97
|
TaxCode::OBJECT_NAME => TaxCode,
|
91
98
|
TaxId::OBJECT_NAME => TaxId,
|
92
99
|
TaxRate::OBJECT_NAME => TaxRate,
|
100
|
+
Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
|
93
101
|
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
|
94
102
|
Terminal::Location::OBJECT_NAME => Terminal::Location,
|
95
103
|
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
|
96
|
-
|
104
|
+
TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
|
97
105
|
Token::OBJECT_NAME => Token,
|
98
106
|
Topup::OBJECT_NAME => Topup,
|
99
107
|
Transfer::OBJECT_NAME => Transfer,
|
108
|
+
Treasury::CreditReversal::OBJECT_NAME => Treasury::CreditReversal,
|
109
|
+
Treasury::DebitReversal::OBJECT_NAME => Treasury::DebitReversal,
|
110
|
+
Treasury::FinancialAccount::OBJECT_NAME => Treasury::FinancialAccount,
|
111
|
+
Treasury::FinancialAccountFeatures::OBJECT_NAME => Treasury::FinancialAccountFeatures,
|
112
|
+
Treasury::InboundTransfer::OBJECT_NAME => Treasury::InboundTransfer,
|
113
|
+
Treasury::OutboundPayment::OBJECT_NAME => Treasury::OutboundPayment,
|
114
|
+
Treasury::OutboundTransfer::OBJECT_NAME => Treasury::OutboundTransfer,
|
115
|
+
Treasury::ReceivedCredit::OBJECT_NAME => Treasury::ReceivedCredit,
|
116
|
+
Treasury::ReceivedDebit::OBJECT_NAME => Treasury::ReceivedDebit,
|
117
|
+
Treasury::Transaction::OBJECT_NAME => Treasury::Transaction,
|
118
|
+
Treasury::TransactionEntry::OBJECT_NAME => Treasury::TransactionEntry,
|
100
119
|
UsageRecord::OBJECT_NAME => UsageRecord,
|
101
120
|
UsageRecordSummary::OBJECT_NAME => UsageRecordSummary,
|
102
121
|
WebhookEndpoint::OBJECT_NAME => WebhookEndpoint,
|
@@ -2,6 +2,14 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Stripe
|
5
|
+
# This is an object representing a Stripe account. You can retrieve it to see
|
6
|
+
# properties on the account like its current requirements or if the account is
|
7
|
+
# enabled to make live charges or receive payouts.
|
8
|
+
#
|
9
|
+
# For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that
|
10
|
+
# account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links)
|
11
|
+
# for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express**
|
12
|
+
# below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
|
5
13
|
class Account < APIResource
|
6
14
|
extend Gem::Deprecate
|
7
15
|
extend Stripe::APIOperations::Create
|
@@ -12,18 +20,43 @@ module Stripe
|
|
12
20
|
|
13
21
|
OBJECT_NAME = "account"
|
14
22
|
|
15
|
-
custom_method :reject, http_verb: :post
|
16
|
-
|
17
23
|
nested_resource_class_methods :capability,
|
18
24
|
operations: %i[retrieve update list],
|
19
25
|
resource_plural: "capabilities"
|
20
26
|
nested_resource_class_methods :person,
|
21
27
|
operations: %i[create retrieve update delete list]
|
22
28
|
|
29
|
+
def persons(params = {}, opts = {})
|
30
|
+
request_stripe_object(
|
31
|
+
method: :get,
|
32
|
+
path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(self["id"]) }),
|
33
|
+
params: params,
|
34
|
+
opts: opts
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
23
38
|
def reject(params = {}, opts = {})
|
24
39
|
request_stripe_object(
|
25
40
|
method: :post,
|
26
|
-
path:
|
41
|
+
path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(self["id"]) }),
|
42
|
+
params: params,
|
43
|
+
opts: opts
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.persons(account, params = {}, opts = {})
|
48
|
+
request_stripe_object(
|
49
|
+
method: :get,
|
50
|
+
path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(account) }),
|
51
|
+
params: params,
|
52
|
+
opts: opts
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.reject(account, params = {}, opts = {})
|
57
|
+
request_stripe_object(
|
58
|
+
method: :post,
|
59
|
+
path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(account) }),
|
27
60
|
params: params,
|
28
61
|
opts: opts
|
29
62
|
)
|
@@ -33,7 +66,6 @@ module Stripe
|
|
33
66
|
|
34
67
|
nested_resource_class_methods :external_account,
|
35
68
|
operations: %i[create retrieve update delete list]
|
36
|
-
|
37
69
|
nested_resource_class_methods :login_link, operations: %i[create]
|
38
70
|
|
39
71
|
def resource_url
|
@@ -60,11 +92,6 @@ module Stripe
|
|
60
92
|
super(id, opts)
|
61
93
|
end
|
62
94
|
|
63
|
-
def persons(params = {}, opts = {})
|
64
|
-
resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
|
65
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
66
|
-
end
|
67
|
-
|
68
95
|
# We are not adding a helper for capabilities here as the Account object
|
69
96
|
# already has a capabilities property which is a hash and not the sub-list
|
70
97
|
# of capabilities.
|
@@ -2,6 +2,10 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Stripe
|
5
|
+
# Account Links are the means by which a Connect platform grants a connected account permission to access
|
6
|
+
# Stripe-hosted applications, such as Connect Onboarding.
|
7
|
+
#
|
8
|
+
# Related guide: [Connect Onboarding](https://stripe.com/docs/connect/connect-onboarding)
|
5
9
|
class AccountLink < APIResource
|
6
10
|
extend Stripe::APIOperations::Create
|
7
11
|
|