Class: Wayforpay::EncryptField

Inherits:
Object
  • Object
show all
Defined in:
lib/wayforpay/encrypt_field.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys, attrs) ⇒ EncryptField

Returns a new instance of EncryptField.



7
8
9
# File 'lib/wayforpay/encrypt_field.rb', line 7

def initialize(keys, attrs)
  @keys, @attrs = keys, attrs
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



5
6
7
# File 'lib/wayforpay/encrypt_field.rb', line 5

def attrs
  @attrs
end

#keysObject (readonly)

Returns the value of attribute keys.



5
6
7
# File 'lib/wayforpay/encrypt_field.rb', line 5

def keys
  @keys
end

Class Method Details

.call(keys, attrs = {}) ⇒ Object



11
12
13
# File 'lib/wayforpay/encrypt_field.rb', line 11

def self.call(keys, attrs = {})
  new(keys, attrs).call
end

Instance Method Details

#callObject



15
16
17
# File 'lib/wayforpay/encrypt_field.rb', line 15

def call
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('md5'), Wayforpay.encrypt_secret_key, signature_string)
end

#signature_stringObject



19
20
21
# File 'lib/wayforpay/encrypt_field.rb', line 19

def signature_string
  attrs.values_at(*keys).compact.join(';')
end