Module: StripeEvent::WebhookControllerDecorator

Defined in:
app/controllers/stripe_event/webhook_controller_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



3
4
5
# File 'app/controllers/stripe_event/webhook_controller_decorator.rb', line 3

def self.prepended(base)
  base.include Spree::Core::ControllerHelpers::Store
end

Instance Method Details

#secrets(payload, signature) ⇒ Object

Raises:

  • (Stripe::SignatureVerificationError)


7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/stripe_event/webhook_controller_decorator.rb', line 7

def secrets(payload, signature)
  all_signing_keys = SpreeStripe::WebhookKey.pluck(:signing_secret).uniq.compact
  all_signing_keys << ENV['STRIPE_SIGNING_SECRET'] if ENV['STRIPE_SIGNING_SECRET'].present?

  return all_signing_keys if all_signing_keys.any?

  raise Stripe::SignatureVerificationError.new(
    'Cannot verify signature without a `StripeEvent.signing_secret`',
    signature, http_body: payload
  )
end