<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,13 +4,19 @@ module ActiveMerchant #:nodoc:
     # of necessary attributes such as checkholder's name, routing and account numbers, but it is
     # not backed by any database.
     # 
-    # You may use Check in place of CreditCard with any gateway that supports it. Currently, only
-    # +BrainTreeGateway+ supports the Check object.
+    # You may use Check in place of CreditCard with any gateway that supports it. 
+    # Currently the following gateways support the check object.
+    # +BrainTreeGateway+ 
+    # +Authorize.net (AIM)+
+    
     class Check
       include Validateable
       
       attr_accessor :first_name, :last_name, :routing_number, :account_number, :account_holder_type, :account_type, :number
       
+      # Required for eCheck.net 
+      attr_accessor :account_name, :bank_name, :bank_account_name, :echeck_type
+      
       # Used for Canadian bank accounts
       attr_accessor :institution_number, :transit_number
       
@@ -28,10 +34,12 @@ module ActiveMerchant #:nodoc:
       end
       
       def validate
-        [:name, :routing_number, :account_number].each do |attr|
+        [:name, :routing_number, :account_number, :account_name, :echeck_type].each do |attr|
           errors.add(attr, &quot;cannot be empty&quot;) if self.send(attr).blank?
         end
         
+        errors.add(:echeck_type, &quot;is invalid&quot;) unless valid_echeck_type?
+        
         errors.add(:routing_number, &quot;is invalid&quot;) unless valid_routing_number?
         
         errors.add(:account_holder_type, &quot;must be personal or business&quot;) if
@@ -45,6 +53,10 @@ module ActiveMerchant #:nodoc:
         'check'
       end
       
+      def valid_echeck_type?
+        AuthorizeNetCimGateway::ECHECK_TYPES.values.include?(echeck_type)
+      end
+      
       # Routing numbers may be validated by calculating a checksum and dividing it by 10. The
       # formula is:
       #   (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0</diff>
      <filename>lib/active_merchant/billing/check.rb</filename>
    </modified>
    <modified>
      <diff>@@ -226,6 +226,20 @@ module ActiveMerchant #:nodoc:
         request = build_recurring_request(:cancel, :subscription_id =&gt; subscription_id)
         recurring_commit(:cancel, request)
       end
+      
+      # Perform an eCheck.net purchase, which is essentially an authorization and capture in a single operation.
+      #
+      # ==== Parameters
+      #
+      # * &lt;tt&gt;money&lt;/tt&gt; -- The amount to be purchased. Either an Integer value in cents or a Money object.
+      # * &lt;tt&gt;check&lt;/tt&gt; -- The Check object for the transaction.
+      # * &lt;tt&gt;options&lt;/tt&gt; -- A hash of optional parameters.
+      def echeck(money, check, options = {})
+       post = {:method =&gt; &quot;ECHECK&quot;}
+       add_check(post, check)
+       post.merge!(options)
+       commit(&quot;AUTH_CAPTURE&quot;, money, post)
+      end
 
       private
       
@@ -295,7 +309,17 @@ module ActiveMerchant #:nodoc:
         request = post.merge(parameters).collect { |key, value| &quot;x_#{key}=#{CGI.escape(value.to_s)}&quot; }.join(&quot;&amp;&quot;)
         request
       end
-
+      
+      def add_check(post, check)
+        post[:bank_aba_code]     = check.routing_number 
+        post[:bank_acct_num]     = check.account_number 
+        post[:bank_acct_type]    = check.account_type
+        post[:bank_name]         = check.bank_name
+        post[:bank_acct_name]    = check.bank_account_name
+        post[:echeck_type]       = check.echeck_type
+        post[:bank_check_number] = check.number
+      end
+      
       def add_invoice(post, options)
         post[:invoice_num] = options[:order_id]
         post[:description] = options[:description]
@@ -615,7 +639,7 @@ module ActiveMerchant #:nodoc:
 
       def recurring_commit(action, request)
         url = test? ? arb_test_url : arb_live_url
-        xml = ssl_post(url, request, &quot;Content-Type&quot; =&gt; &quot;text/xml&quot;)
+        xml = ssl_post(url, request, &quot;Content-Type&quot; =&gt; &quot;application/x-www-form-urlencoded&quot;)
         
         response = recurring_parse(action, xml)
 
@@ -651,7 +675,9 @@ module ActiveMerchant #:nodoc:
         end
       end
     end
-
+    
+    # eCheck.net ------
+            
     AuthorizedNetGateway = AuthorizeNetGateway
   end
 end</diff>
      <filename>lib/active_merchant/billing/gateways/authorize_net.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,8 +70,12 @@ module ActiveMerchant #:nodoc:
       }
       
       ECHECK_TYPES = {
+        :arc =&gt; 'ARC',
+        :boc =&gt; 'BOC',
         :ccd =&gt; 'CCD',
-        :ppd =&gt; 'PPD'
+        :ppd =&gt; 'PPD',
+        :tel =&gt; 'TEL',
+        :web =&gt; 'WEB'
       }
       
       self.homepage_url = 'http://www.authorize.net/'</diff>
      <filename>lib/active_merchant/billing/gateways/authorize_net_cim.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,9 @@ class CheckTest &lt; Test::Unit::TestCase
                   :routing_number =&gt; VALID_ABA,
                   :account_number =&gt; ACCOUNT_NUMBER,
                   :account_holder_type =&gt; 'personal',
