stripe 20.2.0.pre.alpha.2 → 20.2.0.pre.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/stripe/event_types.rb +20 -0
- data/lib/stripe/events/v2_core_account_closed_event.rb +2 -2
- data/lib/stripe/events/v2_core_account_including_defaults_updated_event.rb +2 -2
- data/lib/stripe/events/v2_money_management_received_debit_mandate_canceled_event.rb +2 -0
- data/lib/stripe/events/v2_money_management_received_debit_mandate_created_event.rb +2 -0
- data/lib/stripe/events/v2_money_management_received_debit_mandate_expired_event.rb +2 -0
- data/lib/stripe/events/v2_money_management_received_debit_mandate_pending_cancellation_event.rb +2 -0
- data/lib/stripe/events/v2_money_management_received_debit_mandate_updated_event.rb +2 -0
- data/lib/stripe/events/v2_money_management_spending_mandate_canceled_event.rb +44 -0
- data/lib/stripe/events/v2_money_management_spending_mandate_created_event.rb +46 -0
- data/lib/stripe/events/v2_money_management_spending_mandate_expired_event.rb +44 -0
- data/lib/stripe/events/v2_money_management_spending_mandate_pending_cancellation_event.rb +44 -0
- data/lib/stripe/events/v2_money_management_spending_mandate_updated_event.rb +44 -0
- data/lib/stripe/object_types.rb +1 -0
- data/lib/stripe/params/checkout/session_create_params.rb +4 -0
- data/lib/stripe/params/customer_update_params.rb +55 -0
- data/lib/stripe/params/fx_quote_create_params.rb +2 -2
- data/lib/stripe/params/payment_attempt_record_report_authenticated_params.rb +10 -1
- data/lib/stripe/params/payment_attempt_record_report_authorized_params.rb +35 -1
- data/lib/stripe/params/payment_attempt_record_report_guaranteed_params.rb +35 -1
- data/lib/stripe/params/payment_method_configuration_create_params.rb +21 -0
- data/lib/stripe/params/payment_method_configuration_update_params.rb +21 -0
- data/lib/stripe/params/payment_record_report_payment_attempt_guaranteed_params.rb +35 -1
- data/lib/stripe/params/payment_record_report_payment_attempt_params.rb +35 -1
- data/lib/stripe/params/payment_record_report_payment_params.rb +35 -1
- data/lib/stripe/params/radar/payment_evaluation_create_params.rb +7 -1
- data/lib/stripe/params/setup_intent_confirm_params.rb +13 -1
- data/lib/stripe/params/setup_intent_create_params.rb +13 -1
- data/lib/stripe/params/setup_intent_update_params.rb +13 -1
- data/lib/stripe/params/shared_payment/issued_token_create_params.rb +19 -0
- data/lib/stripe/params/v2/money_management/outbound_payment_create_params.rb +22 -1
- data/lib/stripe/params/v2/money_management/outbound_setup_intent_create_params.rb +46 -0
- data/lib/stripe/params/v2/money_management/payout_intent_create_params.rb +22 -1
- data/lib/stripe/params/v2/money_management/payout_intent_update_params.rb +22 -1
- data/lib/stripe/params/v2/money_management/received_debit_list_params.rb +5 -2
- data/lib/stripe/params/v2/money_management/spending_mandate_cancel_params.rb +10 -0
- data/lib/stripe/params/v2/money_management/spending_mandate_list_params.rb +26 -0
- data/lib/stripe/params/v2/money_management/spending_mandate_retrieve_params.rb +10 -0
- data/lib/stripe/params.rb +6 -0
- data/lib/stripe/resources/balance_transaction.rb +1 -1
- data/lib/stripe/resources/charge.rb +23 -7
- data/lib/stripe/resources/checkout/session.rb +2 -0
- data/lib/stripe/resources/confirmation_token.rb +19 -3
- data/lib/stripe/resources/identity/verification_report.rb +34 -0
- data/lib/stripe/resources/mandate.rb +16 -0
- data/lib/stripe/resources/payment_attempt_record.rb +18 -2
- data/lib/stripe/resources/payment_intent.rb +26 -0
- data/lib/stripe/resources/payment_method.rb +19 -3
- data/lib/stripe/resources/payment_method_configuration.rb +34 -0
- data/lib/stripe/resources/payment_record.rb +18 -2
- data/lib/stripe/resources/radar/payment_evaluation.rb +4 -0
- data/lib/stripe/resources/reserve/hold.rb +2 -2
- data/lib/stripe/resources/reserve/plan.rb +1 -1
- data/lib/stripe/resources/reserve/release.rb +1 -1
- data/lib/stripe/resources/setup_attempt.rb +18 -2
- data/lib/stripe/resources/setup_intent.rb +19 -1
- data/lib/stripe/resources/shared_payment/granted_token.rb +32 -2
- data/lib/stripe/resources/shared_payment/issued_token.rb +20 -0
- data/lib/stripe/resources/terminal/reader.rb +18 -1
- data/lib/stripe/resources/v2/core/event.rb +1 -1
- data/lib/stripe/resources/v2/core/event_base.rb +36 -0
- data/lib/stripe/resources/v2/money_management/outbound_payment.rb +74 -1
- data/lib/stripe/resources/v2/money_management/payout_intent.rb +22 -1
- data/lib/stripe/resources/v2/money_management/payout_method.rb +40 -0
- data/lib/stripe/resources/v2/money_management/received_debit.rb +3 -0
- data/lib/stripe/resources/v2/money_management/spending_mandate.rb +121 -0
- data/lib/stripe/resources.rb +29 -0
- data/lib/stripe/services/checkout/session_service.rb +2 -0
- data/lib/stripe/services/reserve/hold_service.rb +2 -2
- data/lib/stripe/services/reserve/plan_service.rb +2 -2
- data/lib/stripe/services/reserve/release_service.rb +2 -2
- data/lib/stripe/services/v2/core/vault/network_token_service.rb +1 -0
- data/lib/stripe/services/v2/money_management/received_debit_mandate_service.rb +3 -0
- data/lib/stripe/services/v2/money_management/spending_mandate_service.rb +43 -0
- data/lib/stripe/services/v2/money_management_service.rb +2 -1
- data/lib/stripe/services.rb +2 -0
- data/lib/stripe/stripe_event_notification_handler.rb +20 -0
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +61 -2
- data/rbi/stripe/resources/v2/core/event_base.rbi +11 -0
- data/rbi/stripe.rbi +1464 -72
- metadata +14 -2
|
@@ -5,6 +5,7 @@ module Stripe
|
|
|
5
5
|
module V2
|
|
6
6
|
module MoneyManagement
|
|
7
7
|
class ReceivedDebitMandateService < StripeService
|
|
8
|
+
# Deprecated: Use CancelSpendingMandate instead.
|
|
8
9
|
# Cancels an active ReceivedDebitMandate.
|
|
9
10
|
def cancel(id, params = {}, opts = {})
|
|
10
11
|
request(
|
|
@@ -16,6 +17,7 @@ module Stripe
|
|
|
16
17
|
)
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
# Deprecated: Use ListSpendingMandates instead.
|
|
19
21
|
# Returns a list of ReceivedDebitMandates.
|
|
20
22
|
def list(params = {}, opts = {})
|
|
21
23
|
request(
|
|
@@ -27,6 +29,7 @@ module Stripe
|
|
|
27
29
|
)
|
|
28
30
|
end
|
|
29
31
|
|
|
32
|
+
# Deprecated: Use RetrieveSpendingMandate instead.
|
|
30
33
|
# Retrieves the details of an existing ReceivedDebitMandate.
|
|
31
34
|
def retrieve(id, params = {}, opts = {})
|
|
32
35
|
request(
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Stripe
|
|
5
|
+
module V2
|
|
6
|
+
module MoneyManagement
|
|
7
|
+
class SpendingMandateService < StripeService
|
|
8
|
+
# Cancels an active SpendingMandate.
|
|
9
|
+
def cancel(id, params = {}, opts = {})
|
|
10
|
+
request(
|
|
11
|
+
method: :post,
|
|
12
|
+
path: format("/v2/money_management/spending_mandates/%<id>s/cancel", { id: CGI.escape(id) }),
|
|
13
|
+
params: params,
|
|
14
|
+
opts: opts,
|
|
15
|
+
base_address: :api
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns a list of SpendingMandates.
|
|
20
|
+
def list(params = {}, opts = {})
|
|
21
|
+
request(
|
|
22
|
+
method: :get,
|
|
23
|
+
path: "/v2/money_management/spending_mandates",
|
|
24
|
+
params: params,
|
|
25
|
+
opts: opts,
|
|
26
|
+
base_address: :api
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Retrieves the details of an existing SpendingMandate.
|
|
31
|
+
def retrieve(id, params = {}, opts = {})
|
|
32
|
+
request(
|
|
33
|
+
method: :get,
|
|
34
|
+
path: format("/v2/money_management/spending_mandates/%<id>s", { id: CGI.escape(id) }),
|
|
35
|
+
params: params,
|
|
36
|
+
opts: opts,
|
|
37
|
+
base_address: :api
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module Stripe
|
|
5
5
|
module V2
|
|
6
6
|
class MoneyManagementService < StripeService
|
|
7
|
-
attr_reader :adjustments, :currency_conversions, :debit_disputes, :earned_credits, :financial_accounts, :financial_addresses, :funding_intents, :funding_sessions, :inbound_fundings, :inbound_transfers, :inbound_transfer_mandates, :outbound_payments, :outbound_payment_quotes, :outbound_setup_intents, :outbound_transfers, :payout_intents, :payout_methods, :payout_methods_bank_account_spec, :received_credits, :received_debits, :received_debit_mandates, :recipient_verifications, :reward_programs, :reward_program_enrollments, :test_helpers, :transactions, :transaction_entries
|
|
7
|
+
attr_reader :adjustments, :currency_conversions, :debit_disputes, :earned_credits, :financial_accounts, :financial_addresses, :funding_intents, :funding_sessions, :inbound_fundings, :inbound_transfers, :inbound_transfer_mandates, :outbound_payments, :outbound_payment_quotes, :outbound_setup_intents, :outbound_transfers, :payout_intents, :payout_methods, :payout_methods_bank_account_spec, :received_credits, :received_debits, :received_debit_mandates, :recipient_verifications, :reward_programs, :reward_program_enrollments, :spending_mandates, :test_helpers, :transactions, :transaction_entries
|
|
8
8
|
|
|
9
9
|
def initialize(requestor)
|
|
10
10
|
super
|
|
@@ -40,6 +40,7 @@ module Stripe
|
|
|
40
40
|
@reward_programs = Stripe::V2::MoneyManagement::RewardProgramService.new(@requestor)
|
|
41
41
|
@reward_program_enrollments = Stripe::V2::MoneyManagement::RewardProgramEnrollmentService
|
|
42
42
|
.new(@requestor)
|
|
43
|
+
@spending_mandates = Stripe::V2::MoneyManagement::SpendingMandateService.new(@requestor)
|
|
43
44
|
@test_helpers = Stripe::V2::MoneyManagement::TestHelperService.new(@requestor)
|
|
44
45
|
@transactions = Stripe::V2::MoneyManagement::TransactionService.new(@requestor)
|
|
45
46
|
@transaction_entries = Stripe::V2::MoneyManagement::TransactionEntryService.new(@requestor)
|
data/lib/stripe/services.rb
CHANGED
|
@@ -546,6 +546,7 @@ module Stripe
|
|
|
546
546
|
autoload :RecipientVerificationService, "stripe/services/v2/money_management/recipient_verification_service"
|
|
547
547
|
autoload :RewardProgramEnrollmentService, "stripe/services/v2/money_management/reward_program_enrollment_service"
|
|
548
548
|
autoload :RewardProgramService, "stripe/services/v2/money_management/reward_program_service"
|
|
549
|
+
autoload :SpendingMandateService, "stripe/services/v2/money_management/spending_mandate_service"
|
|
549
550
|
autoload :TestHelperService, "stripe/services/v2/money_management/test_helper_service"
|
|
550
551
|
autoload :TransactionEntryService, "stripe/services/v2/money_management/transaction_entry_service"
|
|
551
552
|
autoload :TransactionService, "stripe/services/v2/money_management/transaction_service"
|
|
@@ -987,6 +988,7 @@ module Stripe
|
|
|
987
988
|
stripe/services/v2/money_management/reward_program_enrollment_service
|
|
988
989
|
stripe/services/v2/money_management/reward_program_service
|
|
989
990
|
stripe/services/v2/money_management/reward_programs/rule_service
|
|
991
|
+
stripe/services/v2/money_management/spending_mandate_service
|
|
990
992
|
stripe/services/v2/money_management/test_helper_service
|
|
991
993
|
stripe/services/v2/money_management/test_helpers/financial_address_service
|
|
992
994
|
stripe/services/v2/money_management/transaction_entry_service
|
|
@@ -2150,6 +2150,26 @@ module Stripe
|
|
|
2150
2150
|
register("v2.money_management.reward_program.reward_reversed", &callback)
|
|
2151
2151
|
end
|
|
2152
2152
|
|
|
2153
|
+
def on_v2_money_management_spending_mandate_canceled(&callback)
|
|
2154
|
+
register("v2.money_management.spending_mandate.canceled", &callback)
|
|
2155
|
+
end
|
|
2156
|
+
|
|
2157
|
+
def on_v2_money_management_spending_mandate_created(&callback)
|
|
2158
|
+
register("v2.money_management.spending_mandate.created", &callback)
|
|
2159
|
+
end
|
|
2160
|
+
|
|
2161
|
+
def on_v2_money_management_spending_mandate_expired(&callback)
|
|
2162
|
+
register("v2.money_management.spending_mandate.expired", &callback)
|
|
2163
|
+
end
|
|
2164
|
+
|
|
2165
|
+
def on_v2_money_management_spending_mandate_pending_cancellation(&callback)
|
|
2166
|
+
register("v2.money_management.spending_mandate.pending_cancellation", &callback)
|
|
2167
|
+
end
|
|
2168
|
+
|
|
2169
|
+
def on_v2_money_management_spending_mandate_updated(&callback)
|
|
2170
|
+
register("v2.money_management.spending_mandate.updated", &callback)
|
|
2171
|
+
end
|
|
2172
|
+
|
|
2153
2173
|
def on_v2_money_management_transaction_created(&callback)
|
|
2154
2174
|
register("v2.money_management.transaction.created", &callback)
|
|
2155
2175
|
end
|
data/lib/stripe/version.rb
CHANGED
data/lib/stripe/webhook.rb
CHANGED
|
@@ -76,6 +76,8 @@ module Stripe
|
|
|
76
76
|
|
|
77
77
|
module Signature
|
|
78
78
|
EXPECTED_SCHEME = "v1"
|
|
79
|
+
DebugMetadata = Struct.new(:secret, :destination, :payload)
|
|
80
|
+
private_constant :DebugMetadata
|
|
79
81
|
|
|
80
82
|
# Computes a webhook signature given a time (probably the current time),
|
|
81
83
|
# a payload, and a signing secret.
|
|
@@ -110,7 +112,7 @@ module Stripe
|
|
|
110
112
|
def self.get_timestamp_and_signatures(header, scheme)
|
|
111
113
|
list_items = header.split(/,\s*/).map { |i| i.split("=", 2) }
|
|
112
114
|
timestamp = Integer(list_items.select { |i| i[0] == "t" }[0][1])
|
|
113
|
-
signatures = list_items.select { |i| i[0] == scheme }.map { |i| i[1] }
|
|
115
|
+
signatures = list_items.select { |i| i[0] == scheme }.map { |i| i[1] }.compact
|
|
114
116
|
[Time.at(timestamp), signatures]
|
|
115
117
|
end
|
|
116
118
|
private_class_method :get_timestamp_and_signatures
|
|
@@ -152,7 +154,7 @@ module Stripe
|
|
|
152
154
|
expected_sig = compute_signature(timestamp, payload, secret)
|
|
153
155
|
unless signatures.any? { |s| Util.secure_compare(expected_sig, s) }
|
|
154
156
|
raise SignatureVerificationError.new(
|
|
155
|
-
|
|
157
|
+
signature_error_message(header, payload, secret),
|
|
156
158
|
header, http_body: payload
|
|
157
159
|
)
|
|
158
160
|
end
|
|
@@ -167,6 +169,63 @@ module Stripe
|
|
|
167
169
|
|
|
168
170
|
true
|
|
169
171
|
end
|
|
172
|
+
|
|
173
|
+
private_class_method def self.signature_error_message(header, payload, secret)
|
|
174
|
+
debug_metadata = signature_debug_metadata(header)
|
|
175
|
+
|
|
176
|
+
# If metadata has an asterisk-masked secret, compare against its length and last four characters
|
|
177
|
+
masked_secret = debug_metadata.secret || ""
|
|
178
|
+
masked_suffix = masked_secret[-4, 4]
|
|
179
|
+
secret_suffix = secret[-4, 4] || secret
|
|
180
|
+
if masked_secret&.include?("*") && (secret.length != masked_secret.length || secret_suffix != masked_suffix)
|
|
181
|
+
dashboard_url = "https://dashboard.stripe.com/webhooks"
|
|
182
|
+
dashboard_url += "/#{CGI.escape(debug_metadata.destination)}" if debug_metadata.destination
|
|
183
|
+
return "Webhook signature verification failed. This request may not have originated from Stripe.\n\n" \
|
|
184
|
+
"The signing secret you provided is #{secret.length} characters long " \
|
|
185
|
+
"and ends in `#{secret_suffix}`. " \
|
|
186
|
+
"However, the signing secret for this destination is #{masked_secret.length} characters long " \
|
|
187
|
+
"and looks like `#{masked_secret}`. Ensure you're using the signing secret for this " \
|
|
188
|
+
"destination, as shown on the Dashboard: #{dashboard_url}\n\n" \
|
|
189
|
+
"Learn more: https://docs.stripe.com/webhooks/signature"
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# If metadata includes the truncated payload hash, compare with the payload passed in
|
|
193
|
+
if debug_metadata.payload&.match?(/\A[0-9a-fA-F]{8}\z/)
|
|
194
|
+
expected_hash = debug_metadata.payload.downcase
|
|
195
|
+
actual_hash = OpenSSL::Digest::SHA256.hexdigest(payload)[-8, 8]
|
|
196
|
+
if expected_hash != actual_hash
|
|
197
|
+
return "Webhook signature verification failed.\n\n" \
|
|
198
|
+
"The request body you passed to this function differs from the request body sent by Stripe " \
|
|
199
|
+
"to this webhook destination.\n" \
|
|
200
|
+
"The SHA-256 hash of the body should end in `#{expected_hash}`. However, " \
|
|
201
|
+
"the SHA-256 hash of the body you provided ends in `#{actual_hash}`.\n\n" \
|
|
202
|
+
"Make sure your code does not reformat or otherwise alter the raw HTTP request body " \
|
|
203
|
+
"before passing it to this function.\n\n" \
|
|
204
|
+
"Learn more: https://docs.stripe.com/webhooks/signature"
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Fall back to the generic message if no debug metadata available
|
|
209
|
+
"No signatures found matching the expected signature for payload"
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Extract metadata from the stripe-signature header value to help debug verification failures
|
|
213
|
+
private_class_method def self.signature_debug_metadata(header)
|
|
214
|
+
# For each metadata key, extract the first value found in the header
|
|
215
|
+
metadata = DebugMetadata.new
|
|
216
|
+
list_items = header.b.split(/,\s*/).map { |item| item.split("=", 2) }
|
|
217
|
+
DebugMetadata.members.each do |key|
|
|
218
|
+
value = list_items.assoc(key.to_s)&.[](1)
|
|
219
|
+
value&.force_encoding(header.encoding)
|
|
220
|
+
metadata[key] = safe_metadata_value?(value) ? value : nil
|
|
221
|
+
end
|
|
222
|
+
metadata
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
private_class_method def self.safe_metadata_value?(value)
|
|
226
|
+
# Ignore overly long, potentially attacker-provided metadata values
|
|
227
|
+
value && value.length <= 100 && value.valid_encoding?
|
|
228
|
+
end
|
|
170
229
|
end
|
|
171
230
|
end
|
|
172
231
|
end
|