Class: SermepaWebTpv::Signature
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#generate_transaction_number!, #transaction_amount, #transaction_number
Constructor Details
#initialize(action) ⇒ Signature
Returns a new instance of Signature.
30
31
32
|
# File 'lib/sermepa_web_tpv/signature.rb', line 30
def initialize(action)
@action = action
end
|
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9
10
11
|
# File 'lib/sermepa_web_tpv/signature.rb', line 9
def action
@action
end
|
Class Method Details
.cipher ⇒ Object
21
22
23
|
# File 'lib/sermepa_web_tpv/signature.rb', line 21
def cipher
Mcrypt.new(:tripledes, :cbc, merchant_key, iv, :zeros)
end
|
.digestor ⇒ Object
25
26
27
|
# File 'lib/sermepa_web_tpv/signature.rb', line 25
def digestor
@digestor ||= OpenSSL::Digest.new('sha256')
end
|
.iv ⇒ Object
12
13
14
15
|
# File 'lib/sermepa_web_tpv/signature.rb', line 12
def iv
0.chr * 8
end
|
.merchant_key ⇒ Object
17
18
19
|
# File 'lib/sermepa_web_tpv/signature.rb', line 17
def merchant_key
Base64.decode64(SermepaWebTpv.merchant_secret_key)
end
|
Instance Method Details
#key ⇒ Object
41
42
43
|
# File 'lib/sermepa_web_tpv/signature.rb', line 41
def key
self.class.cipher.encrypt(action.transaction_number)
end
|
#signature ⇒ Object
34
35
36
37
38
39
|
# File 'lib/sermepa_web_tpv/signature.rb', line 34
def signature
Base64.encode64(
OpenSSL::HMAC.digest(self.class.digestor, key,
action.merchant_parameters))
.strip
end
|