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_money_manager_capability_status_updated, #on_v2_core_account_including_configuration_money_manager_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_approval_request_approved, #on_v2_core_approval_request_canceled, #on_v2_core_approval_request_created, #on_v2_core_approval_request_expired, #on_v2_core_approval_request_failed, #on_v2_core_approval_request_rejected, #on_v2_core_approval_request_succeeded, #on_v2_core_batch_job_batch_failed, #on_v2_core_batch_job_canceled, #on_v2_core_batch_job_completed, #on_v2_core_batch_job_created, #on_v2_core_batch_job_ready_for_upload, #on_v2_core_batch_job_timeout, #on_v2_core_batch_job_updated, #on_v2_core_batch_job_upload_timeout, #on_v2_core_batch_job_validating, #on_v2_core_batch_job_validation_failed, #on_v2_core_event_destination_ping, #on_v2_core_health_event_generation_failure_resolved, #on_v2_data_reporting_query_run_created, #on_v2_data_reporting_query_run_failed, #on_v2_data_reporting_query_run_succeeded, #on_v2_data_reporting_query_run_updated, #on_v2_extend_workflow_run_failed, #on_v2_extend_workflow_run_started, #on_v2_extend_workflow_run_succeeded, #on_v2_money_management_adjustment_created, #on_v2_money_management_financial_account_created, #on_v2_money_management_financial_account_updated, #on_v2_money_management_financial_address_activated, #on_v2_money_management_financial_address_failed, #on_v2_money_management_inbound_transfer_available, #on_v2_money_management_inbound_transfer_bank_debit_failed, #on_v2_money_management_inbound_transfer_bank_debit_processing, #on_v2_money_management_inbound_transfer_bank_debit_queued, #on_v2_money_management_inbound_transfer_bank_debit_returned, #on_v2_money_management_inbound_transfer_bank_debit_succeeded, #on_v2_money_management_outbound_payment_canceled, #on_v2_money_management_outbound_payment_created, #on_v2_money_management_outbound_payment_failed, #on_v2_money_management_outbound_payment_posted, #on_v2_money_management_outbound_payment_returned, #on_v2_money_management_outbound_payment_under_review, #on_v2_money_management_outbound_payment_updated, #on_v2_money_management_outbound_transfer_canceled, #on_v2_money_management_outbound_transfer_created, #on_v2_money_management_outbound_transfer_failed, #on_v2_money_management_outbound_transfer_posted, #on_v2_money_management_outbound_transfer_returned, #on_v2_money_management_outbound_transfer_under_review, #on_v2_money_management_outbound_transfer_updated, #on_v2_money_management_payout_method_created, #on_v2_money_management_payout_method_updated, #on_v2_money_management_received_credit_available, #on_v2_money_management_received_credit_failed, #on_v2_money_management_received_credit_returned, #on_v2_money_management_received_credit_succeeded, #on_v2_money_management_received_debit_canceled, #on_v2_money_management_received_debit_failed, #on_v2_money_management_received_debit_pending, #on_v2_money_management_received_debit_succeeded, #on_v2_money_management_received_debit_updated, #on_v2_money_management_transaction_created, #on_v2_money_management_transaction_updated, #on_v2_orchestrated_commerce_agreement_confirmed, #on_v2_orchestrated_commerce_agreement_created, #on_v2_orchestrated_commerce_agreement_partially_confirmed, #on_v2_orchestrated_commerce_agreement_terminated, #on_v2_signals_account_evaluation_complete, #pre_handle, #registered_event_types
Constructor Details
#initialize(client, webhook_secret, &fallback_callback) ⇒ StripeEventNotificationHandler
Returns a new instance of StripeEventNotificationHandler.
468 469 470 471 472 473 474 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 468 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
476 477 478 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 476 def self.without_verification(client, &fallback_callback) StripeEventNotificationHandlerWithoutVerification.send(:new, client, &fallback_callback) end |
Instance Method Details
#handle(webhook_body, sig_header) ⇒ Object
480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/stripe/stripe_event_notification_handler.rb', line 480 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 |