Class: LucidShopify::VerifyWebhook
- Inherits:
-
Object
- Object
- LucidShopify::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.
20 21 22 23 24 25 26 |
# File 'lib/lucid_shopify/verify_webhook.rb', line 20 def call(data, hmac) digest = OpenSSL::Digest::SHA256.new digest = OpenSSL::HMAC.digest(digest, LucidShopify.config.shared_secret, data) digest = Base64.encode64(digest).strip raise Error, 'invalid signature' unless digest == hmac end |