Method: Increase::Webhook::Signature.compute_signature

Defined in:
lib/increase/webhook/signature.rb

.compute_signature(timestamp:, payload:, secret:) ⇒ Object

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
67
# File 'lib/increase/webhook/signature.rb', line 60

def self.compute_signature(timestamp:, payload:, secret:)
  raise ArgumentError, "timestamp is required" if timestamp.nil?
  raise ArgumentError, "payload is required" if payload.nil?
  raise ArgumentError, "secret is required" if secret.nil?

  signed_payload = timestamp.to_s + "." + payload.to_s
  OpenSSL::HMAC.hexdigest("SHA256", secret, signed_payload)
end