Class: Stripe::StripeEventNotificationHandler
- Inherits:
-
StripeEventNotificationHandlerBase
- Object
- StripeEventNotificationHandlerBase
- Stripe::StripeEventNotificationHandler
- Defined in:
- lib/stripe/stripe_event_notification_handler.rb
Overview
Verifies incoming webhook signatures before routing events to the callbacks registered on it. This is the handler you want unless events reach you through a channel that has already authenticated them.
Class Method Summary collapse
Instance Method Summary collapse
- #handle(webhook_body, sig_header) ⇒ Object
-
#initialize(client, webhook_secret, &fallback_callback) ⇒ StripeEventNotificationHandler
constructor
A new instance of StripeEventNotificationHandler.
Methods inherited from StripeEventNotificationHandlerBase
#on_v1_billing_meter_error_report_triggered, #on_v1_billing_meter_no_meter_found, #on_v2_commerce_product_catalog_imports_failed, #on_v2_commerce_product_catalog_imports_processing, #on_v2_commerce_product_catalog_imports_succeeded, #on_v2_commerce_product_catalog_imports_succeeded_with_errors, #on_v2_core_account_closed, #on_v2_core_account_created, #on_v2_core_account_including_configuration_customer_capability_status_updated, #on_v2_core_account_including_configuration_customer_updated, #on_v2_core_account_including_configuration_merchant_capability_status_updated, #on_v2_core_account_including_configuration_merchant_updated, #on_v2_core_account_including_configuration_recipient_capability_status_updated, #on_v2_core_account_including_configuration_recipient_updated, #on_v2_core_account_including_defaults_updated, #on_v2_core_account_including_future_requirements_updated, #on_v2_core_account_including_identity_updated, #on_v2_core_account_including_requirements_updated, #on_v2_core_account_link_returned, #on_v2_core_account_person_created, #on_v2_core_account_person_deleted, #on_v2_core_account_person_updated, #on_v2_core_account_updated, #on_v2_core_event_destination_ping, #pre_handle, #registered_event_types
Constructor Details
#initialize(client, webhook_secret, &fallback_callback) ⇒ StripeEventNotificationHandler
Returns a new instance of StripeEventNotificationHandler.
188 189 190 191 192 193 194 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 188 def initialize(client, webhook_secret, &fallback_callback) super(client, &fallback_callback) raise ArgumentError, "webhook_secret must be a non-empty string" if webhook_secret.nil? || webhook_secret.empty? @webhook_secret = webhook_secret end |
Class Method Details
.without_verification(client, &fallback_callback) ⇒ Object
196 197 198 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 196 def self.without_verification(client, &fallback_callback) StripeEventNotificationHandlerWithoutVerification.send(:new, client, &fallback_callback) end |
Instance Method Details
#handle(webhook_body, sig_header) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 200 def handle(webhook_body, sig_header) # set before parsing, so that even a failed parse locks out registration. # we're ok with this not being a thread-safe write since registering # handlers should happen synchronously on startup before any multi-threaded reads happen @has_handled_events = true dispatch(@client.parse_event_notification( webhook_body, sig_header, @webhook_secret )) end |