<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,11 +5,15 @@ module Adyen
 
     extend ActionView::Helpers::TagHelper
 
+    ######################################################
+    # SKINS
+    ######################################################
+
     def self.skins
       @skins ||= {}
     end
     
-    def self.add_skin(name, skin_code, shared_secret)
+    def self.register_skin(name, skin_code, shared_secret)
       self.skins[name] = {:name =&gt; name, :skin_code =&gt; skin_code, :shared_secret =&gt; shared_secret }
     end
 
@@ -20,6 +24,26 @@ module Adyen
     def self.skin_by_code(skin_code)
       self.skins.detect { |(name, skin)| skin[:skin_code] == skin_code }.last rescue nil      
     end
+    
+    def self.lookup_shared_secret(skin_code)
+      skin = skin_by_code(skin_code)[:shared_secret] rescue nil
+    end    
+    
+    ######################################################
+    # DEFAULT FORM / REDIRECT PARAMETERS
+    ######################################################    
+
+    def self.default_parameters
+      @default_arguments ||= {}
+    end
+    
+    def self.default_parameters=(hash)
+      @default_arguments = hash
+    end
+
+    ######################################################
+    # ADYEN FORM URL
+    ######################################################
 
     ACTION_URL = &quot;https://%s.adyen.com/hpp/select.shtml&quot;
 
@@ -28,65 +52,75 @@ module Adyen
       Adyen::Form::ACTION_URL % environment.to_s
     end
 
-    def self.calculate_signature_string(attributes)
-      merchant_sig_string = &quot;&quot;
-      merchant_sig_string &lt;&lt; attributes[:payment_amount].to_s    &lt;&lt; attributes[:currency_code].to_s      &lt;&lt;
-                             attributes[:ship_before_date].to_s  &lt;&lt; attributes[:merchant_reference].to_s &lt;&lt;
-                             attributes[:skin_code].to_s         &lt;&lt; attributes[:merchant_account].to_s   &lt;&lt;
-                             attributes[:session_validity].to_s  &lt;&lt; attributes[:shopper_email].to_s      &lt;&lt;
-                             attributes[:shopper_reference].to_s &lt;&lt; attributes[:recurring_contract].to_s &lt;&lt;
-                             attributes[:allowed_methods].to_s   &lt;&lt; attributes[:blocked_methods].to_s    &lt;&lt;
-                             attributes[:shopper_statement].to_s &lt;&lt; attributes[:billing_address_type].to_s
-    end
 
-    def self.calculate_signature(attributes)
-       Adyen::Encoding.hmac_base64(attributes.delete(:shared_secret), calculate_signature_string(attributes))
-    end
+    ######################################################
+    # POSTING/REDIRECTING TO ADYEN
+    ######################################################
 
-    def self.do_attribute_transformations!(attributes = {})
-      raise &quot;YENs are not yet supported!&quot; if attributes[:currency_code] == 'JPY' # TODO: fixme
+    def self.do_parameter_transformations!(parameters = {})
+      raise &quot;YENs are not yet supported!&quot; if parameters[:currency_code] == 'JPY' # TODO: fixme
 
-      attributes[:recurring_contract] = 'DEFAULT' if attributes.delete(:recurring) == true
-      attributes[:order_data]         = Adyen::Encoding.gzip_base64(attributes.delete(:order_data_raw)) if attributes[:order_data_raw]
-      attributes[:ship_before_date]   = Adyen::Formatter::DateTime.fmt_date(attributes[:ship_before_date])
-      attributes[:session_validity]   = Adyen::Formatter::DateTime.fmt_time(attributes[:session_validity])
+      parameters.replace(default_parameters.merge(parameters))
+      parameters[:recurring_contract] = 'DEFAULT' if parameters.delete(:recurring) == true
+      parameters[:order_data]         = Adyen::Encoding.gzip_base64(parameters.delete(:order_data_raw)) if parameters[:order_data_raw]
+      parameters[:ship_before_date]   = Adyen::Formatter::DateTime.fmt_date(parameters[:ship_before_date])
+      parameters[:session_validity]   = Adyen::Formatter::DateTime.fmt_time(parameters[:session_validity])
       
-      if attributes[:skin]
-        skin = Adyen::Form.skin_by_name(attributes.delete(:skin))
-        attributes[:skin_code]     ||= skin[:skin_code]
-        attributes[:shared_secret] ||= skin[:shared_secret]
+      if parameters[:skin]
+        skin = Adyen::Form.skin_by_name(parameters.delete(:skin))
+        parameters[:skin_code]     ||= skin[:skin_code]
+        parameters[:shared_secret] ||= skin[:shared_secret]
       end
     end
 
-    def self.payment_fields(attributes = {})
-      do_attribute_transformations!(attributes)
+    def self.payment_parameters(parameters = {})
+      do_parameter_transformations!(parameters)
       
