Class: VisaNetUy::PlugIn
- Inherits:
-
Object
- Object
- VisaNetUy::PlugIn
- Defined in:
- lib/visa_net_uy/plug_in.rb
Instance Attribute Summary collapse
-
#cipher_private_key ⇒ Object
Returns the value of attribute cipher_private_key.
-
#cipher_public_key ⇒ Object
Returns the value of attribute cipher_public_key.
-
#iv ⇒ Object
Returns the value of attribute iv.
-
#signature_private_key ⇒ Object
Returns the value of attribute signature_private_key.
-
#signature_public_key ⇒ Object
Returns the value of attribute signature_public_key.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PlugIn
constructor
A new instance of PlugIn.
- #vpos_request_params(fields) ⇒ Object
- #vpos_response_fields(response) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PlugIn
Returns a new instance of PlugIn.
5 6 7 8 9 10 11 12 13 |
# File 'lib/visa_net_uy/plug_in.rb', line 5 def initialize( = {}) unless block_given? .each do |key, value| send(:"#{key}=", value) end else yield(self) end end |
Instance Attribute Details
#cipher_private_key ⇒ Object
Returns the value of attribute cipher_private_key.
3 4 5 |
# File 'lib/visa_net_uy/plug_in.rb', line 3 def cipher_private_key @cipher_private_key end |
#cipher_public_key ⇒ Object
Returns the value of attribute cipher_public_key.
3 4 5 |
# File 'lib/visa_net_uy/plug_in.rb', line 3 def cipher_public_key @cipher_public_key end |
#iv ⇒ Object
Returns the value of attribute iv.
3 4 5 |
# File 'lib/visa_net_uy/plug_in.rb', line 3 def iv @iv end |
#signature_private_key ⇒ Object
Returns the value of attribute signature_private_key.
3 4 5 |
# File 'lib/visa_net_uy/plug_in.rb', line 3 def signature_private_key @signature_private_key end |
#signature_public_key ⇒ Object
Returns the value of attribute signature_public_key.
3 4 5 |
# File 'lib/visa_net_uy/plug_in.rb', line 3 def signature_public_key @signature_public_key end |
Instance Method Details
#vpos_request_params(fields) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/visa_net_uy/plug_in.rb', line 15 def vpos_request_params(fields) request_params = {} # Check for required fields fields.include?('acquirerId') ? (request_params['IDACQUIRER'] = fields['acquirerId']) : (raise "Misssing acquirerId field.") fields.include?('commerceId') ? (request_params['IDCOMMERCE'] = fields['commerceId']) : (raise "Misssing commerceId field.") # Generate XML from fields xml = xmler.generate(fields) # Generate SessionKey session_key = cipher.generate_session_key # Generate digital signature urlsafe_base64_signature = signer.generate_urlsafe_base64_signature(xml, signature_private_key) request_params['DIGITALSIGN'] = urlsafe_base64_signature # Cipher XML urlsafe_base64_encrypted_xml = cipher.urlsafe_base64_symmetric_encrypt(xml, session_key, iv) request_params['XMLREQ'] = urlsafe_base64_encrypted_xml # Cipher SessionKey urlsafe_base64_encrypted_session_key = cipher.urlsafe_base64_asymmetric_encrypt(session_key, cipher_public_key) request_params['SESSIONKEY'] = urlsafe_base64_encrypted_session_key request_params end |
#vpos_response_fields(response) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/visa_net_uy/plug_in.rb', line 43 def vpos_response_fields(response) # Check for required fields response.include?('SESSIONKEY') ? (session_key = response['SESSIONKEY']) : (raise "Misssing SESSIONKEY.") response.include?('XMLRES') ? (xmlres = response['XMLRES']) : (raise "Misssing XMLRES.") response.include?('DIGITALSIGN') ? (digital_sing = response['DIGITALSIGN']) : (raise "Misssing DIGITALSIGN.") # Decrypt Session Key session_key = cipher.urlsafe_base64_asymmetric_decrypt(session_key, cipher_private_key) # Decrypt XML xml = cipher.urlsafe_base64_symmetric_decrypt(xmlres, session_key, iv) # Verify Signature raise 'Invalid Signature.' unless signer.verify_urlsafe_base64_signature(xml, digital_sing, signature_public_key) # Parse XML xmler.parse(xml) end |