stripe 9.5.0.pre.beta.1 → 10.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 +51 -220
- data/OPENAPI_VERSION +1 -1
- data/README.md +0 -11
- data/VERSION +1 -1
- data/lib/stripe/api_operations/request.rb +0 -2
- data/lib/stripe/api_version.rb +1 -2
- data/lib/stripe/object_types.rb +0 -18
- data/lib/stripe/resources/financial_connections/account.rb +0 -39
- data/lib/stripe/resources/issuing/token.rb +1 -1
- data/lib/stripe/resources/payment_method_configuration.rb +1 -1
- data/lib/stripe/resources/quote.rb +0 -94
- data/lib/stripe/resources/subscription_schedule.rb +0 -18
- data/lib/stripe/resources/terminal/reader.rb +0 -54
- data/lib/stripe/resources.rb +0 -17
- data/lib/stripe/stripe_client.rb +26 -60
- data/lib/stripe/stripe_configuration.rb +0 -2
- data/lib/stripe/util.rb +1 -8
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +0 -46
- metadata +4 -22
- data/lib/stripe/request_signing_authenticator.rb +0 -83
- data/lib/stripe/resources/capital/financing_offer.rb +0 -32
- 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 -11
- data/lib/stripe/resources/customer_session.rb +0 -12
- data/lib/stripe/resources/financial_connections/account_inferred_balance.rb +0 -13
- data/lib/stripe/resources/financial_connections/transaction.rb +0 -13
- data/lib/stripe/resources/gift_cards/card.rb +0 -25
- data/lib/stripe/resources/gift_cards/transaction.rb +0 -56
- data/lib/stripe/resources/issuing/personalization_design.rb +0 -77
- data/lib/stripe/resources/issuing/physical_bundle.rb +0 -13
- data/lib/stripe/resources/order.rb +0 -89
- data/lib/stripe/resources/quote_phase.rb +0 -29
- 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 -39
- data/lib/stripe/resources/tax/registration.rb +0 -19
@@ -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
|
def accept(params = {}, opts = {})
|
19
15
|
request_stripe_object(
|
20
16
|
method: :post,
|
@@ -60,42 +56,6 @@ module Stripe
|
|
60
56
|
)
|
61
57
|
end
|
62
58
|
|
63
|
-
def list_lines(params = {}, opts = {})
|
64
|
-
request_stripe_object(
|
65
|
-
method: :get,
|
66
|
-
path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(self["id"]) }),
|
67
|
-
params: params,
|
68
|
-
opts: opts
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
|
-
def list_preview_invoice_lines(preview_invoice, params = {}, opts = {})
|
73
|
-
request_stripe_object(
|
74
|
-
method: :get,
|
75
|
-
path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(self["id"]), preview_invoice: CGI.escape(preview_invoice) }),
|
76
|
-
params: params,
|
77
|
-
opts: opts
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
|
-
def mark_draft(params = {}, opts = {})
|
82
|
-
request_stripe_object(
|
83
|
-
method: :post,
|
84
|
-
path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(self["id"]) }),
|
85
|
-
params: params,
|
86
|
-
opts: opts
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
def mark_stale(params = {}, opts = {})
|
91
|
-
request_stripe_object(
|
92
|
-
method: :post,
|
93
|
-
path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(self["id"]) }),
|
94
|
-
params: params,
|
95
|
-
opts: opts
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
59
|
def pdf(params = {}, opts = {}, &read_body_chunk_block)
|
100
60
|
config = opts[:client]&.config || Stripe.config
|
101
61
|
opts = { api_base: config.uploads_base }.merge(opts)
|
@@ -108,15 +68,6 @@ module Stripe
|
|
108
68
|
)
|
109
69
|
end
|
110
70
|
|
111
|
-
def reestimate(params = {}, opts = {})
|
112
|
-
request_stripe_object(
|
113
|
-
method: :post,
|
114
|
-
path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(self["id"]) }),
|
115
|
-
params: params,
|
116
|
-
opts: opts
|
117
|
-
)
|
118
|
-
end
|
119
|
-
|
120
71
|
def self.accept(quote, params = {}, opts = {})
|
121
72
|
request_stripe_object(
|
122
73
|
method: :post,
|
@@ -162,42 +113,6 @@ module Stripe
|
|
162
113
|
)
|
163
114
|
end
|
164
115
|
|
165
|
-
def self.list_lines(quote, params = {}, opts = {})
|
166
|
-
request_stripe_object(
|
167
|
-
method: :get,
|
168
|
-
path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(quote) }),
|
169
|
-
params: params,
|
170
|
-
opts: opts
|
171
|
-
)
|
172
|
-
end
|
173
|
-
|
174
|
-
def self.list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {})
|
175
|
-
request_stripe_object(
|
176
|
-
method: :get,
|
177
|
-
path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(quote), preview_invoice: CGI.escape(preview_invoice) }),
|
178
|
-
params: params,
|
179
|
-
opts: opts
|
180
|
-
)
|
181
|
-
end
|
182
|
-
|
183
|
-
def self.mark_draft(quote, params = {}, opts = {})
|
184
|
-
request_stripe_object(
|
185
|
-
method: :post,
|
186
|
-
path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(quote) }),
|
187
|
-
params: params,
|
188
|
-
opts: opts
|
189
|
-
)
|
190
|
-
end
|
191
|
-
|
192
|
-
def self.mark_stale(quote, params = {}, opts = {})
|
193
|
-
request_stripe_object(
|
194
|
-
method: :post,
|
195
|
-
path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(quote) }),
|
196
|
-
params: params,
|
197
|
-
opts: opts
|
198
|
-
)
|
199
|
-
end
|
200
|
-
|
201
116
|
def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
|
202
117
|
config = opts[:client]&.config || Stripe.config
|
203
118
|
opts = { api_base: config.uploads_base }.merge(opts)
|
@@ -209,14 +124,5 @@ module Stripe
|
|
209
124
|
&read_body_chunk_block
|
210
125
|
)
|
211
126
|
end
|
212
|
-
|
213
|
-
def self.reestimate(quote, params = {}, opts = {})
|
214
|
-
request_stripe_object(
|
215
|
-
method: :post,
|
216
|
-
path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(quote) }),
|
217
|
-
params: params,
|
218
|
-
opts: opts
|
219
|
-
)
|
220
|
-
end
|
221
127
|
end
|
222
128
|
end
|
@@ -12,15 +12,6 @@ module Stripe
|
|
12
12
|
|
13
13
|
OBJECT_NAME = "subscription_schedule"
|
14
14
|
|
15
|
-
def amend(params = {}, opts = {})
|
16
|
-
request_stripe_object(
|
17
|
-
method: :post,
|
18
|
-
path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(self["id"]) }),
|
19
|
-
params: params,
|
20
|
-
opts: opts
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
15
|
def cancel(params = {}, opts = {})
|
25
16
|
request_stripe_object(
|
26
17
|
method: :post,
|
@@ -39,15 +30,6 @@ module Stripe
|
|
39
30
|
)
|
40
31
|
end
|
41
32
|
|
42
|
-
def self.amend(schedule, params = {}, opts = {})
|
43
|
-
request_stripe_object(
|
44
|
-
method: :post,
|
45
|
-
path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(schedule) }),
|
46
|
-
params: params,
|
47
|
-
opts: opts
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
33
|
def self.cancel(schedule, params = {}, opts = {})
|
52
34
|
request_stripe_object(
|
53
35
|
method: :post,
|
@@ -23,33 +23,6 @@ module Stripe
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
def collect_inputs(params = {}, opts = {})
|
27
|
-
request_stripe_object(
|
28
|
-
method: :post,
|
29
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_inputs", { reader: CGI.escape(self["id"]) }),
|
30
|
-
params: params,
|
31
|
-
opts: opts
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
def collect_payment_method(params = {}, opts = {})
|
36
|
-
request_stripe_object(
|
37
|
-
method: :post,
|
38
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_payment_method", { reader: CGI.escape(self["id"]) }),
|
39
|
-
params: params,
|
40
|
-
opts: opts
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
def confirm_payment_intent(params = {}, opts = {})
|
45
|
-
request_stripe_object(
|
46
|
-
method: :post,
|
47
|
-
path: format("/v1/terminal/readers/%<reader>s/confirm_payment_intent", { reader: CGI.escape(self["id"]) }),
|
48
|
-
params: params,
|
49
|
-
opts: opts
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
26
|
def process_payment_intent(params = {}, opts = {})
|
54
27
|
request_stripe_object(
|
55
28
|
method: :post,
|
@@ -95,33 +68,6 @@ module Stripe
|
|
95
68
|
)
|
96
69
|
end
|
97
70
|
|
98
|
-
def self.collect_inputs(reader, params = {}, opts = {})
|
99
|
-
request_stripe_object(
|
100
|
-
method: :post,
|
101
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_inputs", { reader: CGI.escape(reader) }),
|
102
|
-
params: params,
|
103
|
-
opts: opts
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.collect_payment_method(reader, params = {}, opts = {})
|
108
|
-
request_stripe_object(
|
109
|
-
method: :post,
|
110
|
-
path: format("/v1/terminal/readers/%<reader>s/collect_payment_method", { reader: CGI.escape(reader) }),
|
111
|
-
params: params,
|
112
|
-
opts: opts
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
|
-
def self.confirm_payment_intent(reader, params = {}, opts = {})
|
117
|
-
request_stripe_object(
|
118
|
-
method: :post,
|
119
|
-
path: format("/v1/terminal/readers/%<reader>s/confirm_payment_intent", { reader: CGI.escape(reader) }),
|
120
|
-
params: params,
|
121
|
-
opts: opts
|
122
|
-
)
|
123
|
-
end
|
124
|
-
|
125
71
|
def self.process_payment_intent(reader, params = {}, opts = {})
|
126
72
|
request_stripe_object(
|
127
73
|
method: :post,
|
data/lib/stripe/resources.rb
CHANGED
@@ -14,14 +14,10 @@ require "stripe/resources/bank_account"
|
|
14
14
|
require "stripe/resources/billing_portal/configuration"
|
15
15
|
require "stripe/resources/billing_portal/session"
|
16
16
|
require "stripe/resources/capability"
|
17
|
-
require "stripe/resources/capital/financing_offer"
|
18
|
-
require "stripe/resources/capital/financing_summary"
|
19
|
-
require "stripe/resources/capital/financing_transaction"
|
20
17
|
require "stripe/resources/card"
|
21
18
|
require "stripe/resources/cash_balance"
|
22
19
|
require "stripe/resources/charge"
|
23
20
|
require "stripe/resources/checkout/session"
|
24
|
-
require "stripe/resources/confirmation_token"
|
25
21
|
require "stripe/resources/country_spec"
|
26
22
|
require "stripe/resources/coupon"
|
27
23
|
require "stripe/resources/credit_note"
|
@@ -29,7 +25,6 @@ require "stripe/resources/credit_note_line_item"
|
|
29
25
|
require "stripe/resources/customer"
|
30
26
|
require "stripe/resources/customer_balance_transaction"
|
31
27
|
require "stripe/resources/customer_cash_balance_transaction"
|
32
|
-
require "stripe/resources/customer_session"
|
33
28
|
require "stripe/resources/discount"
|
34
29
|
require "stripe/resources/dispute"
|
35
30
|
require "stripe/resources/ephemeral_key"
|
@@ -38,14 +33,10 @@ require "stripe/resources/exchange_rate"
|
|
38
33
|
require "stripe/resources/file"
|
39
34
|
require "stripe/resources/file_link"
|
40
35
|
require "stripe/resources/financial_connections/account"
|
41
|
-
require "stripe/resources/financial_connections/account_inferred_balance"
|
42
36
|
require "stripe/resources/financial_connections/account_owner"
|
43
37
|
require "stripe/resources/financial_connections/account_ownership"
|
44
38
|
require "stripe/resources/financial_connections/session"
|
45
|
-
require "stripe/resources/financial_connections/transaction"
|
46
39
|
require "stripe/resources/funding_instructions"
|
47
|
-
require "stripe/resources/gift_cards/card"
|
48
|
-
require "stripe/resources/gift_cards/transaction"
|
49
40
|
require "stripe/resources/identity/verification_report"
|
50
41
|
require "stripe/resources/identity/verification_session"
|
51
42
|
require "stripe/resources/invoice"
|
@@ -55,14 +46,11 @@ require "stripe/resources/issuing/authorization"
|
|
55
46
|
require "stripe/resources/issuing/card"
|
56
47
|
require "stripe/resources/issuing/cardholder"
|
57
48
|
require "stripe/resources/issuing/dispute"
|
58
|
-
require "stripe/resources/issuing/personalization_design"
|
59
|
-
require "stripe/resources/issuing/physical_bundle"
|
60
49
|
require "stripe/resources/issuing/token"
|
61
50
|
require "stripe/resources/issuing/transaction"
|
62
51
|
require "stripe/resources/line_item"
|
63
52
|
require "stripe/resources/login_link"
|
64
53
|
require "stripe/resources/mandate"
|
65
|
-
require "stripe/resources/order"
|
66
54
|
require "stripe/resources/payment_intent"
|
67
55
|
require "stripe/resources/payment_link"
|
68
56
|
require "stripe/resources/payment_method"
|
@@ -75,9 +63,6 @@ require "stripe/resources/price"
|
|
75
63
|
require "stripe/resources/product"
|
76
64
|
require "stripe/resources/promotion_code"
|
77
65
|
require "stripe/resources/quote"
|
78
|
-
require "stripe/resources/quote_phase"
|
79
|
-
require "stripe/resources/quote_preview_invoice"
|
80
|
-
require "stripe/resources/quote_preview_subscription_schedule"
|
81
66
|
require "stripe/resources/radar/early_fraud_warning"
|
82
67
|
require "stripe/resources/radar/value_list"
|
83
68
|
require "stripe/resources/radar/value_list_item"
|
@@ -97,8 +82,6 @@ require "stripe/resources/subscription_item"
|
|
97
82
|
require "stripe/resources/subscription_schedule"
|
98
83
|
require "stripe/resources/tax/calculation"
|
99
84
|
require "stripe/resources/tax/calculation_line_item"
|
100
|
-
require "stripe/resources/tax/form"
|
101
|
-
require "stripe/resources/tax/registration"
|
102
85
|
require "stripe/resources/tax/settings"
|
103
86
|
require "stripe/resources/tax/transaction"
|
104
87
|
require "stripe/resources/tax/transaction_line_item"
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -212,10 +212,9 @@ module Stripe
|
|
212
212
|
end
|
213
213
|
|
214
214
|
def execute_request(method, path,
|
215
|
-
api_base: nil, api_key: nil,
|
216
|
-
headers: {}, params: {}, api_mode: nil)
|
215
|
+
api_base: nil, api_key: nil, headers: {}, params: {})
|
217
216
|
http_resp, api_key = execute_request_internal(
|
218
|
-
method, path, api_base, api_key, headers, params
|
217
|
+
method, path, api_base, api_key, headers, params
|
219
218
|
)
|
220
219
|
|
221
220
|
begin
|
@@ -246,7 +245,6 @@ module Stripe
|
|
246
245
|
def execute_request_stream(method, path,
|
247
246
|
api_base: nil, api_key: nil,
|
248
247
|
headers: {}, params: {},
|
249
|
-
api_mode: nil,
|
250
248
|
&read_body_chunk_block)
|
251
249
|
unless block_given?
|
252
250
|
raise ArgumentError,
|
@@ -254,8 +252,7 @@ module Stripe
|
|
254
252
|
end
|
255
253
|
|
256
254
|
http_resp, api_key = execute_request_internal(
|
257
|
-
method, path, api_base, api_key,
|
258
|
-
headers, params, api_mode, &read_body_chunk_block
|
255
|
+
method, path, api_base, api_key, headers, params, &read_body_chunk_block
|
259
256
|
)
|
260
257
|
|
261
258
|
# When the read_body_chunk_block is given, we no longer have access to the
|
@@ -435,7 +432,7 @@ module Stripe
|
|
435
432
|
|
436
433
|
private def execute_request_internal(method, path,
|
437
434
|
api_base, api_key, headers, params,
|
438
|
-
|
435
|
+
&read_body_chunk_block)
|
439
436
|
raise ArgumentError, "method should be a symbol" \
|
440
437
|
unless method.is_a?(Symbol)
|
441
438
|
raise ArgumentError, "path should be a string" \
|
@@ -443,10 +440,9 @@ module Stripe
|
|
443
440
|
|
444
441
|
api_base ||= config.api_base
|
445
442
|
api_key ||= config.api_key
|
446
|
-
authenticator ||= config.authenticator
|
447
443
|
params = Util.objects_to_ids(params)
|
448
444
|
|
449
|
-
|
445
|
+
check_api_key!(api_key)
|
450
446
|
|
451
447
|
body_params = nil
|
452
448
|
query_params = nil
|
@@ -459,9 +455,8 @@ module Stripe
|
|
459
455
|
|
460
456
|
query_params, path = merge_query_params(query_params, path)
|
461
457
|
|
462
|
-
headers = request_headers(api_key, method
|
458
|
+
headers = request_headers(api_key, method)
|
463
459
|
.update(Util.normalize_headers(headers))
|
464
|
-
|
465
460
|
url = api_url(path, api_base)
|
466
461
|
|
467
462
|
# Merge given query parameters with any already encoded in the path.
|
@@ -472,16 +467,13 @@ module Stripe
|
|
472
467
|
# a log-friendly variant of the encoded form. File objects are displayed
|
473
468
|
# as such instead of as their file contents.
|
474
469
|
body, body_log =
|
475
|
-
body_params ? encode_body(body_params, headers
|
476
|
-
|
477
|
-
authenticator.authenticate(method, headers, body) unless api_key
|
470
|
+
body_params ? encode_body(body_params, headers) : [nil, nil]
|
478
471
|
|
479
472
|
# stores information on the request we're about to make so that we don't
|
480
473
|
# have to pass as many parameters around for logging.
|
481
474
|
context = RequestLogContext.new
|
482
475
|
context.account = headers["Stripe-Account"]
|
483
476
|
context.api_key = api_key
|
484
|
-
context.authenticator = authenticator
|
485
477
|
context.api_version = headers["Stripe-Version"]
|
486
478
|
context.body = body_log
|
487
479
|
context.idempotency_key = headers["Idempotency-Key"]
|
@@ -520,16 +512,8 @@ module Stripe
|
|
520
512
|
(api_base || config.api_base) + url
|
521
513
|
end
|
522
514
|
|
523
|
-
private def
|
524
|
-
|
525
|
-
raise AuthenticationError, "Can't specify both API key " \
|
526
|
-
"and authenticator. Either set your API key" \
|
527
|
-
'using "Stripe.api_key = <API-KEY>", or set your authenticator ' \
|
528
|
-
'using "Stripe.authenticator = <AUTHENTICATOR>"' \
|
529
|
-
end
|
530
|
-
|
531
|
-
unless api_key || authenticator
|
532
|
-
# Default to missing API key error message for general users.
|
515
|
+
private def check_api_key!(api_key)
|
516
|
+
unless api_key
|
533
517
|
raise AuthenticationError, "No API key provided. " \
|
534
518
|
'Set your API key using "Stripe.api_key = <API-KEY>". ' \
|
535
519
|
"You can generate API keys from the Stripe web interface. " \
|
@@ -548,7 +532,7 @@ module Stripe
|
|
548
532
|
# Encodes a set of body parameters using multipart if `Content-Type` is set
|
549
533
|
# for that, or standard form-encoding otherwise. Returns the encoded body
|
550
534
|
# and a version of the encoded body that's safe to be logged.
|
551
|
-
private def encode_body(body_params, headers
|
535
|
+
private def encode_body(body_params, headers)
|
552
536
|
body = nil
|
553
537
|
flattened_params = Util.flatten_params(body_params)
|
554
538
|
|
@@ -564,22 +548,15 @@ module Stripe
|
|
564
548
|
flattened_params =
|
565
549
|
flattened_params.map { |k, v| [k, v.is_a?(String) ? v : v.to_s] }.to_h
|
566
550
|
|
567
|
-
elsif api_mode == :preview
|
568
|
-
body = JSON.generate(body_params)
|
569
|
-
headers["Content-Type"] = "application/json"
|
570
551
|
else
|
571
552
|
body = Util.encode_parameters(body_params)
|
572
553
|
end
|
573
554
|
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
# forms of certain characters introduce a lot of visual noise and it's
|
580
|
-
# nice to have a clearer format for logs.
|
581
|
-
body_log = flattened_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
582
|
-
end
|
555
|
+
# We don't use `Util.encode_parameters` partly as an optimization (to not
|
556
|
+
# redo work we've already done), and partly because the encoded forms of
|
557
|
+
# certain characters introduce a lot of visual noise and it's nice to
|
558
|
+
# have a clearer format for logs.
|
559
|
+
body_log = flattened_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
583
560
|
|
584
561
|
[body, body_log]
|
585
562
|
end
|
@@ -768,11 +745,10 @@ module Stripe
|
|
768
745
|
end
|
769
746
|
|
770
747
|
private def specific_api_error(resp, error_data, context)
|
771
|
-
message = error_data[:message]
|
772
748
|
Util.log_error("Stripe API error",
|
773
749
|
status: resp.http_status,
|
774
750
|
error_code: error_data[:code],
|
775
|
-
error_message: message,
|
751
|
+
error_message: error_data[:message],
|
776
752
|
error_param: error_data[:param],
|
777
753
|
error_type: error_data[:type],
|
778
754
|
idempotency_key: context.idempotency_key,
|
@@ -793,26 +769,26 @@ module Stripe
|
|
793
769
|
when 400, 404
|
794
770
|
case error_data[:type]
|
795
771
|
when "idempotency_error"
|
796
|
-
IdempotencyError.new(message, **opts)
|
772
|
+
IdempotencyError.new(error_data[:message], **opts)
|
797
773
|
else
|
798
774
|
InvalidRequestError.new(
|
799
|
-
message, error_data[:param],
|
775
|
+
error_data[:message], error_data[:param],
|
800
776
|
**opts
|
801
777
|
)
|
802
778
|
end
|
803
779
|
when 401
|
804
|
-
AuthenticationError.new(message, **opts)
|
780
|
+
AuthenticationError.new(error_data[:message], **opts)
|
805
781
|
when 402
|
806
782
|
CardError.new(
|
807
|
-
message, error_data[:param],
|
783
|
+
error_data[:message], error_data[:param],
|
808
784
|
**opts
|
809
785
|
)
|
810
786
|
when 403
|
811
|
-
PermissionError.new(message, **opts)
|
787
|
+
PermissionError.new(error_data[:message], **opts)
|
812
788
|
when 429
|
813
|
-
RateLimitError.new(message, **opts)
|
789
|
+
RateLimitError.new(error_data[:message], **opts)
|
814
790
|
else
|
815
|
-
APIError.new(message, **opts)
|
791
|
+
APIError.new(error_data[:message], **opts)
|
816
792
|
end
|
817
793
|
end
|
818
794
|
|
@@ -880,7 +856,7 @@ module Stripe
|
|
880
856
|
message + "\n\n(Network error: #{error.message})"
|
881
857
|
end
|
882
858
|
|
883
|
-
private def request_headers(api_key, method
|
859
|
+
private def request_headers(api_key, method)
|
884
860
|
user_agent = "Stripe/v1 RubyBindings/#{Stripe::VERSION}"
|
885
861
|
unless Stripe.app_info.nil?
|
886
862
|
user_agent += " " + format_app_info(Stripe.app_info)
|
@@ -889,13 +865,9 @@ module Stripe
|
|
889
865
|
headers = {
|
890
866
|
"User-Agent" => user_agent,
|
891
867
|
"Authorization" => "Bearer #{api_key}",
|
868
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
892
869
|
}
|
893
870
|
|
894
|
-
if api_mode != :preview
|
895
|
-
# TODO: (major) don't set Content-Type if method is not post
|
896
|
-
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
897
|
-
end
|
898
|
-
|
899
871
|
if config.enable_telemetry? && !@last_request_metrics.nil?
|
900
872
|
headers["X-Stripe-Client-Telemetry"] = JSON.generate(
|
901
873
|
last_request_metrics: @last_request_metrics.payload
|
@@ -908,12 +880,7 @@ module Stripe
|
|
908
880
|
headers["Idempotency-Key"] ||= SecureRandom.uuid
|
909
881
|
end
|
910
882
|
|
911
|
-
|
912
|
-
headers["Stripe-Version"] = ApiVersion::PREVIEW
|
913
|
-
elsif config.api_version
|
914
|
-
headers["Stripe-Version"] = config.api_version
|
915
|
-
end
|
916
|
-
|
883
|
+
headers["Stripe-Version"] = config.api_version if config.api_version
|
917
884
|
headers["Stripe-Account"] = config.stripe_account if config.stripe_account
|
918
885
|
|
919
886
|
user_agent = @system_profiler.user_agent
|
@@ -999,7 +966,6 @@ module Stripe
|
|
999
966
|
attr_accessor :body
|
1000
967
|
attr_accessor :account
|
1001
968
|
attr_accessor :api_key
|
1002
|
-
attr_accessor :authenticator
|
1003
969
|
attr_accessor :api_version
|
1004
970
|
attr_accessor :idempotency_key
|
1005
971
|
attr_accessor :method
|
@@ -27,7 +27,6 @@ module Stripe
|
|
27
27
|
class StripeConfiguration
|
28
28
|
attr_accessor :api_key
|
29
29
|
attr_accessor :api_version
|
30
|
-
attr_accessor :authenticator
|
31
30
|
attr_accessor :client_id
|
32
31
|
attr_accessor :enable_telemetry
|
33
32
|
attr_accessor :logger
|
@@ -65,7 +64,6 @@ module Stripe
|
|
65
64
|
|
66
65
|
def initialize
|
67
66
|
@api_version = ApiVersion::CURRENT
|
68
|
-
|
69
67
|
@ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
|
70
68
|
@enable_telemetry = true
|
71
69
|
@verify_ssl_certs = true
|
data/lib/stripe/util.rb
CHANGED
@@ -7,7 +7,6 @@ module Stripe
|
|
7
7
|
# Options that a user is allowed to specify.
|
8
8
|
OPTS_USER_SPECIFIED = Set[
|
9
9
|
:api_key,
|
10
|
-
:authenticator,
|
11
10
|
:idempotency_key,
|
12
11
|
:stripe_account,
|
13
12
|
:stripe_version
|
@@ -282,13 +281,7 @@ module Stripe
|
|
282
281
|
when String
|
283
282
|
{ api_key: opts }
|
284
283
|
when Hash
|
285
|
-
|
286
|
-
# no need to check the api_key per request.
|
287
|
-
if !(opts.key?(:client) &&
|
288
|
-
opts.fetch(:client).config.authenticator) &&
|
289
|
-
opts.key?(:api_key)
|
290
|
-
check_api_key!(opts.fetch(:api_key))
|
291
|
-
end
|
284
|
+
check_api_key!(opts.fetch(:api_key)) if opts.key?(:api_key)
|
292
285
|
# Explicitly use dup here instead of clone to avoid preserving freeze
|
293
286
|
# state on input params.
|
294
287
|
opts.dup
|
data/lib/stripe/version.rb
CHANGED
data/lib/stripe.rb
CHANGED
@@ -13,7 +13,6 @@ require "set"
|
|
13
13
|
require "socket"
|
14
14
|
require "uri"
|
15
15
|
require "forwardable"
|
16
|
-
require "base64"
|
17
16
|
|
18
17
|
# Version
|
19
18
|
require "stripe/api_version"
|
@@ -45,7 +44,6 @@ require "stripe/api_resource_test_helpers"
|
|
45
44
|
require "stripe/singleton_api_resource"
|
46
45
|
require "stripe/webhook"
|
47
46
|
require "stripe/stripe_configuration"
|
48
|
-
require "stripe/request_signing_authenticator"
|
49
47
|
|
50
48
|
# Named API resources
|
51
49
|
require "stripe/resources"
|
@@ -72,7 +70,6 @@ module Stripe
|
|
72
70
|
|
73
71
|
# User configurable options
|
74
72
|
def_delegators :@config, :api_key, :api_key=
|
75
|
-
def_delegators :@config, :authenticator, :authenticator=
|
76
73
|
def_delegators :@config, :api_version, :api_version=
|
77
74
|
def_delegators :@config, :stripe_account, :stripe_account=
|
78
75
|
def_delegators :@config, :api_base, :api_base=
|
@@ -119,49 +116,6 @@ module Stripe
|
|
119
116
|
version: version,
|
120
117
|
}
|
121
118
|
end
|
122
|
-
|
123
|
-
class Preview
|
124
|
-
def self._get_default_opts(opts)
|
125
|
-
{ api_mode: :preview }.merge(opts)
|
126
|
-
end
|
127
|
-
|
128
|
-
def self.get(url, opts = {})
|
129
|
-
Stripe.raw_request(:get, url, {}, _get_default_opts(opts))
|
130
|
-
end
|
131
|
-
|
132
|
-
def self.post(url, params = {}, opts = {})
|
133
|
-
Stripe.raw_request(:post, url, params, _get_default_opts(opts))
|
134
|
-
end
|
135
|
-
|
136
|
-
def self.delete(url, opts = {})
|
137
|
-
Stripe.raw_request(:delete, url, {}, _get_default_opts(opts))
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
class RawRequest
|
142
|
-
include Stripe::APIOperations::Request
|
143
|
-
|
144
|
-
def initialize
|
145
|
-
@opts = {}
|
146
|
-
end
|
147
|
-
|
148
|
-
def execute(method, url, params = {}, opts = {})
|
149
|
-
resp, = execute_resource_request(method, url, params, opts)
|
150
|
-
|
151
|
-
resp
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
# Sends a request to Stripe REST API
|
156
|
-
def self.raw_request(method, url, params = {}, opts = {})
|
157
|
-
req = RawRequest.new
|
158
|
-
req.execute(method, url, params, opts)
|
159
|
-
end
|
160
|
-
|
161
|
-
def self.deserialize(data)
|
162
|
-
data = JSON.parse(data) if data.is_a?(String)
|
163
|
-
Util.convert_to_stripe_object(data, {})
|
164
|
-
end
|
165
119
|
end
|
166
120
|
|
167
121
|
Stripe.log_level = ENV["STRIPE_LOG"] unless ENV["STRIPE_LOG"].nil?
|