<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -47,6 +47,13 @@ module ActiveMerchant
         @options = options
         super
       end  
+      
+      def authorize(money, credit_card, options = {})
+        requires!(options, :order_id)
+        
+        request = build_purchase_or_authorization_request(:authorization, money, credit_card, options) 
+        commit(request)
+      end
   
       def purchase(money, credit_card, options = {})
         requires!(options, :order_id)
@@ -55,6 +62,28 @@ module ActiveMerchant
         commit(request)
       end     
       
+      def capture(money, authorization, options = {})
+        requires!(options, :order_id, :pasref) 
+        options.update(
+          :authcode =&gt; authorization
+        )
+        
+        request = build_void_or_settle_request(:settle, money, options) 
+        commit(request)
+      end
+      
+      # Void a previous transaction
+      def void(authorization, options = {})
+        requires!(options, :order_id, :pasref)
+        options.update(
+          :authcode =&gt; authorization
+        )
+        
+        request = build_void_or_settle_request(:void, nil, options) 
+        commit(request)
+      end
+
+      
       private           
       def commit(request)        
         response = parse(ssl_post(URL, request))
@@ -148,6 +177,32 @@ module ActiveMerchant
         xml.target!
       end
       
+      def build_void_or_settle_request(action, money, options)
+        timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+        
+        xml = Builder::XmlMarkup.new :indent =&gt; 2
+        xml.tag! 'request', 'timestamp' =&gt; timestamp, 'type' =&gt; action do
+      
+          xml.tag! 'merchantid', @options[:login] 
+          xml.tag! 'account', @options[:account]
+      
+          xml.tag! 'orderid', sanitize_order_id(options[:order_id])
+          xml.tag! 'amount', amount(money), 'currency' =&gt; options[:currency] || currency(money)
+                    
+          xml.tag! 'pasref', options[:pasref]
+          xml.tag! 'authcode', options[:authcode]
+          
+          xml.tag! 'sha1hash', sha1from(&quot;#{timestamp}.#{@options[:login]}.#{sanitize_order_id(options[:order_id])}.#{amount(money)}.#{options[:currency] || currency(money)}.&quot;)
+          xml.tag! 'comments' do
+            xml.tag! 'comment', options[:description], 'id' =&gt; 1 
+            xml.tag! 'comment', 'id' =&gt; 2
+          end
+          
+        end
+
+        xml.target!
+      end
+      
       def auto_settle_flag(action)
         action == :authorization ? '0' : '1'
       end</diff>
      <filename>lib/active_merchant/billing/gateways/realex.rb</filename>
    </modified>
    <modified>
      <diff>@@ -179,77 +179,14 @@ quickpay:
   password: Y
     
 realex:
-  login: X 
+  login: X
   password: Y
     
 realex_with_account:
   login: X
   password: Y
-  account: testaccount
-
-# Realex doesn't provide public testing data
-# Fill in the card numbers with the Realex test
-# data.  
-realex_visa:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_visa_declined:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_visa_referral_a:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-  
-realex_visa_referral_b:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-  
-realex_visa_coms_error:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
+  account: &quot;testaccount&quot;
   
-realex_mastercard:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_mastercard_declined:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_mastercard_referral_a:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_mastercard_referral_b:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
-realex_mastercard_coms_error:
-  number: 
-  month: '6'
-  year: '2020'
-  verification_value: '123'
-
 sage:
   login: login
   password: password</diff>
      <filename>test/fixtures.yml</filename>
    </modified>
    <modified>
      <diff>@@ -8,21 +8,106 @@ class RemoteRealexTest &lt; Test::Unit::TestCase
     @gateway_with_account = RealexGateway.new(fixtures(:realex_with_account))
   
     # Replace the card numbers with the test account numbers from Realex
-    @visa            = fixtures(:realex_visa)
-    @visa_declined   = fixtures(:realex_visa_declined)
-    @visa_referral_b = fixtures(:realex_visa_referral_b)
-    @visa_referral_a = fixtures(:realex_visa_referral_a)
-    @visa_coms_error = fixtures(:realex_visa_coms_error)
+    @visa            = credit_card('your-test-creditcard-no-here')
+    @visa_declined   = credit_card('your-test-creditcard-no-here')
+    @visa_referral_b = credit_card('your-test-creditcard-no-here')
+    @visa_referral_a = credit_card('your-test-creditcard-no-here')
+    @visa_coms_error = credit_card('your-test-creditcard-no-here')
     
-    @mastercard            = fixtures(:realex_mastercard)
-    @mastercard_declined   = fixtures(:realex_mastercard_declined)
-    @mastercard_referral_b = fixtures(:realex_mastercard_referral_b)
-    @mastercard_referral_a = fixtures(:realex_mastercard_referral_a)
-    @mastercard_coms_error = fixtures(:realex_mastercard_coms_error)
+    @mastercard            = credit_card('your-test-creditcard-no-here', {:type =&gt; 'master'})
+    @mastercard_declined   = credit_card('your-test-creditcard-no-here', {:type =&gt; 'master'})
+    @mastercard_referral_b = credit_card('your-test-creditcard-no-here', {:type =&gt; 'master'})
+    @mastercard_referral_a = credit_card('your-test-creditcard-no-here', {:type =&gt; 'master'})
+    @mastercard_coms_error = credit_card('your-test-creditcard-no-here', {:type =&gt; 'master'})
     
     @amount = 10000
   end
   
+  def test_realex_authorize
+    [ @visa, @mastercard ].each do |card|
+
+      response = @gateway.authorize(@amount, card, 
+        :order_id =&gt; generate_unique_id,
+        :description =&gt; 'Test Realex authorize',
+        :billing_address =&gt; {
+          :zip =&gt; '90210',
+          :country =&gt; 'US'
+        }
+      )
+      assert_not_nil response
+      assert_success response
+      assert response.test?
+      assert response.authorization.length &gt; 0
+      assert_equal 'Successful', response.message
+    end      
+  end
+  
+  def test_realex_authorize_and_capture
+    [ @visa, @mastercard ].each do |card|
+
+      auth_response = @gateway.authorize(@amount, card, 
+        :order_id =&gt; generate_unique_id,
+        :description =&gt; 'Test Realex authorize',
+        :billing_address =&gt; {
+          :zip =&gt; '90210',
+          :country =&gt; 'US'
+        }
+      )
+ 
+      assert_not_nil auth_response
+      assert_success auth_response
+      assert auth_response.test?
+      assert auth_response.authorization.length &gt; 0
+      assert_equal 'Successful', auth_response.message
+    
+      capt_response = @gateway.capture(@amount, auth_response.authorization,
+        :order_id =&gt; auth_response.params['orderid'],
+        :pasref =&gt; auth_response.params['pasref'],
+        :description =&gt; 'Test Realex capture'
+      )
+
+      assert_not_nil capt_response
+      assert_success capt_response
+      assert capt_response.test?
+      assert_equal 'Successful', capt_response.message
+      
+    end      
+  end
+  
+  
+  def test_realex_authorize_and_void
+    [ @visa, @mastercard ].each do |card|
+
+      auth_response = @gateway.authorize(@amount, card, 
+        :order_id =&gt; generate_unique_id,
+        :description =&gt; 'Test Realex authorize',
+        :billing_address =&gt; {
+          :zip =&gt; '90210',
+          :country =&gt; 'US'
+        }
+      )
+ 
+      assert_not_nil auth_response
+      assert_success auth_response
+      assert auth_response.test?
+      assert auth_response.authorization.length &gt; 0
+      assert_equal 'Successful', auth_response.message
+    
+      void_response = @gateway.void(auth_response.authorization,
+        :order_id =&gt; auth_response.params['orderid'],
+        :pasref =&gt; auth_response.params['pasref'],
+        :description =&gt; 'Test Realex void'
+      )
+
+      assert_not_nil void_response
+      assert_success void_response
+      assert void_response.test?
+      assert_equal 'Successful', void_response.message
+      
+    end      
+  end
+  
+  
   def test_realex_purchase
     [ @visa, @mastercard ].each do |card|
 </diff>
      <filename>test/remote/gateways/remote_realex_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9e7407deb7acf76c2252404b920dd7695b118167</id>
    </parent>
  </parents>
  <author>
    <name>Brian Quinn</name>
    <email>briandquinn@gmail.com</email>
  </author>
  <url>http://github.com/BDQ/active_merchant/commit/6cb1e5d6b55a4aa0f8bd83950e8cfe8e9aa76c25</url>
  <id>6cb1e5d6b55a4aa0f8bd83950e8cfe8e9aa76c25</id>
  <committed-date>2008-11-10T12:46:53-08:00</committed-date>
  <authored-date>2008-11-10T12:46:53-08:00</authored-date>
  <message>Added authorize / capture / void support to Realex gateway</message>
  <tree>e71ae9087dd3c1904c0894a8d05f3a85b562242a</tree>
  <committer>
    <name>Brian Quinn</name>
    <email>briandquinn@gmail.com</email>
  </committer>
</commit>
