Class: Lucid::Shopify::VerifyWebhook
- Inherits:
-
Object
- Object
- Lucid::Shopify::VerifyWebhook
- Defined in:
- lib/lucid/shopify/verify_webhook.rb
Constant Summary collapse
- Error =
Class.new(Error)
Instance Method Summary collapse
-
#call(data, hmac) ⇒ Object
Verify that the webhook request originated from Shopify.
Instance Method Details
#call(data, hmac) ⇒ Object
Verify that the webhook request originated from Shopify.
19 20 21 22 23 24 25 |
# File 'lib/lucid/shopify/verify_webhook.rb', line 19 def call(data, hmac) digest = OpenSSL::Digest::SHA256.new digest = OpenSSL::HMAC.digest(digest, Shopify.config.shared_secret, data) digest = Base64.encode64(digest).strip raise Error, 'invalid signature' unless digest == hmac end |