<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/active_merchant/billing/gateways/elavon.rb</filename>
    </added>
    <added>
      <filename>test/remote/gateways/remote_elavon_test.rb</filename>
    </added>
    <added>
      <filename>test/unit/gateways/elavon_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 = ActiveMerchant CHANGELOG
 
 * Fix typo preventing OgoneGateway from working in production [Nicolas Jacobeus]
+* Add support for the Elavon MyVirtualMerchant gateway [jstorimer]
 * Fix recurring transactions in Ogone gateway [cody]
 * Fix money formatting for Ogone gateway [cody]
 * Tweak Ogone gateway to use ActiveMerchant conventions for reference transactions [cody, jstorimer]</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -112,3 +112,7 @@ FirstPay (July 24, 2009)
 Ogone (July 20, 2009)
 
 * Nicolas Jacobeus
+
+Elavon (August 09, 2009)
+
+* Jesse Storimer</diff>
      <filename>CONTRIBUTERS</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,16 @@
 module ActiveMerchant #:nodoc:
   module Billing #:nodoc:
     class ViaklixGateway &lt; Gateway
-      TEST_URL = 'https://demo.viaklix.com/process.asp'
-      LIVE_URL = 'https://www.viaklix.com/process.asp'
+      class_inheritable_accessor :test_url, :live_url, :delimiter, :actions
+
+      self.test_url = 'https://demo.viaklix.com/process.asp'
+      self.live_url = 'https://www.viaklix.com/process.asp'
+      self.delimiter = &quot;\r\n&quot;
+      
+      self.actions = {
+        :purchase =&gt; 'SALE',
+        :credit =&gt; 'CREDIT'
+      }
       
       APPROVED = '0'
       
@@ -35,7 +43,7 @@ module ActiveMerchant #:nodoc:
         add_creditcard(form, creditcard)        
         add_address(form, options)   
         add_customer_data(form, options)
-        commit('SALE', money, form)
+        commit(:purchase, money, form)
       end
       
       # Make a credit to a card (Void can only be done from the virtual terminal)
@@ -50,7 +58,7 @@ module ActiveMerchant #:nodoc:
         add_creditcard(form, creditcard)        
         add_address(form, options)   
         add_customer_data(form, options)
-        commit('CREDIT', money, form)
+        commit(:credit, money, form)
       end
       
       private
@@ -104,20 +112,24 @@ module ActiveMerchant #:nodoc:
         form[:exp_date] = expdate(creditcard)
         
         if creditcard.verification_value?
-          form[:cvv2cvc2] = creditcard.verification_value 
-          form[:cvv2] = 'present'
+          add_verification_value(form, creditcard)
         end
         
         form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
         form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
       end
       
+      def add_verification_value(form, creditcard)
+        form[:cvv2cvc2] = creditcard.verification_value 
+        form[:cvv2] = 'present'
+      end
+      
       def preamble
         result = {
           'merchant_id'   =&gt; @options[:login],
           'pin'           =&gt; @options[:password],
           'show_form'     =&gt; 'false',
-          'test_mode'     =&gt; @options[:test] ? 'TRUE' : 'FALSE',
+          'test_mode'     =&gt; test? ? 'TRUE' : 'FALSE',
           'result_format' =&gt; 'ASCII',          
         }
         
@@ -125,20 +137,32 @@ module ActiveMerchant #:nodoc:
         result
       end
       
+      def test?
+        @options[:test] || super
+      end
+      
       def commit(action, money, parameters)
         parameters[:amount] = amount(money)
-        parameters[:transaction_type] = action
+        parameters[:transaction_type] = self.actions[action]
             
-        response = parse( ssl_post(test? ? TEST_URL : LIVE_URL, post_data(parameters)) )
+        response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) )
 
-        Response.new(response['result'] == APPROVED, response['result_message'], response, 
+        Response.new(response['result'] == APPROVED, message_from(response), response, 
           :test =&gt; @options[:test] || test?, 
-          :authorization =&gt; response['txn_id'],
+          :authorization =&gt; authorization_from(response),
           :avs_result =&gt; { :code =&gt; response['avs_response'] },
           :cvv_result =&gt; response['cvv2_response']
         )
       end
       
+      def authorization_from(response)
+        response['txn_id']
+      end
+      
+      def message_from(response)
+        response['result_message']
+      end
+      
       def post_data(parameters)
         result = preamble
         result.merge!(parameters)        
@@ -154,9 +178,9 @@ module ActiveMerchant #:nodoc:
       # Parse the response message
       def parse(msg)
         resp = {}
-        msg.split(&quot;\r\n&quot;).collect{|li|
+        msg.split(self.delimiter).collect{|li|
             key, value = li.split(&quot;=&quot;)
-            resp[key.gsub(/^ssl_/, '')] = value.to_s.strip
+            resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
           }
         resp
       end</diff>
      <filename>lib/active_merchant/billing/gateways/viaklix.rb</filename>
    </modified>
    <modified>
      <diff>@@ -44,6 +44,10 @@ efsnet:
   login: X
   password: Y
 
+elavon:
+  login: LOGIN
+  password: PASSWORD
+
 # Working credentials, no need to replace
 eway:
   login: '87654321'</diff>
      <filename>test/fixtures.yml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2c5832f7e3aa257abf8bd5e4617e40fc218282dd</id>
    </parent>
  </parents>
  <author>
    <name>Jesse Storimer</name>
    <email>jesse@jadedpixel.com</email>
  </author>
  <url>http://github.com/rayvinly/active_merchant/commit/90f5bbdbe7051daddedfdfbafe6d0feb2ef6dd39</url>
  <id>90f5bbdbe7051daddedfdfbafe6d0feb2ef6dd39</id>
  <committed-date>2009-08-20T09:24:41-07:00</committed-date>
  <authored-date>2009-08-07T19:43:08-07:00</authored-date>
  <message>Added support for Elavon gateway.</message>
  <tree>4b2c22bad03945dd3811f1b93c9d5f0d8f34b54f</tree>
  <committer>
    <name>James MacAulay</name>
    <email>james@jadedpixel.com</email>
  </committer>
</commit>
