Sha256: f654204e216193159cf9e6165b6a844cb0b81fa2da0400c1f2aebf4b3a042a77
Contents?: true
Size: 1.04 KB
Versions: 18
Compression:
Stored size: 1.04 KB
Contents
module Stripe module EventDispatch def dispatch_stripe_event(request) retrieve_stripe_event(request) do |evt| target = evt.data.object ::Stripe::Callbacks.run_callbacks(evt, target) end end def retrieve_stripe_event(request) id = request['id'] body = request.body.read sig_header = request.headers['HTTP_STRIPE_SIGNATURE'] endpoint_secrets = ::Rails.application.config.stripe.signing_secrets if Object.const_defined?('Stripe::Webhook') && sig_header && endpoint_secrets event = webhook_event(body, sig_header, endpoint_secrets) else event = Stripe::Event.retrieve(id) end yield event end private def webhook_event(body, sig_header, endpoint_secrets) endpoint_secrets.each_with_index do |secret, i| begin return ::Stripe::Webhook.construct_event(body, sig_header, secret.to_s) rescue ::Stripe::SignatureVerificationError raise if i == endpoint_secrets.length - 1 end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems