Class: Braintree::SignatureService

Inherits:
Object
  • Object
show all
Defined in:
lib/braintree/signature_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, digest = Braintree::Digest) ⇒ SignatureService

Returns a new instance of SignatureService.


5
6
7
8
# File 'lib/braintree/signature_service.rb', line 5

def initialize(key, digest=Braintree::Digest)
  @key = key
  @digest = digest
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.


3
4
5
# File 'lib/braintree/signature_service.rb', line 3

def key
  @key
end

Instance Method Details

#hash(data) ⇒ Object


15
16
17
# File 'lib/braintree/signature_service.rb', line 15

def hash(data)
  @digest.hexdigest(@key, data)
end

#sign(data) ⇒ Object


10
11
12
13
# File 'lib/braintree/signature_service.rb', line 10

def sign(data)
  query_string = Util.hash_to_query_string(data)
  "#{hash(query_string)}|#{query_string}"
end