Class: Braintree::SignatureService
- Inherits:
-
Object
- Object
- Braintree::SignatureService
- Defined in:
- lib/braintree/signature_service.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #hash(data) ⇒ Object
-
#initialize(key, digest = Braintree::Digest) ⇒ SignatureService
constructor
A new instance of SignatureService.
- #sign(data) ⇒ Object
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
#key ⇒ Object (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 |