stripe 10.7.0.pre.beta.3 → 10.7.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 +44 -266
- data/OPENAPI_VERSION +1 -1
- data/README.md +0 -11
- data/VERSION +1 -1
- data/lib/stripe/api_operations/request.rb +1 -2
- data/lib/stripe/api_version.rb +0 -1
- data/lib/stripe/object_types.rb +0 -19
- data/lib/stripe/resources/application_fee_refund.rb +0 -1
- data/lib/stripe/resources/capability.rb +0 -1
- data/lib/stripe/resources/customer_balance_transaction.rb +0 -1
- data/lib/stripe/resources/customer_cash_balance_transaction.rb +0 -2
- data/lib/stripe/resources/financial_connections/account.rb +0 -3
- data/lib/stripe/resources/invoice.rb +0 -53
- data/lib/stripe/resources/person.rb +0 -1
- data/lib/stripe/resources/quote.rb +0 -104
- data/lib/stripe/resources/reversal.rb +0 -1
- data/lib/stripe/resources/subscription_schedule.rb +0 -20
- data/lib/stripe/resources/tax_id.rb +0 -1
- data/lib/stripe/resources/terminal/reader.rb +0 -60
- data/lib/stripe/resources.rb +0 -18
- data/lib/stripe/stripe_client.rb +28 -62
- data/lib/stripe/stripe_configuration.rb +1 -2
- data/lib/stripe/util.rb +1 -8
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +0 -46
- metadata +4 -23
- data/lib/stripe/request_signing_authenticator.rb +0 -79
- data/lib/stripe/resources/account_notice.rb +0 -14
- data/lib/stripe/resources/capital/financing_offer.rb +0 -36
- data/lib/stripe/resources/capital/financing_summary.rb +0 -12
- data/lib/stripe/resources/capital/financing_transaction.rb +0 -13
- data/lib/stripe/resources/confirmation_token.rb +0 -13
- data/lib/stripe/resources/financial_connections/account_inferred_balance.rb +0 -13
- data/lib/stripe/resources/gift_cards/card.rb +0 -26
- data/lib/stripe/resources/gift_cards/transaction.rb +0 -60
- data/lib/stripe/resources/invoice_payment.rb +0 -11
- data/lib/stripe/resources/issuing/credit_underwriting_record.rb +0 -75
- data/lib/stripe/resources/issuing/personalization_design.rb +0 -83
- data/lib/stripe/resources/issuing/physical_bundle.rb +0 -13
- data/lib/stripe/resources/margin.rb +0 -14
- data/lib/stripe/resources/order.rb +0 -97
- data/lib/stripe/resources/quote_phase.rb +0 -31
- data/lib/stripe/resources/quote_preview_invoice.rb +0 -42
- data/lib/stripe/resources/quote_preview_subscription_schedule.rb +0 -10
- data/lib/stripe/resources/tax/form.rb +0 -41
@@ -6,12 +6,9 @@ module Stripe
|
|
6
6
|
# A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access.
|
7
7
|
class Account < APIResource
|
8
8
|
extend Stripe::APIOperations::List
|
9
|
-
extend Stripe::APIOperations::NestedResource
|
10
9
|
|
11
10
|
OBJECT_NAME = "financial_connections.account"
|
12
11
|
|
13
|
-
nested_resource_class_methods :inferred_balance, operations: %i[list]
|
14
|
-
|
15
12
|
# Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions).
|
16
13
|
def disconnect(params = {}, opts = {})
|
17
14
|
request_stripe_object(
|
@@ -40,30 +40,9 @@ module Stripe
|
|
40
40
|
extend Stripe::APIOperations::List
|
41
41
|
extend Stripe::APIOperations::Search
|
42
42
|
include Stripe::APIOperations::Save
|
43
|
-
extend Stripe::APIOperations::NestedResource
|
44
43
|
|
45
44
|
OBJECT_NAME = "invoice"
|
46
45
|
|
47
|
-
nested_resource_class_methods :payment, operations: %i[retrieve list]
|
48
|
-
|
49
|
-
# Attaches a PaymentIntent to the invoice, adding it to the list of payments.
|
50
|
-
# When the PaymentIntent's status changes to succeeded, the payment is credited
|
51
|
-
# to the invoice, increasing its amount_paid. When the invoice is fully paid, the
|
52
|
-
# invoice's status becomes paid.
|
53
|
-
#
|
54
|
-
# If the PaymentIntent's status is already succeeded when it is attached, it is
|
55
|
-
# credited to the invoice immediately.
|
56
|
-
#
|
57
|
-
# Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create)
|
58
|
-
def attach_payment_intent(params = {}, opts = {})
|
59
|
-
request_stripe_object(
|
60
|
-
method: :post,
|
61
|
-
path: format("/v1/invoices/%<invoice>s/attach_payment_intent", { invoice: CGI.escape(self["id"]) }),
|
62
|
-
params: params,
|
63
|
-
opts: opts
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
46
|
# Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method.
|
68
47
|
def finalize_invoice(params = {}, opts = {})
|
69
48
|
request_stripe_object(
|
@@ -116,38 +95,6 @@ module Stripe
|
|
116
95
|
)
|
117
96
|
end
|
118
97
|
|
119
|
-
# Attaches a PaymentIntent to the invoice, adding it to the list of payments.
|
120
|
-
# When the PaymentIntent's status changes to succeeded, the payment is credited
|
121
|
-
# to the invoice, increasing its amount_paid. When the invoice is fully paid, the
|
122
|
-
# invoice's status becomes paid.
|
123
|
-
#
|
124
|
-
# If the PaymentIntent's status is already succeeded when it is attached, it is
|
125
|
-
# credited to the invoice immediately.
|
126
|
-
#
|
127
|
-
# Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create)
|
128
|
-
def self.attach_payment_intent(invoice, params = {}, opts = {})
|
129
|
-
request_stripe_object(
|
130
|
-
method: :post,
|
131
|
-
path: format("/v1/invoices/%<invoice>s/attach_payment_intent", { invoice: CGI.escape(invoice) }),
|
132
|
-
params: params,
|
133
|
-
opts: opts
|
134
|
-
)
|
135
|
-
end
|
136
|
-
|
137
|
-
# At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.
|
138
|
-
#
|
139
|
-
# Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.
|
140
|
-
#
|
141
|
-
# You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource.
|
142
|
-
def self.create_preview(params = {}, opts = {})
|
143
|
-
request_stripe_object(
|
144
|
-
method: :post,
|
145
|
-
path: "/v1/invoices/create_preview",
|
146
|
-
params: params,
|
147
|
-
opts: opts
|
148
|
-
)
|
149
|
-
end
|
150
|
-
|
151
98
|
# Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method.
|
152
99
|
def self.finalize_invoice(invoice, params = {}, opts = {})
|
153
100
|
request_stripe_object(
|
@@ -9,7 +9,6 @@ module Stripe
|
|
9
9
|
#
|
10
10
|
# Related guide: [Handling identity verification with the API](https://stripe.com/docs/connect/handling-api-verification#person-information)
|
11
11
|
class Person < APIResource
|
12
|
-
extend Stripe::APIOperations::List
|
13
12
|
include Stripe::APIOperations::Save
|
14
13
|
|
15
14
|
OBJECT_NAME = "person"
|
@@ -8,13 +8,9 @@ module Stripe
|
|
8
8
|
extend Stripe::APIOperations::Create
|
9
9
|
extend Stripe::APIOperations::List
|
10
10
|
include Stripe::APIOperations::Save
|
11
|
-
extend Stripe::APIOperations::NestedResource
|
12
11
|
|
13
12
|
OBJECT_NAME = "quote"
|
14
13
|
|
15
|
-
nested_resource_class_methods :preview_invoice, operations: %i[list]
|
16
|
-
nested_resource_class_methods :preview_subscription_schedule, operations: %i[list]
|
17
|
-
|
18
14
|
# Accepts the specified quote.
|
19
15
|
def accept(params = {}, opts = {})
|
20
16
|
request_stripe_object(
|
@@ -65,46 +61,6 @@ module Stripe
|
|
65
61
|
)
|
66
62
|
end
|
67
63
|
|
68
|
-
# Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.
|
69
|
-
def list_lines(params = {}, opts = {})
|
70
|
-
request_stripe_object(
|
71
|
-
method: :get,
|
72
|
-
path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(self["id"]) }),
|
73
|
-
params: params,
|
74
|
-
opts: opts
|
75
|
-
)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Preview the invoice line items that would be generated by accepting the quote.
|
79
|
-
def list_preview_invoice_lines(preview_invoice, params = {}, opts = {})
|
80
|
-
request_stripe_object(
|
81
|
-
method: :get,
|
82
|
-
path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(self["id"]), preview_invoice: CGI.escape(preview_invoice) }),
|
83
|
-
params: params,
|
84
|
-
opts: opts
|
85
|
-
)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Converts a stale quote to draft.
|
89
|
-
def mark_draft(params = {}, opts = {})
|
90
|
-
request_stripe_object(
|
91
|
-
method: :post,
|
92
|
-
path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(self["id"]) }),
|
93
|
-
params: params,
|
94
|
-
opts: opts
|
95
|
-
)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Converts a draft or open quote to stale.
|
99
|
-
def mark_stale(params = {}, opts = {})
|
100
|
-
request_stripe_object(
|
101
|
-
method: :post,
|
102
|
-
path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(self["id"]) }),
|
103
|
-
params: params,
|
104
|
-
opts: opts
|
105
|
-
)
|
106
|
-
end
|
107
|
-
|
108
64
|
# Download the PDF for a finalized quote
|
109
65
|
def pdf(params = {}, opts = {}, &read_body_chunk_block)
|
110
66
|
config = opts[:client]&.config || Stripe.config
|
@@ -118,16 +74,6 @@ module Stripe
|
|
118
74
|
)
|
119
75
|
end
|
120
76
|
|
121
|
-
# Recompute the upcoming invoice estimate for the quote.
|
122
|
-
def reestimate(params = {}, opts = {})
|
123
|
-
request_stripe_object(
|
124
|
-
method: :post,
|
125
|
-
path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(self["id"]) }),
|
126
|
-
params: params,
|
127
|
-
opts: opts
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
77
|
# Accepts the specified quote.
|
132
78
|
def self.accept(quote, params = {}, opts = {})
|
133
79
|
request_stripe_object(
|
@@ -178,46 +124,6 @@ module Stripe
|
|
178
124
|
)
|
179
125
|
end
|
180
126
|
|
181
|
-
# Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.
|
182
|
-
def self.list_lines(quote, params = {}, opts = {})
|
183
|
-
request_stripe_object(
|
184
|
-
method: :get,
|
185
|
-
path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(quote) }),
|
186
|
-
params: params,
|
187
|
-
opts: opts
|
188
|
-
)
|
189
|
-
end
|
190
|
-
|
191
|
-
# Preview the invoice line items that would be generated by accepting the quote.
|
192
|
-
def self.list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {})
|
193
|
-
request_stripe_object(
|
194
|
-
method: :get,
|
195
|
-
path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(quote), preview_invoice: CGI.escape(preview_invoice) }),
|
196
|
-
params: params,
|
197
|
-
opts: opts
|
198
|
-
)
|
199
|
-
end
|
200
|
-
|
201
|
-
# Converts a stale quote to draft.
|
202
|
-
def self.mark_draft(quote, params = {}, opts = {})
|
203
|
-
request_stripe_object(
|
204
|
-
method: :post,
|
205
|
-
path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(quote) }),
|
206
|
-
params: params,
|
207
|
-
opts: opts
|
208
|
-
)
|
209
|
-
end
|
210
|
-
|
211
|
-
# Converts a draft or open quote to stale.
|
212
|
-
def self.mark_stale(quote, params = {}, opts = {})
|
213
|
-
request_stripe_object(
|
214
|
-
method: :post,
|
215
|
-
path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(quote) }),
|
216
|
-
params: params,
|
217
|
-
opts: opts
|
218
|
-
)
|
219
|
-
end
|
220
|
-
|
221
127
|
# Download the PDF for a finalized quote
|
222
128
|
def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
|
223
129
|
config = opts[:client]&.config || Stripe.config
|
@@ -230,15 +136,5 @@ module Stripe
|
|
230
136
|
&read_body_chunk_block
|
231
137
|
)
|
232
138
|
end
|
233
|
-
|
234
|
-
# Recompute the upcoming invoice estimate for the quote.
|
235
|
-
def self.reestimate(quote, params = {}, opts = {})
|
236
|
-
request_stripe_object(
|
237
|
-
method: :post,
|
238
|
-
path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(quote) }),
|
239
|
-
params: params,
|
240
|
-
opts: opts
|
241
|
-
)
|
242
|
-
end
|
243
139
|
end
|
244
140
|
end
|
@@ -16,7 +16,6 @@ module Stripe
|
|
16
16
|
#
|
17
17
|
# Related guide: [Reversing transfers](https://stripe.com/docs/connect/separate-charges-and-transfers#reversing-transfers)
|
18
18
|
class Reversal < APIResource
|
19
|
-
extend Stripe::APIOperations::List
|
20
19
|
include Stripe::APIOperations::Save
|
21
20
|
|
22
21
|
OBJECT_NAME = "transfer_reversal"
|
@@ -12,16 +12,6 @@ module Stripe
|
|
12
12
|
|
13
13
|
OBJECT_NAME = "subscription_schedule"
|
14
14
|
|
15
|
-
# Amends an existing subscription schedule.
|
16
|
-
def amend(params = {}, opts = {})
|
17
|
-
request_stripe_object(
|
18
|
-
method: :post,
|
19
|
-
path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(self["id"]) }),
|
20
|
-
params: params,
|
21
|
-
opts: opts
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
15
|
# Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.
|
26
16
|
def cancel(params = {}, opts = {})
|
27
17
|
request_stripe_object(
|
@@ -42,16 +32,6 @@ module Stripe
|
|
42
32
|
)
|
43
33
|
end
|
44
34
|
|
45
|
-
# Amends an existing subscription schedule.
|
46
|
-
def self.amend(schedule, params = {}, opts = {})
|
47
|
-
request_stripe_object(
|
48
|
-
method: :post,
|
49
|
-
path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(schedule) }),
|
50
|
-
params: params,
|
51
|
-
opts: opts
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
35
|
# Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.
|
56
36
|
def self.cancel(schedule, params = {}, opts = {})
|
57
37
|
request_stripe_object(
|
@@ -8,7 +8,6 @@ module Stripe
|
|
8
8
|
# Related guides: [Customer tax identification numbers](https://stripe.com/docs/billing/taxes/tax-ids), [Account tax IDs](https://stripe.com/docs/invoicing/connect#account-tax-ids)
|
9
9
|
class TaxId < APIResource
|
10
10
|
include Stripe::APIOperations::Delete
|
11
|
-
extend Stripe::APIOperations::List
|
12
11
|
|
13
12
|
OBJECT_NAME = "tax_id"
|
14
13
|
|
@@ -24,36 +24,6 @@ module Stripe
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
27
|
-
# Initiates an input collection flow on a Reader.
|
28
|
-
def collect_inputs(params = {}, opts = {})
|
29
|
-
request_stripe_object(
|
30
|
-
method: :post,
|
31
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_inputs", { reader: CGI.escape(self["id"]) }),
|
32
|
-
params: params,
|
33
|
-
opts: opts
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation.
|
38
|
-
def collect_payment_method(params = {}, opts = {})
|
39
|
-
request_stripe_object(
|
40
|
-
method: :post,
|
41
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_payment_method", { reader: CGI.escape(self["id"]) }),
|
42
|
-
params: params,
|
43
|
-
opts: opts
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Finalizes a payment on a Reader.
|
48
|
-
def confirm_payment_intent(params = {}, opts = {})
|
49
|
-
request_stripe_object(
|
50
|
-
method: :post,
|
51
|
-
path: format("/v1/terminal/readers/%<reader>s/confirm_payment_intent", { reader: CGI.escape(self["id"]) }),
|
52
|
-
params: params,
|
53
|
-
opts: opts
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
27
|
# Initiates a payment flow on a Reader.
|
58
28
|
def process_payment_intent(params = {}, opts = {})
|
59
29
|
request_stripe_object(
|
@@ -104,36 +74,6 @@ module Stripe
|
|
104
74
|
)
|
105
75
|
end
|
106
76
|
|
107
|
-
# Initiates an input collection flow on a Reader.
|
108
|
-
def self.collect_inputs(reader, params = {}, opts = {})
|
109
|
-
request_stripe_object(
|
110
|
-
method: :post,
|
111
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_inputs", { reader: CGI.escape(reader) }),
|
112
|
-
params: params,
|
113
|
-
opts: opts
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation.
|
118
|
-
def self.collect_payment_method(reader, params = {}, opts = {})
|
119
|
-
request_stripe_object(
|
120
|
-
method: :post,
|
121
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_payment_method", { reader: CGI.escape(reader) }),
|
122
|
-
params: params,
|
123
|
-
opts: opts
|
124
|
-
)
|
125
|
-
end
|
126
|
-
|
127
|
-
# Finalizes a payment on a Reader.
|
128
|
-
def self.confirm_payment_intent(reader, params = {}, opts = {})
|
129
|
-
request_stripe_object(
|
130
|
-
method: :post,
|
131
|
-
path: format("/v1/terminal/readers/%<reader>s/confirm_payment_intent", { reader: CGI.escape(reader) }),
|
132
|
-
params: params,
|
133
|
-
opts: opts
|
134
|
-
)
|
135
|
-
end
|
136
|
-
|
137
77
|
# Initiates a payment flow on a Reader.
|
138
78
|
def self.process_payment_intent(reader, params = {}, opts = {})
|
139
79
|
request_stripe_object(
|
data/lib/stripe/resources.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require "stripe/resources/account"
|
5
5
|
require "stripe/resources/account_link"
|
6
|
-
require "stripe/resources/account_notice"
|
7
6
|
require "stripe/resources/account_session"
|
8
7
|
require "stripe/resources/apple_pay_domain"
|
9
8
|
require "stripe/resources/application_fee"
|
@@ -15,9 +14,6 @@ require "stripe/resources/bank_account"
|
|
15
14
|
require "stripe/resources/billing_portal/configuration"
|
16
15
|
require "stripe/resources/billing_portal/session"
|
17
16
|
require "stripe/resources/capability"
|
18
|
-
require "stripe/resources/capital/financing_offer"
|
19
|
-
require "stripe/resources/capital/financing_summary"
|
20
|
-
require "stripe/resources/capital/financing_transaction"
|
21
17
|
require "stripe/resources/card"
|
22
18
|
require "stripe/resources/cash_balance"
|
23
19
|
require "stripe/resources/charge"
|
@@ -25,7 +21,6 @@ require "stripe/resources/checkout/session"
|
|
25
21
|
require "stripe/resources/climate/order"
|
26
22
|
require "stripe/resources/climate/product"
|
27
23
|
require "stripe/resources/climate/supplier"
|
28
|
-
require "stripe/resources/confirmation_token"
|
29
24
|
require "stripe/resources/country_spec"
|
30
25
|
require "stripe/resources/coupon"
|
31
26
|
require "stripe/resources/credit_note"
|
@@ -42,34 +37,25 @@ require "stripe/resources/exchange_rate"
|
|
42
37
|
require "stripe/resources/file"
|
43
38
|
require "stripe/resources/file_link"
|
44
39
|
require "stripe/resources/financial_connections/account"
|
45
|
-
require "stripe/resources/financial_connections/account_inferred_balance"
|
46
40
|
require "stripe/resources/financial_connections/account_owner"
|
47
41
|
require "stripe/resources/financial_connections/account_ownership"
|
48
42
|
require "stripe/resources/financial_connections/session"
|
49
43
|
require "stripe/resources/financial_connections/transaction"
|
50
44
|
require "stripe/resources/funding_instructions"
|
51
|
-
require "stripe/resources/gift_cards/card"
|
52
|
-
require "stripe/resources/gift_cards/transaction"
|
53
45
|
require "stripe/resources/identity/verification_report"
|
54
46
|
require "stripe/resources/identity/verification_session"
|
55
47
|
require "stripe/resources/invoice"
|
56
48
|
require "stripe/resources/invoice_item"
|
57
49
|
require "stripe/resources/invoice_line_item"
|
58
|
-
require "stripe/resources/invoice_payment"
|
59
50
|
require "stripe/resources/issuing/authorization"
|
60
51
|
require "stripe/resources/issuing/card"
|
61
52
|
require "stripe/resources/issuing/cardholder"
|
62
|
-
require "stripe/resources/issuing/credit_underwriting_record"
|
63
53
|
require "stripe/resources/issuing/dispute"
|
64
|
-
require "stripe/resources/issuing/personalization_design"
|
65
|
-
require "stripe/resources/issuing/physical_bundle"
|
66
54
|
require "stripe/resources/issuing/token"
|
67
55
|
require "stripe/resources/issuing/transaction"
|
68
56
|
require "stripe/resources/line_item"
|
69
57
|
require "stripe/resources/login_link"
|
70
58
|
require "stripe/resources/mandate"
|
71
|
-
require "stripe/resources/margin"
|
72
|
-
require "stripe/resources/order"
|
73
59
|
require "stripe/resources/payment_intent"
|
74
60
|
require "stripe/resources/payment_link"
|
75
61
|
require "stripe/resources/payment_method"
|
@@ -82,9 +68,6 @@ require "stripe/resources/price"
|
|
82
68
|
require "stripe/resources/product"
|
83
69
|
require "stripe/resources/promotion_code"
|
84
70
|
require "stripe/resources/quote"
|
85
|
-
require "stripe/resources/quote_phase"
|
86
|
-
require "stripe/resources/quote_preview_invoice"
|
87
|
-
require "stripe/resources/quote_preview_subscription_schedule"
|
88
71
|
require "stripe/resources/radar/early_fraud_warning"
|
89
72
|
require "stripe/resources/radar/value_list"
|
90
73
|
require "stripe/resources/radar/value_list_item"
|
@@ -104,7 +87,6 @@ require "stripe/resources/subscription_item"
|
|
104
87
|
require "stripe/resources/subscription_schedule"
|
105
88
|
require "stripe/resources/tax/calculation"
|
106
89
|
require "stripe/resources/tax/calculation_line_item"
|
107
|
-
require "stripe/resources/tax/form"
|
108
90
|
require "stripe/resources/tax/registration"
|
109
91
|
require "stripe/resources/tax/settings"
|
110
92
|
require "stripe/resources/tax/transaction"
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -209,10 +209,9 @@ module Stripe
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def execute_request(method, path,
|
212
|
-
api_base: nil, api_key: nil,
|
213
|
-
headers: {}, params: {}, api_mode: nil, usage: [])
|
212
|
+
api_base: nil, api_key: nil, headers: {}, params: {}, usage: [])
|
214
213
|
http_resp, api_key = execute_request_internal(
|
215
|
-
method, path, api_base, api_key, headers, params,
|
214
|
+
method, path, api_base, api_key, headers, params, usage
|
216
215
|
)
|
217
216
|
|
218
217
|
begin
|
@@ -243,7 +242,6 @@ module Stripe
|
|
243
242
|
def execute_request_stream(method, path,
|
244
243
|
api_base: nil, api_key: nil, usage: [],
|
245
244
|
headers: {}, params: {},
|
246
|
-
api_mode: nil,
|
247
245
|
&read_body_chunk_block)
|
248
246
|
unless block_given?
|
249
247
|
raise ArgumentError,
|
@@ -251,8 +249,7 @@ module Stripe
|
|
251
249
|
end
|
252
250
|
|
253
251
|
http_resp, api_key = execute_request_internal(
|
254
|
-
method, path, api_base, api_key,
|
255
|
-
headers, params, api_mode, usage, &read_body_chunk_block
|
252
|
+
method, path, api_base, api_key, headers, params, usage, &read_body_chunk_block
|
256
253
|
)
|
257
254
|
|
258
255
|
# When the read_body_chunk_block is given, we no longer have access to the
|
@@ -431,8 +428,8 @@ module Stripe
|
|
431
428
|
end
|
432
429
|
|
433
430
|
private def execute_request_internal(method, path,
|
434
|
-
api_base, api_key, headers, params,
|
435
|
-
|
431
|
+
api_base, api_key, headers, params, usage,
|
432
|
+
&read_body_chunk_block)
|
436
433
|
raise ArgumentError, "method should be a symbol" \
|
437
434
|
unless method.is_a?(Symbol)
|
438
435
|
raise ArgumentError, "path should be a string" \
|
@@ -440,10 +437,9 @@ module Stripe
|
|
440
437
|
|
441
438
|
api_base ||= config.api_base
|
442
439
|
api_key ||= config.api_key
|
443
|
-
authenticator ||= config.authenticator
|
444
440
|
params = Util.objects_to_ids(params)
|
445
441
|
|
446
|
-
|
442
|
+
check_api_key!(api_key)
|
447
443
|
|
448
444
|
body_params = nil
|
449
445
|
query_params = nil
|
@@ -456,9 +452,8 @@ module Stripe
|
|
456
452
|
|
457
453
|
query_params, path = merge_query_params(query_params, path)
|
458
454
|
|
459
|
-
headers = request_headers(api_key, method
|
455
|
+
headers = request_headers(api_key, method)
|
460
456
|
.update(Util.normalize_headers(headers))
|
461
|
-
|
462
457
|
url = api_url(path, api_base)
|
463
458
|
|
464
459
|
# Merge given query parameters with any already encoded in the path.
|
@@ -469,16 +464,13 @@ module Stripe
|
|
469
464
|
# a log-friendly variant of the encoded form. File objects are displayed
|
470
465
|
# as such instead of as their file contents.
|
471
466
|
body, body_log =
|
472
|
-
body_params ? encode_body(body_params, headers
|
473
|
-
|
474
|
-
authenticator.authenticate(method, headers, body) unless api_key
|
467
|
+
body_params ? encode_body(body_params, headers) : [nil, nil]
|
475
468
|
|
476
469
|
# stores information on the request we're about to make so that we don't
|
477
470
|
# have to pass as many parameters around for logging.
|
478
471
|
context = RequestLogContext.new
|
479
472
|
context.account = headers["Stripe-Account"]
|
480
473
|
context.api_key = api_key
|
481
|
-
context.authenticator = authenticator
|
482
474
|
context.api_version = headers["Stripe-Version"]
|
483
475
|
context.body = body_log
|
484
476
|
context.idempotency_key = headers["Idempotency-Key"]
|
@@ -515,16 +507,8 @@ module Stripe
|
|
515
507
|
(api_base || config.api_base) + url
|
516
508
|
end
|
517
509
|
|
518
|
-
private def
|
519
|
-
|
520
|
-
raise AuthenticationError, "Can't specify both API key " \
|
521
|
-
"and authenticator. Either set your API key" \
|
522
|
-
'using "Stripe.api_key = <API-KEY>", or set your authenticator ' \
|
523
|
-
'using "Stripe.authenticator = <AUTHENTICATOR>"' \
|
524
|
-
end
|
525
|
-
|
526
|
-
unless api_key || authenticator
|
527
|
-
# Default to missing API key error message for general users.
|
510
|
+
private def check_api_key!(api_key)
|
511
|
+
unless api_key
|
528
512
|
raise AuthenticationError, "No API key provided. " \
|
529
513
|
'Set your API key using "Stripe.api_key = <API-KEY>". ' \
|
530
514
|
"You can generate API keys from the Stripe web interface. " \
|
@@ -543,7 +527,7 @@ module Stripe
|
|
543
527
|
# Encodes a set of body parameters using multipart if `Content-Type` is set
|
544
528
|
# for that, or standard form-encoding otherwise. Returns the encoded body
|
545
529
|
# and a version of the encoded body that's safe to be logged.
|
546
|
-
private def encode_body(body_params, headers
|
530
|
+
private def encode_body(body_params, headers)
|
547
531
|
body = nil
|
548
532
|
flattened_params = Util.flatten_params(body_params)
|
549
533
|
|
@@ -559,22 +543,15 @@ module Stripe
|
|
559
543
|
flattened_params =
|
560
544
|
flattened_params.map { |k, v| [k, v.is_a?(String) ? v : v.to_s] }.to_h
|
561
545
|
|
562
|
-
elsif api_mode == :preview
|
563
|
-
body = JSON.generate(body_params)
|
564
|
-
headers["Content-Type"] = "application/json"
|
565
546
|
else
|
566
547
|
body = Util.encode_parameters(body_params)
|
567
548
|
end
|
568
549
|
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
# forms of certain characters introduce a lot of visual noise and it's
|
575
|
-
# nice to have a clearer format for logs.
|
576
|
-
flattened_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
577
|
-
end
|
550
|
+
# We don't use `Util.encode_parameters` partly as an optimization (to not
|
551
|
+
# redo work we've already done), and partly because the encoded forms of
|
552
|
+
# certain characters introduce a lot of visual noise and it's nice to
|
553
|
+
# have a clearer format for logs.
|
554
|
+
body_log = flattened_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
578
555
|
|
579
556
|
[body, body_log]
|
580
557
|
end
|
@@ -761,11 +738,10 @@ module Stripe
|
|
761
738
|
end
|
762
739
|
|
763
740
|
private def specific_api_error(resp, error_data, context)
|
764
|
-
message = error_data[:message]
|
765
741
|
Util.log_error("Stripe API error",
|
766
742
|
status: resp.http_status,
|
767
743
|
error_code: error_data[:code],
|
768
|
-
error_message: message,
|
744
|
+
error_message: error_data[:message],
|
769
745
|
error_param: error_data[:param],
|
770
746
|
error_type: error_data[:type],
|
771
747
|
idempotency_key: context.idempotency_key,
|
@@ -786,26 +762,26 @@ module Stripe
|
|
786
762
|
when 400, 404
|
787
763
|
case error_data[:type]
|
788
764
|
when "idempotency_error"
|
789
|
-
IdempotencyError.new(message, **opts)
|
765
|
+
IdempotencyError.new(error_data[:message], **opts)
|
790
766
|
else
|
791
767
|
InvalidRequestError.new(
|
792
|
-
message, error_data[:param],
|
768
|
+
error_data[:message], error_data[:param],
|
793
769
|
**opts
|
794
770
|
)
|
795
771
|
end
|
796
772
|
when 401
|
797
|
-
AuthenticationError.new(message, **opts)
|
773
|
+
AuthenticationError.new(error_data[:message], **opts)
|
798
774
|
when 402
|
799
775
|
CardError.new(
|
800
|
-
message, error_data[:param],
|
776
|
+
error_data[:message], error_data[:param],
|
801
777
|
**opts
|
802
778
|
)
|
803
779
|
when 403
|
804
|
-
PermissionError.new(message, **opts)
|
780
|
+
PermissionError.new(error_data[:message], **opts)
|
805
781
|
when 429
|
806
|
-
RateLimitError.new(message, **opts)
|
782
|
+
RateLimitError.new(error_data[:message], **opts)
|
807
783
|
else
|
808
|
-
APIError.new(message, **opts)
|
784
|
+
APIError.new(error_data[:message], **opts)
|
809
785
|
end
|
810
786
|
end
|
811
787
|
|
@@ -873,20 +849,16 @@ module Stripe
|
|
873
849
|
message + "\n\n(Network error: #{error.message})"
|
874
850
|
end
|
875
851
|
|
876
|
-
private def request_headers(api_key, method
|
852
|
+
private def request_headers(api_key, method)
|
877
853
|
user_agent = "Stripe/v1 RubyBindings/#{Stripe::VERSION}"
|
878
854
|
user_agent += " " + format_app_info(Stripe.app_info) unless Stripe.app_info.nil?
|
879
855
|
|
880
856
|
headers = {
|
881
857
|
"User-Agent" => user_agent,
|
882
858
|
"Authorization" => "Bearer #{api_key}",
|
859
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
883
860
|
}
|
884
861
|
|
885
|
-
if api_mode != :preview
|
886
|
-
# TODO: (major) don't set Content-Type if method is not post
|
887
|
-
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
888
|
-
end
|
889
|
-
|
890
862
|
if config.enable_telemetry? && !@last_request_metrics.nil?
|
891
863
|
headers["X-Stripe-Client-Telemetry"] = JSON.generate(
|
892
864
|
last_request_metrics: @last_request_metrics.payload
|
@@ -899,12 +871,7 @@ module Stripe
|
|
899
871
|
headers["Idempotency-Key"] ||= SecureRandom.uuid
|
900
872
|
end
|
901
873
|
|
902
|
-
|
903
|
-
headers["Stripe-Version"] = ApiVersion::PREVIEW
|
904
|
-
elsif config.api_version
|
905
|
-
headers["Stripe-Version"] = config.api_version
|
906
|
-
end
|
907
|
-
|
874
|
+
headers["Stripe-Version"] = config.api_version if config.api_version
|
908
875
|
headers["Stripe-Account"] = config.stripe_account if config.stripe_account
|
909
876
|
|
910
877
|
user_agent = @system_profiler.user_agent
|
@@ -987,8 +954,7 @@ module Stripe
|
|
987
954
|
# that we can log certain information. It's useful because it means that we
|
988
955
|
# don't have to pass around as many parameters.
|
989
956
|
class RequestLogContext
|
990
|
-
attr_accessor :body, :account, :api_key, :
|
991
|
-
:request_id
|
957
|
+
attr_accessor :body, :account, :api_key, :api_version, :idempotency_key, :method, :path, :query, :request_id
|
992
958
|
|
993
959
|
# The idea with this method is that we might want to update some of
|
994
960
|
# context information because a response that we've received from the API
|