-      raise &quot;Cannot generate form: :currency code attribute not found!&quot;         unless attributes[:currency_code]
-      raise &quot;Cannot generate form: :payment_amount code attribute not found!&quot;   unless attributes[:payment_amount]
-      raise &quot;Cannot generate form: :merchant_account attribute not found!&quot;      unless attributes[:merchant_account]
-      raise &quot;Cannot generate form: :skin_code attribute not found!&quot;             unless attributes[:skin_code]
-      raise &quot;Cannot generate form: :shared_secret signing secret not provided!&quot; unless attributes[:shared_secret]
+      raise &quot;Cannot generate form: :currency code attribute not found!&quot;         unless parameters[:currency_code]
+      raise &quot;Cannot generate form: :payment_amount code attribute not found!&quot;   unless parameters[:payment_amount]
+      raise &quot;Cannot generate form: :merchant_account attribute not found!&quot;      unless parameters[:merchant_account]
+      raise &quot;Cannot generate form: :skin_code attribute not found!&quot;             unless parameters[:skin_code]
+      raise &quot;Cannot generate form: :shared_secret signing secret not provided!&quot; unless parameters[:shared_secret]
 
       # Merchant signature
-      attributes[:merchant_sig] = calculate_signature(attributes)
-      return attributes      
+      parameters[:merchant_sig] = calculate_signature(parameters)
+      return parameters      
     end
     
