Module: StripeEvent::WebhookControllerDecorator

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

Instance Method Summary collapse

Instance Method Details

#secrets(payload, signature) ⇒ Object

Raises:

  • (Stripe::SignatureVerificationError)


3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/stripe_event/webhook_controller_decorator.rb', line 3

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