6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/square/utilities/webhooks_helper.rb', line 6
def self.is_valid_webhook_event_signature(request_body, , signature_key, notification_url)
return false if request_body.nil?
raise 'signature_key is null or empty' if signature_key.nil? || signature_key.empty?
raise 'notification_url is null or empty' if notification_url.nil? || notification_url.empty?
payload_bytes = "#{notification_url}#{request_body}".force_encoding('utf-8')
signature_key_bytes = signature_key.force_encoding('utf-8')
hmac = OpenSSL::HMAC.digest('sha256', signature_key_bytes, payload_bytes)
hash_base64 = Base64.strict_encode64(hmac)
hash_base64 ==
end
|