-    def self.redirect_url(attributes)
-      self.url + '?' + payment_fields(attributes).map { |(k, v)| &quot;#{k.to_s.camelize(:lower)}=#{CGI.escape(v.to_s)}&quot; }.join('&amp;')
+    def self.redirect_url(parameters = {})
+      self.url + '?' + payment_parameters(parameters).map { |(k, v)| &quot;#{k.to_s.camelize(:lower)}=#{CGI.escape(v.to_s)}&quot; }.join('&amp;')
     end
 
-    def self.hidden_fields(attributes = {})
+    def self.hidden_fields(parameters = {})
       # Generate hidden input tags
-      payment_fields(attributes).map { |key, value|
+      payment_parameters(parameters).map { |key, value|
         self.tag(:input, :type =&gt; 'hidden', :name =&gt; key.to_s.camelize(:lower), :value =&gt; value)
       }.join(&quot;\n&quot;)
     end
     
-    def self.lookup_shared_secret(skin_code)
-      skin = skin_by_code(skin_code)[:shared_secret] rescue nil
+    ######################################################
+    # MERCHANT SIGNATURE CALCULATION
+    ######################################################
+
+    def self.calculate_signature_string(parameters)
+      merchant_sig_string = &quot;&quot;
+      merchant_sig_string &lt;&lt; parameters[:payment_amount].to_s    &lt;&lt; parameters[:currency_code].to_s      &lt;&lt;
+                             parameters[:ship_before_date].to_s  &lt;&lt; parameters[:merchant_reference].to_s &lt;&lt;
+                             parameters[:skin_code].to_s         &lt;&lt; parameters[:merchant_account].to_s   &lt;&lt;
+                             parameters[:session_validity].to_s  &lt;&lt; parameters[:shopper_email].to_s      &lt;&lt;
+                             parameters[:shopper_reference].to_s &lt;&lt; parameters[:recurring_contract].to_s &lt;&lt;
+                             parameters[:allowed_methods].to_s   &lt;&lt; parameters[:blocked_methods].to_s    &lt;&lt;
+                             parameters[:shopper_statement].to_s &lt;&lt; parameters[:billing_address_type].to_s
     end
 
+    def self.calculate_signature(parameters)
+       Adyen::Encoding.hmac_base64(parameters.delete(:shared_secret), calculate_signature_string(parameters))
+    end
+
+    ######################################################
+    # REDIRECT SIGNATURE CHECKING
+    ######################################################
+
     def self.redirect_signature_string(params)
       params[:authResult].to_s + params[:pspReference].to_s + params[:merchantReference].to_s + params[:skinCode].to_s
     end</diff>
      <filename>lib/adyen/form.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,8 @@ require &quot;#{File.dirname(__FILE__)}/spec_helper.rb&quot;
 describe Adyen::Form do
 
   before(:all) do
-    Adyen::Form.add_skin(:testing, '4aD37dJA', 'Kah942*$7sdp0)')
+    Adyen::Form.register_skin(:testing, '4aD37dJA', 'Kah942*$7sdp0)')
+    Adyen::Form.default_parameters[:merchant_account] = 'TestMerchant'
   end
 
   describe 'Action URLs' do
@@ -73,7 +74,7 @@ describe Adyen::Form do
     before(:each) do
       @attributes = { :currency_code =&gt; 'GBP', :payment_amount =&gt; 10000, :ship_before_date =&gt; Date.today,
         :merchant_reference =&gt; 'Internet Order 12345', :skin =&gt; :testing,
-        :merchant_account =&gt; 'TestMerchant', :session_validity =&gt; 1.hour.from_now }
+        :session_validity =&gt; 1.hour.from_now }
 
       @redirect_url = Adyen::Form.redirect_url(@attributes)
     end
@@ -100,7 +101,7 @@ describe Adyen::Form do
     before(:each) do
       @attributes = { :currency_code =&gt; 'GBP', :payment_amount =&gt; 10000, :ship_before_date =&gt; Date.today,
         :merchant_reference =&gt; 'Internet Order 12345', :skin =&gt; :testing,
-        :merchant_account =&gt; 'TestMerchant', :session_validity =&gt; 1.hour.from_now }
+        :session_validity =&gt; 1.hour.from_now }
     end
 
     it &quot;should generate a valid payment form&quot; do
@@ -115,37 +116,36 @@ describe Adyen::Form do
 
     before(:each) do
 
-      @attributes = { :currency_code =&gt; 'GBP', :payment_amount =&gt; 10000,
+      @parameters = { :currency_code =&gt; 'GBP', :payment_amount =&gt; 10000,
         :ship_before_date =&gt; '2007-10-20', :merchant_reference =&gt; 'Internet Order 12345',
-        :skin =&gt; :testing, :merchant_account =&gt; 'TestMerchant',
-        :session_validity =&gt; '2007-10-11T11:00:00Z' }
+        :skin =&gt; :testing, :session_validity =&gt; '2007-10-11T11:00:00Z' }
 
-      Adyen::Form.do_attribute_transformations!(@attributes)
+      Adyen::Form.do_parameter_transformations!(@parameters)
     end
 
     it &quot;should construct the signature string correctly&quot; do
-      signature_string = Adyen::Form.calculate_signature_string(@attributes)
+      signature_string = Adyen::Form.calculate_signature_string(@parameters)
       signature_string.should eql(&quot;10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Z&quot;)
     end
     
     it &quot;should calculate the signature correctly&quot; do
-      signature = Adyen::Form.calculate_signature(@attributes)
+      signature = Adyen::Form.calculate_signature(@parameters)
       signature.should eql('x58ZcRVL1H6y+XSeBGrySJ9ACVo=')
     end
 
     it &quot;should calculate the signature correctly for a recurring payment&quot; do
       # Add the required recurrent payment attributes
-      @attributes.merge!(:recurring_contract =&gt; 'DEFAULT', :shopper_reference =&gt; 'grasshopper52', :shopper_email =&gt; 'gras.shopper@somewhere.org')
+      @parameters.merge!(:recurring_contract =&gt; 'DEFAULT', :shopper_reference =&gt; 'grasshopper52', :shopper_email =&gt; 'gras.shopper@somewhere.org')
 
-      signature_string = Adyen::Form.calculate_signature_string(@attributes)
+      signature_string = Adyen::Form.calculate_signature_string(@parameters)
       signature_string.should eql(&quot;10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Zgras.shopper@somewhere.orggrasshopper52DEFAULT&quot;)
     end
 
     it &quot;should calculate the signature correctly for a recurring payment&quot; do
       # Add the required recurrent payment attributes
-      @attributes.merge!(:recurring_contract =&gt; 'DEFAULT', :shopper_reference =&gt; 'grasshopper52', :shopper_email =&gt; 'gras.shopper@somewhere.org')
+      @parameters.merge!(:recurring_contract =&gt; 'DEFAULT', :shopper_reference =&gt; 'grasshopper52', :shopper_email =&gt; 'gras.shopper@somewhere.org')
 
-      signature = Adyen::Form.calculate_signature(@attributes)
+      signature = Adyen::Form.calculate_signature(@parameters)
       signature.should eql('F2BQEYbE+EUhiRGuPtcD16Gm7JY=')
     end
   end</diff>
      <filename>spec/form_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>874bbd84a0f668afcd9c84df0fb9a6277879f120</id>
    </parent>
  </parents>
  <author>
    <name>Willem van Bergen</name>
    <email>willem@vanbergen.org</email>
  </author>
  <url>http://github.com/wvanbergen/adyen/commit/d688f16a1b8e89292260456e1c15fa7a6e933f6f</url>
  <id>d688f16a1b8e89292260456e1c15fa7a6e933f6f</id>
  <committed-date>2009-10-21T08:18:33-07:00</committed-date>
  <authored-date>2009-10-21T08:18:33-07:00</authored-date>
  <message>Added default arguments to Adyen::Form, and did some renaming of method names.</message>
  <tree>4a5d2d5e9fe2a57a0dba3d464b5f7595f90ce1a6</tree>
  <committer>
    <name>Willem van Bergen</name>
    <email>willem@vanbergen.org</email>
  </committer>
</commit>
