<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20081225222501_add_address_fields.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -37,7 +37,7 @@ task :stats =&gt; &quot;spec:statsetup&quot;
 desc &quot;Run all specs in spec directory&quot;
 Spec::Rake::SpecTask.new(:spec) do |t|
   t.spec_opts = ['--options', &quot;\&quot;#{extension_root}/spec/spec.opts\&quot;&quot;]
-  t.spec_files = FileList['spec/**/*_spec.rb']
+  t.spec_files = FileList[&quot;#{extension_root}/spec/**/*_spec.rb&quot;]
 end
 
 namespace :spec do</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -80,7 +80,7 @@ class Notification &lt; ActiveRecord::Base
       self.items_total = self.items_price + self.items_shipping_price + self.items_extras
       # Verify if the total order value in the notification is the same as in the order.
       unless self.items_total == self.order.total
-        errors.add(:order, &quot;total n&#227;o confere com a notifica&#231;&#227;o, pedido: #{self.order.total}, notifica&#231;&#227;o: #{self.items_price}.&quot;)
+        errors.add(:order, &quot;total n&#227;o confere com a notifica&#231;&#227;o, pedido: #{self.order.total}, notifica&#231;&#227;o: #{self.items_total}.&quot;)
       end
     end
   end
@@ -139,7 +139,7 @@ class Notification &lt; ActiveRecord::Base
     self.order = Order.find_by_number(self.Referencia)
 
     # Define the shipping type as defined by the store if nothing was received.
-    self.TipoFrete = &quot;FR&quot; if self.TipoFrete.empty?
+    self.TipoFrete = &quot;FR&quot; if self.TipoFrete.nil? || self.TipoFrete.empty? 
     
     return true
   end</diff>
      <filename>app/models/notification.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,7 +28,7 @@ module Spree #:nodoc:
           
         order.line_items.each_with_index do |item, index|
           data_to_transmit.merge!(
-            &quot;item_id_#{index + 1}&quot;    =&gt; item.variant.product.sku,
+            &quot;item_id_#{index + 1}&quot;    =&gt; item.variant.sku,
             &quot;item_descr_#{index + 1}&quot; =&gt; item.variant.product.name,
             &quot;item_quant_#{index + 1}&quot; =&gt; item.quantity.to_s,
             &quot;item_valor_#{index + 1}&quot; =&gt; (item.price*100).to_i.to_s
@@ -41,7 +41,6 @@ module Spree #:nodoc:
         end
 
         string = data_to_transmit.map {|k,v| &quot;#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}&quot; }.join('&amp;')
-      
       end
     
       module_function :data_to_send</diff>
      <filename>lib/spree/pagseguro/checkout_data.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,12 @@ class PsSpreeOwnCartExtension &lt; Spree::Extension
   url &quot;http://github.com/edmundo/spree-ps-spree-own-cart/tree/master&quot;
 
   def activate
+    Address.class_eval do
+      validates_presence_of :number
+      validates_presence_of :borough
+      validates_presence_of :area_code
+      validates_numericality_of :area_code, :integer_only =&gt; true
+    end
 
     # Add a partial for PagSeguro Payment txns
     Admin::OrdersController.class_eval do
@@ -31,20 +37,40 @@ class PsSpreeOwnCartExtension &lt; Spree::Extension
 #      end
 #    end
 
+    OrdersHelper.class_eval do
+      def to_iso(text)
+        Iconv.iconv('iso-8859-1', 'utf-8', text).to_s
+      end
+
+      def to_utf(text)
+        Iconv.iconv('utf-8', 'iso-8859-1', text).to_s
+      end
+    end
+
     OrdersController.class_eval do
+      before_filter :set_charset, :only =&gt; :transmit
+      def set_charset
+        headers[&quot;Content-Type&quot;] = &quot;text/html; charset=ISO-8859-1&quot;
+      end
+      
       include Spree::Pagseguro::PostsData
 
       before_filter :load_object, :only =&gt; [:checkout, :confirmation, :transmit, :finished]
       skip_before_filter :verify_authenticity_token, :only =&gt; [:transmit]
 
+#      skip_before_filter :verify_authenticity_token, :only =&gt; [:confirmation]
+
       def confirmation
         # Mark the order as &quot;ready to transmit&quot;
         if @order.state == &quot;shipment&quot;
           @order.next!
         end
+
       end
 
       def transmit
+        require 'iconv'
+
         if Spree::Pagseguro::Config[:always_use_sandbox] || RAILS_ENV == 'development'
           pagseguro_url = Spree::Pagseguro::Config[:sandbox_billing_url]
         else
@@ -64,20 +90,20 @@ class PsSpreeOwnCartExtension &lt; Spree::Extension
           session[:order_id] = nil
         end
 
-        payload = Spree::Pagseguro::CheckoutData.data_to_send(@order)
-              
-        # If we are waiting for payment response the checkout is complete
-        if object.checkout_complete
-          # Transmit the form to PagSeguro
-          if Spree::Pagseguro::Config[:always_use_sandbox] || RAILS_ENV == 'development'
-            response = post(pagseguro_url, payload, 'Content-Length' =&gt; &quot;#{payload.size}&quot;)
-          else
-            response = ssl_post(pagseguro_url, payload, 'Content-Length' =&gt; &quot;#{payload.size}&quot;)
-          end
-
-          # Render the payment screen.
-          render :inline =&gt; response
-        end
+#        payload = Spree::Pagseguro::CheckoutData.data_to_send(@order)
+
+#        # If we are waiting for payment response the checkout is complete
+#        if object.checkout_complete
+#          # Transmit the form to PagSeguro
+#          if Spree::Pagseguro::Config[:always_use_sandbox] || RAILS_ENV == 'development'
+#            response = post(pagseguro_url, payload, 'Content-Length' =&gt; &quot;#{payload.size}&quot;)
+#          else
+#            response = ssl_post(pagseguro_url, payload, 'Content-Length' =&gt; &quot;#{payload.size}&quot;)
+#          end
+
+#          render :inline =&gt; response
+#        end
+         render :layout =&gt; false
       end
 
       def finished</diff>
      <filename>ps_spree_own_cart_extension.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,13 +6,12 @@ module NotificationSpecHelper
     Spree::Pagseguro::Config.set({:account =&gt; &quot;test@example.com&quot;})
 
     order = mock_model(Order, :null_object =&gt; true)
-    order.stub!(:total).and_return(5.23 * 2)
+    order.stub!(:total).and_return((5.23 * 2) + 10.99) 
     {
       :VendedorEmail    =&gt; &quot;test@example.com&quot;,
       :TransacaoID      =&gt; &quot;123XYZ&quot;,
       :Referencia       =&gt; &quot;1&quot;,
       :TipoFrete        =&gt; &quot;FR&quot;,
-      :ValorFrete       =&gt; 10.99,
       :Anotacao         =&gt; &quot;Here goes some notes.&quot;,
       :DataTransacao    =&gt; &quot;01/01/2008 12:30:10&quot;,
       :TipoPagamento    =&gt; &quot;Cart&#227;o de Cr&#233;dito&quot;,
@@ -31,8 +30,8 @@ module NotificationSpecHelper
       :ProdDescricao_1  =&gt; &quot;Nothing&quot;,
       :ProdValor_1      =&gt; 5.23,
       :ProdQuantidade_1 =&gt; 2,
-      :ProdFrete_1      =&gt; 2.30,
-      :ProdExtras_1     =&gt; 1.20,
+      :ProdExtras_1     =&gt; 0,
+      :ProdFrete_1      =&gt; 10.99,
       :NumItens         =&gt; 1,
       :order            =&gt; order
     }
@@ -117,7 +116,7 @@ describe Notification do
     @notification.attributes = valid_notification_attributes
     @notification.order.stub!(:total).and_return(99)
     @notification.should_not be_valid
-    @notification.errors.full_messages.should include(&quot;#{'order'.intern.l('order').humanize} total n&#227;o confere com a notifica&#231;&#227;o, pedido: #{@notification.order.total}, notifica&#231;&#227;o: #{@notification.items_price}.&quot;)
+    @notification.errors.full_messages.should include(&quot;#{'order'.intern.l('order').humanize} total n&#227;o confere com a notifica&#231;&#227;o, pedido: #{@notification.order.total}, notifica&#231;&#227;o: #{@notification.items_total}.&quot;)
   end
 
 end</diff>
      <filename>spec/models/notification_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -68,18 +68,18 @@ describe PagseguroPayment do
         @pagseguro_payment.state.should == &quot;status_definition_expired&quot;
       end
 
+      # We cannot approve a payment that was never being done.
+      it &quot;should transition to payment_approved when called approve_payment&quot; do
+        @pagseguro_payment.approve_payment
+        @pagseguro_payment.state.should == &quot;payment_approved&quot;
+      end
+
       # We cannot cancel a payment that was never being done.
       it &quot;should not transition to payment_canceled when called cancel_payment&quot; do
         @pagseguro_payment.cancel_payment
         @pagseguro_payment.state.should == &quot;waiting_for_status_definition&quot;
       end
       
-      # We cannot approve a payment that was never being done.
-      it &quot;should not transition to payment_approved when called approve_payment&quot; do
-        @pagseguro_payment.approve_payment
-        @pagseguro_payment.state.should == &quot;waiting_for_status_definition&quot;
-      end
-
       # We cannot say the payment was credited in our gateway account if it was never being done.
       it &quot;should not transition to payment_completed when called complete_payment&quot; do
         @pagseguro_payment.complete_payment</diff>
      <filename>spec/models/pagseguro_payment_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,4 @@
 --colour
 --format
 specdoc
---loadby
-mtime
 --reverse</diff>
      <filename>spec/spec.opts</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>07923ed54b6ae75c8161ca86f9f37f00a0ec945f</id>
    </parent>
  </parents>
  <author>
    <name>Edmundo Valle Neto</name>
    <email>edmundo.vn@gmail.com</email>
  </author>
  <url>http://github.com/edmundo/spree-ps-spree-own-cart/commit/2be5cbefd256af78d35611a3defd4c7d46295961</url>
  <id>2be5cbefd256af78d35611a3defd4c7d46295961</id>
  <committed-date>2008-12-31T11:46:19-08:00</committed-date>
  <authored-date>2008-12-31T11:46:19-08:00</authored-date>
  <message>Changed the way address is handled and some charset conversions.</message>
  <tree>e9a9ba94f6c6e9db86346282a91e5c1eb51cdb4f</tree>
  <committer>
    <name>Edmundo Valle Neto</name>
    <email>edmundo.vn@gmail.com</email>
  </committer>
</commit>
