lib/active_merchant/billing/gateways/mit.rb in activemerchant-1.133.0 vs lib/active_merchant/billing/gateways/mit.rb in activemerchant-1.137.0

- old
+ new

@@ -5,10 +5,11 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class MitGateway < Gateway self.live_url = 'https://wpy.mitec.com.mx/ModuloUtilWS/activeCDP.htm' + self.test_url = 'https://scqa.mitec.com.mx/ModuloUtilWS/activeCDP.htm' self.supported_countries = ['MX'] self.default_currency = 'MXN' self.supported_cardtypes = %i[visa master] @@ -39,11 +40,11 @@ iv_base64 = unpacked[0].bytes.slice(0, 16) # Splits the second bytes (the encrypted text bytes) these would be the # original message full_data = unpacked[0].bytes.slice(16, unpacked[0].bytes.length) # Creates the engine - engine = OpenSSL::Cipher::AES128.new(:CBC) + engine = OpenSSL::Cipher.new('aes-128-cbc') # Set engine as decrypt mode engine.decrypt # Converts the key from hex to bytes engine.key = [keyinhex].pack('H*') # Converts the ivBase64 array into bytes @@ -52,11 +53,11 @@ engine.update(full_data.pack('c*')) + engine.final end def encrypt(val, keyinhex) # Creates the engine motor - engine = OpenSSL::Cipher::AES128.new(:CBC) + engine = OpenSSL::Cipher.new('aes-128-cbc') # Set engine as encrypt mode engine.encrypt # Converts the key from hex to bytes engine.key = [keyinhex].pack('H*') # Generates a random iv with this settings @@ -218,11 +219,15 @@ post[:expyear] = payment.year post[:cvv] = payment.verification_value post[:name_client] = [payment.first_name, payment.last_name].join(' ') end + def url + test? ? test_url : live_url + end + def commit(action, parameters) - raw_response = ssl_post(live_url, parameters, { 'Content-type' => 'text/plain' }) + raw_response = ssl_post(url, parameters, { 'Content-type' => 'text/plain' }) response = JSON.parse(decrypt(raw_response, @options[:key_session])) Response.new( success_from(response), message_from(response),