-                  :account_type =&gt; 'checking')
+                  :account_type =&gt; 'checking',
+                  :account_name =&gt; 'Rick James',
+                  :echeck_type =&gt; 'PPD')
     assert c.valid?
   end
   
@@ -85,4 +87,30 @@ class CheckTest &lt; Test::Unit::TestCase
     c.valid?
     assert !c.errors.on(:account_type)
   end
+  
+  def test_account_name
+    c = Check.new
+    c.account_name = 'Rick James'
+    c.valid?
+    assert !c.errors.on(:account_name)
+    c.account_name = nil
+    c.valid?
+    assert c.errors.on(:account_name)
+    c.account_name = &quot;&quot;
+    c.valid?
+    assert c.errors.on(:account_name)
+  end
+  
+  def test_echeck_type
+    c = Check.new
+    AuthorizeNetCimGateway::ECHECK_TYPES.map do |name, value|
+      c.echeck_type = value
+      c.valid?
+      assert !c.errors.on(:echeck_type)
+    end
+    c.echeck_type = 'moo'
+    c.valid?
+    assert c.errors.on(:echeck_type)
+    assert_equal c.errors.on(:echeck_type), &quot;is invalid&quot;
+  end
 end</diff>
      <filename>test/unit/check_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ class AuthorizeNetTest &lt; Test::Unit::TestCase
       :login =&gt; 'X',
       :password =&gt; 'Y'
     )
-    @amount = 100
+    @amount = 0
     @credit_card = credit_card
     @subscription_id = '100748'
   end
@@ -211,6 +211,14 @@ class AuthorizeNetTest &lt; Test::Unit::TestCase
     assert_equal '2013-11', @gateway.send(:arb_expdate, credit_card('4111111111111111', :month =&gt; &quot;11&quot;, :year =&gt; &quot;2013&quot;))
   end
 
+  def test_echeck
+    check = Check.new(:routing_number =&gt; &quot;111000025&quot;, :account_number =&gt; &quot;123456789012&quot;)
+    response = @gateway.send(:echeck, 100, check)
+    assert_instance_of Response, response
+    assert response.success?
+    assert response.test?
+  end
+
   private
   def post_data_fixture
     'x_encap_char=%24&amp;x_card_num=4242424242424242&amp;x_exp_date=0806&amp;x_card_code=123&amp;x_type=AUTH_ONLY&amp;x_first_name=Longbob&amp;x_version=3.1&amp;x_login=X&amp;x_last_name=Longsen&amp;x_tran_key=Y&amp;x_relay_response=FALSE&amp;x_delim_data=TRUE&amp;x_delim_char=%2C&amp;x_amount=1.01'</diff>
      <filename>test/unit/gateways/authorize_net_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a3d18bd755595ba78b897237a116bafc464bed55</id>
    </parent>
  </parents>
  <author>
    <name>Tim Matheson</name>
    <email>me@tim-mathesons-macbook.local</email>
  </author>
  <url>http://github.com/timmatheson/active_merchant/commit/21b1971b76c7fc233030fde50f17d5cedbe2599f</url>
  <id>21b1971b76c7fc233030fde50f17d5cedbe2599f</id>
  <committed-date>2009-10-16T09:43:53-07:00</committed-date>
  <authored-date>2009-10-16T09:43:53-07:00</authored-date>
  <message>adding eCheck.net support to Authorize.net</message>
  <tree>61066e7aceece8dad46c5ef25ab65b67744f2a44</tree>
  <committer>
    <name>Tim Matheson</name>
    <email>me@tim-mathesons-macbook.local</email>
  </committer>
</commit>
