Class: ShopifyClient::VerifyWebhook
- Inherits:
-
Object
- Object
- ShopifyClient::VerifyWebhook
- Defined in:
- lib/shopify-client/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.
16 17 18 19 20 21 22 |
# File 'lib/shopify-client/verify_webhook.rb', line 16 def call(data, hmac) digest = OpenSSL::Digest::SHA256.new digest = OpenSSL::HMAC.digest(digest, ShopifyClient.config.shared_secret, data) digest = Base64.encode64(digest).strip raise Error, 'invalid signature' unless digest == hmac end |