Class: DkPaymentGateway::Signature
- Inherits:
-
Object
- Object
- DkPaymentGateway::Signature
- Defined in:
- lib/dk_payment_gateway/signature.rb
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
Class Method Summary collapse
-
.generate(private_key, request_body) ⇒ Object
Convenience method to generate signature headers.
Instance Method Summary collapse
-
#generate_headers(request_body) ⇒ Object
Generate signature headers for a request Returns a hash with DK-Signature, DK-Timestamp, and DK-Nonce.
-
#initialize(private_key) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(private_key) ⇒ Signature
Returns a new instance of Signature.
13 14 15 |
# File 'lib/dk_payment_gateway/signature.rb', line 13 def initialize(private_key) @private_key = private_key end |
Instance Attribute Details
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
11 12 13 |
# File 'lib/dk_payment_gateway/signature.rb', line 11 def private_key @private_key end |
Class Method Details
.generate(private_key, request_body) ⇒ Object
Convenience method to generate signature headers
66 67 68 |
# File 'lib/dk_payment_gateway/signature.rb', line 66 def generate(private_key, request_body) new(private_key).generate_headers(request_body) end |
Instance Method Details
#generate_headers(request_body) ⇒ Object
Generate signature headers for a request Returns a hash with DK-Signature, DK-Timestamp, and DK-Nonce
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dk_payment_gateway/signature.rb', line 19 def generate_headers(request_body) = nonce = generate_nonce signature = sign_request(request_body, , nonce) { 'DK-Signature' => "DKSignature #{signature}", 'DK-Timestamp' => , 'DK-Nonce' => nonce } end |