<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/payments/_billing_address_form.erb</filename>
    </added>
    <added>
      <filename>app/views/payments/_contact_information_form.erb</filename>
    </added>
    <added>
      <filename>app/views/payments/_credit_card_form.erb</filename>
    </added>
    <added>
      <filename>app/views/payments/new.iphone.erb</filename>
    </added>
    <added>
      <filename>lib/countries.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,15 +1,25 @@
 class PaymentsController &lt; ApplicationController
+  skip_before_filter :redirect_to_iphone
+  acts_as_iphone_controller
+  
+  def new
+    @payment_authorizer = PaymentAuthorizer.new
+  end
+  
   def attempt
-    payment_params = params[:payment_authorizer]
+    payment_params = params[:payment_authorizer].merge(params[:date])
     @payment_authorizer = PaymentAuthorizer.new(payment_params)
     amount = params[:donation_amount_in_cents].to_i
 
     # TODO: create new model &amp; save off transaction ID, name, email, payment amount
 
-    if amount &gt; 0 &amp;&amp; @payment_authorizer.attempt(amount)
-        render :template =&gt; &quot;receipt&quot;
+    if amount &lt;= 0
+      @error_message = &quot;Your donation amount seems to be incorrect. Please try again.&quot;
+      render :action =&gt; &quot;new&quot;
+    elsif @payment_authorizer.attempt(amount)
+      render :action =&gt; &quot;receipt&quot;
     else
-      render :template =&gt; &quot;/donations/new&quot;
+      render :action =&gt; &quot;new&quot;
     end
   end
 end</diff>
      <filename>app/controllers/payments_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -36,7 +36,9 @@ class PaymentAuthorizer &lt; ActiveValidations::Base
   end
   
   def credit_card
-    return ActiveMerchant::Billing::CreditCard.new(:first_name =&gt; @first_name, :last_name =&gt; @last_name, :number =&gt; @credit_card_number, :month =&gt; @expiration_month,
-                                                                                            :year =&gt; @expiration_year, :verification_value =&gt; @card_security_code)
+    return ActiveMerchant::Billing::CreditCard.new(
+      :first_name =&gt; @first_name, :last_name =&gt; @last_name, 
+      :number =&gt; @credit_card_number, :verification_value =&gt; @card_security_code,
+      :month =&gt; @expiration_month, :year =&gt; @expiration_year)
   end
 end
\ No newline at end of file</diff>
      <filename>app/models/payment_authorizer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,2 @@
 &lt;h1&gt;Welcome to iPhone Donations&lt;/h1&gt;
-&lt;%= link_to_external &quot;Go to standard page&quot;, {:controller =&gt; &quot;donations&quot;, :action =&gt; &quot;view_full_site&quot;} %&gt;
\ No newline at end of file
+&lt;%= link_to_external &quot;Go to standard page&quot;, {:controller =&gt; &quot;donations&quot;, :action =&gt; &quot;view_full_site&quot;} %&gt;</diff>
      <filename>app/views/donations/index.iphone.erb</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,7 @@ ActionController::Routing::Routes.draw do |map|
   # Note: These default routes make all actions in every controller accessible via GET requests. You should
   # consider removing the them or commenting them out if you're using named routes and resources.
 
+  map.connect 'cms/:controller/:action/:id'
   map.connect 'cms/donations', :controller =&gt; 'donations', :action =&gt; 'index'
   map.connect 'cms/donations/view_full_site', :controller =&gt; 'donations', :action =&gt; &quot;view_full_site&quot;
   map.routes_for_bcms_blog</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,13 +7,13 @@ describe PaymentsController do
   end
 
   it &quot;should create the payment_authorizer&quot; do
-    PaymentAuthorizer.should_receive(:new).with(HashWithIndifferentAccess.new({:param_one =&gt; &quot;value&quot;})).and_return(@payment_authorizer)
-
-    post :attempt, :payment_authorizer =&gt; {:param_one =&gt; &quot;value&quot;}
+    PaymentAuthorizer.should_receive(:new).with(HashWithIndifferentAccess.new({:param_one =&gt; &quot;value&quot;, :year =&gt; &quot;2020&quot;})).and_return(@payment_authorizer)
+    
+    post :attempt, :payment_authorizer =&gt; {:param_one =&gt; &quot;value&quot;}, :date =&gt; {:year =&gt; &quot;2020&quot;}
   end
 
   it &quot;should assign the payment_gateway&quot; do
