Class: Billimatic::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/billimatic/signature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ Signature

Returns a new instance of Signature.



5
6
7
# File 'lib/billimatic/signature.rb', line 5

def initialize(secret)
  @secret = secret
end

Instance Attribute Details

#secretObject

Returns the value of attribute secret.



3
4
5
# File 'lib/billimatic/signature.rb', line 3

def secret
  @secret
end

Instance Method Details

#check?(billimatic_request_id, signature_to_check, body) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/billimatic/signature.rb', line 9

def check?(billimatic_request_id, signature_to_check, body)
  billimatic_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret, "#{billimatic_request_id}#{body}")
  signature_to_check == billimatic_signature
end