Class: Vpago::AcledaMobile::CallbackValidator
- Inherits:
-
Object
- Object
- Vpago::AcledaMobile::CallbackValidator
- Defined in:
- lib/vpago/acleda_mobile/callback_validator.rb
Instance Method Summary collapse
- #call ⇒ Object
- #hmac_hash ⇒ Object
-
#initialize(options) ⇒ CallbackValidator
constructor
{ “TransactionId”: “REF0361472663”, “PaymentTokenId”: “16de81d4-b5ef-ef59-16de-81d4b5efef59”, “TxnAmount”: “30”, “SenderName”: “Test User”, “SignedHash”: “c5b9be690bde7dc8a0abebb1a45c0850359540a4977aecd4cdf13e15a2edfe79”, }.
- #secret_key ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ CallbackValidator
{
"TransactionId": "REF0361472663",
"PaymentTokenId": "16de81d4-b5ef-ef59-16de-81d4b5efef59",
"TxnAmount": "30",
"SenderName": "Test User",
"SignedHash": "c5b9be690bde7dc8a0abebb1a45c0850359540a4977aecd4cdf13e15a2edfe79",
}
11 12 13 |
# File 'lib/vpago/acleda_mobile/callback_validator.rb', line 11 def initialize() = end |
Instance Method Details
#call ⇒ Object
15 16 17 |
# File 'lib/vpago/acleda_mobile/callback_validator.rb', line 15 def call valid? end |
#hmac_hash ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/vpago/acleda_mobile/callback_validator.rb', line 29 def hmac_hash key = secret_key = "#{@options[:TransactionId]} #{@options[:PaymentTokenId]} #{@options[:TxnAmount]}" OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), key, ) end |
#secret_key ⇒ Object
19 20 21 |
# File 'lib/vpago/acleda_mobile/callback_validator.rb', line 19 def secret_key ENV.fetch('ACLEDA_MOBILE_SECRET_HASH_KEY', nil) end |
#valid? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/vpago/acleda_mobile/callback_validator.rb', line 23 def valid? return false if secret_key.blank? hmac_hash == [:SignedHash] end |