Class: DkPaymentGateway::Signature
- Inherits:
-
Object
- Object
- DkPaymentGateway::Signature
- Defined in:
- lib/dk_payment_gateway/signature.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
Class Method Summary collapse
-
.generate(private_key, access_token, 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, access_token) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(private_key, access_token) ⇒ Signature
Returns a new instance of Signature.
13 14 15 16 |
# File 'lib/dk_payment_gateway/signature.rb', line 13 def initialize(private_key, access_token) @private_key = private_key @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/dk_payment_gateway/signature.rb', line 11 def access_token @access_token end |
#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, access_token, request_body) ⇒ Object
Convenience method to generate signature headers
69 70 71 |
# File 'lib/dk_payment_gateway/signature.rb', line 69 def generate(private_key, access_token, request_body) new(private_key, access_token).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
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dk_payment_gateway/signature.rb', line 20 def generate_headers(request_body) = nonce = generate_nonce signature = sign_request(request_body, , nonce) { 'DK-Signature' => "DKSignature #{signature}", 'DK-Timestamp' => , 'DK-Nonce' => nonce, 'Authorization' => "Bearer #{access_token}" } end |