<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -42,7 +42,7 @@ module ActiveMerchant
       BANK_ERROR = REALEX_ERROR  = &quot;Gateway is in maintenance. Please try again later.&quot;
       ERROR = CLIENT_DEACTIVATED = &quot;Gateway Error&quot;
       
-      # Unique to the Realex gateway, it requires a separate secret password used to provide refunds/credits.
+      # Unique to the Realex gateway, it requires a separate secret password used to provide credits/refunds.
       attr_accessor :refundhash
       
       def initialize(options = {})
@@ -195,7 +195,7 @@ module ActiveMerchant
       end
 
       def build_purchase_or_authorization_request(action, money, credit_card, options)
-        timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+        timestamp = self.class.timestamp
         
         xml = Builder::XmlMarkup.new :indent =&gt; 2
         xml.tag! 'request', 'timestamp' =&gt; timestamp, 'type' =&gt; 'auth' do
@@ -267,7 +267,7 @@ module ActiveMerchant
       #  &lt;md5hash&gt;738e83....34ae662a&lt;/md5hash&gt;  
       # &lt;/request&gt; 
       def build_rebate_request(money, options)
-        timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+        timestamp = self.class.timestamp
         
         xml = Builder::XmlMarkup.new :indent =&gt; 2
         xml.tag! 'request', 'timestamp' =&gt; timestamp, 'type' =&gt; 'rebate' do
@@ -302,7 +302,7 @@ module ActiveMerchant
       #  &lt;md5hash&gt;34e7....a77d&lt;/md5hash&gt;  
       # &lt;/request&gt; 
       def build_void_request(options)
-        timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+        timestamp = self.class.timestamp
         
         xml = Builder::XmlMarkup.new :indent =&gt; 2
         xml.tag! 'request', 'timestamp' =&gt; timestamp, 'type' =&gt; 'void' do
@@ -333,7 +333,7 @@ module ActiveMerchant
       #  &lt;sha1hash&gt;7384ae67....ac7d7d&lt;/sha1hash&gt;  
       # &lt;/request&gt; 
       def build_settle_request(options)
-        timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+        timestamp = self.class.timestamp
         
         xml = Builder::XmlMarkup.new :indent =&gt; 2
         xml.tag! 'request', 'timestamp' =&gt; timestamp, 'type' =&gt; 'settle' do
@@ -342,9 +342,10 @@ module ActiveMerchant
           xml.tag! 'orderid', sanitize_order_id(options[:order_id])
           xml.tag! 'pasref', options[:pasref]
           xml.tag! 'authcode', options[:authcode]
-          xml.tag! 'comments' do
-            xml.tag! 'comment', options[:description], 'id' =&gt; 1 
-            xml.tag! 'comment', 'id' =&gt; 2
+          if options[:description]
+            xml.tag! 'comments' do
+              xml.tag! 'comment', options[:description], 'id' =&gt; 1 
+            end
           end
           xml.tag! 'sha1hash', sha1from(&quot;#{timestamp}.#{@options[:login]}.#{sanitize_order_id(options[:order_id])}&quot;)
         end
@@ -398,6 +399,10 @@ module ActiveMerchant
       def sanitize_order_id(order_id)
         order_id.to_s.gsub(/[^a-zA-Z0-9\-_]/, '')
       end
+      
+      def self.timestamp
+        Time.now.strftime('%Y%m%d%H%M%S')
+      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/active_merchant/billing/gateways/realex.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,14 +3,20 @@ require 'digest/sha1'
 
 class RealexTest &lt; Test::Unit::TestCase
   
+  class ActiveMerchant::Billing::RealexGateway
+    # For the purposes of testing, lets redefine some protected methods as public.
+    public :build_purchase_or_authorization_request, :build_rebate_request, :build_void_request, :build_settle_request
+  end
+  
   def setup
     @login = 'your_merchant_id'
     @password = 'your_secret'
+    @account = 'your_account'
     
     @gateway = RealexGateway.new(
-      :login =&gt; @merchant_id,
-      :password =&gt; @secret,
-      :account =&gt; ''
+      :login =&gt; @login,
+      :password =&gt; @password,
+      :account =&gt; @account
     )
 
     @gateway_with_account = RealexGateway.new(
@@ -35,7 +41,6 @@ class RealexTest &lt; Test::Unit::TestCase
     @amount = 100
   end
   
-  
   def test_in_test
     assert_equal :test, ActiveMerchant::Billing::Base.gateway_mode
   end  
@@ -109,6 +114,29 @@ class RealexTest &lt; Test::Unit::TestCase
     assert_equal 'M', response.cvv_result['code']
   end
   
+  def test_capture_xml
+    options = {
+      :pasref =&gt; '1234',
+      :authcode =&gt; '1234',
+      :order_id =&gt; '1'
+    }
+    
+    ActiveMerchant::Billing::RealexGateway.expects(:timestamp).returns('20090824160201')
+    
+    valid_capture_xml = &lt;&lt;-SRC
+&lt;request timestamp=&quot;20090824160201&quot; type=&quot;settle&quot;&gt;
+  &lt;merchantid&gt;your_merchant_id&lt;/merchantid&gt;
+  &lt;account&gt;your_account&lt;/account&gt;
+  &lt;orderid&gt;1&lt;/orderid&gt;
+  &lt;pasref&gt;1234&lt;/pasref&gt;
+  &lt;authcode&gt;1234&lt;/authcode&gt;
+  &lt;sha1hash&gt;a28e8d7ae105d98f8cf1a014786aed77bde6485a&lt;/sha1hash&gt;
+&lt;/request&gt;
+SRC
+    
+    assert_equal valid_capture_xml, @gateway.build_settle_request(options)    
+  end
+  
   private
   
   def successful_purchase_response</diff>
      <filename>test/unit/gateways/realex_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1fb149614c55e98b1c594f8a1b308c9c7710e0ac</id>
    </parent>
  </parents>
  <author>
    <name>David Rice</name>
    <email>davidjrice@gmail.com</email>
  </author>
  <url>http://github.com/davidjrice/active_merchant/commit/56f040b229c4fec88ded451284c9a13a12b39aea</url>
  <id>56f040b229c4fec88ded451284c9a13a12b39aea</id>
  <committed-date>2009-08-24T08:21:20-07:00</committed-date>
  <authored-date>2009-08-24T08:21:20-07:00</authored-date>
  <message>Add xml generation test for realex capture request</message>
  <tree>536e11ed91b750aa3a0835348d0ca3e06c68154f</tree>
  <committer>
    <name>David Rice</name>
    <email>davidjrice@gmail.com</email>
  </committer>
</commit>