-    post :attempt, :payment_authorizer =&gt; {}
+    post :attempt, :payment_authorizer =&gt; {}, :date =&gt; {}
 
     assigns[:payment_authorizer].should == @payment_authorizer
   end
@@ -21,21 +21,22 @@ describe PaymentsController do
   it &quot;should attempt payment if the donation is greater than 0&quot; do
     @payment_authorizer.should_receive(:attempt).with(5000)
 
-    post :attempt, :payment_authorizer =&gt; {}, :donation_amount_in_cents =&gt; 5000
+    post :attempt, :payment_authorizer =&gt; {}, :date =&gt; {}, :donation_amount_in_cents =&gt; 5000
   end
 
   it &quot;should not attempt donation of zero or lower&quot; do
     @payment_authorizer.should_not_receive(:attempt)
 
-    post :attempt, :payment_authorizer =&gt; {}, :donation_amount_in_cents =&gt; 0
+    post :attempt, :payment_authorizer =&gt; {}, :date =&gt; {}, :donation_amount_in_cents =&gt; 0
 
-    response.should render_template(&quot;/donations/new&quot;)
+    assigns[:error_message].should_not be_blank
+    response.should render_template(&quot;new&quot;)
   end
 
   it &quot;should render the receipt page if the payment is successful&quot; do
     @payment_authorizer.stub!(:attempt).and_return(true)
 
-    post :attempt, :payment_authorizer =&gt; {}, :donation_amount_in_cents =&gt; 5000
+    post :attempt, :payment_authorizer =&gt; {}, :date =&gt; {}, :donation_amount_in_cents =&gt; 5000
 
     response.should render_template(&quot;receipt&quot;)
   end
@@ -43,8 +44,36 @@ describe PaymentsController do
   it &quot;should render the donations page if the payment is unsuccessful&quot; do
     @payment_authorizer.stub!(:attempt).and_return(false)
 
-    post :attempt, :payment_authorizer =&gt; {}, :donation_amount_in_cents =&gt; 5000
+    post :attempt, :payment_authorizer =&gt; {}, :date =&gt; {}, :donation_amount_in_cents =&gt; 5000
 
-    response.should render_template(&quot;/donations/new&quot;)
+    response.should render_template(&quot;new&quot;)
+  end
+  
+  describe &quot;using Mobile Safari&quot; do
+    before(:each) do
+      request.user_agent = &quot;Mobile Safari&quot;
+    end
+
+    it &quot;should show the proper iPhone view&quot; do
+      get :new
+    
+      response.should render_template(&quot;new.iphone.erb&quot;)
+    end
+  
+    it &quot;should have a payment authorizer when starting payment&quot; do
+      get :new
+    
+      assigns[:payment_authorizer].should == @payment_authorizer
+    end
+    
+    # it &quot;should have countries&quot; do
+    #   COUNTRIES.should_not be_nil
+    #   COUNTRIES.should be_instance_of(Array)
+    # 
+    #   get :new
+    # 
+    #   response.should be_success
+    #   response.include?(&quot;United States&quot;).should == true
+    # end
   end
 end</diff>
      <filename>spec/controllers/payments_controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>36462d953b6af1e50c4900615b1e8d5dd1c95d98</id>
    </parent>
  </parents>
  <author>
    <name>Colin Jones</name>
    <email>trptcolin@gmail.com</email>
  </author>
  <url>http://github.com/agiletoolkit/mano_browercms/commit/e8a799597c74cc907b58d642c97a5acc2ae1b698</url>
  <id>e8a799597c74cc907b58d642c97a5acc2ae1b698</id>
  <committed-date>2009-08-26T06:17:01-07:00</committed-date>
  <authored-date>2009-08-26T06:17:01-07:00</authored-date>
  <message>payments controller and simple view; no API keys introduced yet, so payment attempt is not quite ready</message>
  <tree>dd94d2124f921cb3a0933154e76f947c509efe60</tree>
  <committer>
    <name>Colin Jones</name>
    <email>trptcolin@gmail.com</email>
  </committer>
</commit>
