From 5b88f63f6e98dab10a97d113115f6a44596aa013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Koch?= Date: Wed, 30 Mar 2011 00:30:54 +0200 Subject: [PATCH 1/3] fixed 'The totals of the cart item amounts do not match order amounts.' error with patch http://pastie.org/1731543 --- app/controllers/checkout_controller_decorator.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/checkout_controller_decorator.rb b/app/controllers/checkout_controller_decorator.rb index cc78b68..b412c1c 100644 --- a/app/controllers/checkout_controller_decorator.rb +++ b/app/controllers/checkout_controller_decorator.rb @@ -150,6 +150,7 @@ CheckoutController.class_eval do #need to force checkout to complete state until @order.state == "complete" if @order.next! + @order.update! state_callback(:after) end end @@ -226,7 +227,7 @@ CheckoutController.class_eval do { :name => item.variant.product.name, :description => item.variant.product.description[0..120], :sku => item.variant.sku, - :qty => item.quantity, + :quantity => item.quantity, :amount => price, :weight => item.variant.weight, :height => item.variant.height, @@ -239,7 +240,7 @@ CheckoutController.class_eval do { :name => credit.label, :description => credit.label, :sku => credit.id, - :qty => 1, + :quantity => 1, :amount => (credit.amount*100).to_i } end end @@ -248,7 +249,7 @@ CheckoutController.class_eval do credits.compact! if credits.present? items.concat credits - credits_total = credits.map {|i| i[:amount] * i[:qty] }.sum + credits_total = credits.map {|i| i[:amount] * i[:quantity] }.sum end opts = { :return_url => request.protocol + request.host_with_port + "/orders/#{order.number}/checkout/paypal_confirm?payment_method_id=#{payment_method}", From 228e341e581a3bf16c22fce622260e51562b587a Mon Sep 17 00:00:00 2001 From: curlyheads Date: Sat, 16 Apr 2011 14:37:01 +0200 Subject: [PATCH 2/3] fixed correct tax amount display on PayPal site, tax and shipping displayed seperately TODO: tax should be set differently joshnuss: fixed logo image url passed to paypal joshnuss: logo image should use Spree::Config setting joshnuss: save bill address during checkout if it is empty schustafa: Product descriptions can be nil without disrupting checkout. --- app/controllers/checkout_controller_decorator.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/checkout_controller_decorator.rb b/app/controllers/checkout_controller_decorator.rb index b412c1c..356ca3f 100644 --- a/app/controllers/checkout_controller_decorator.rb +++ b/app/controllers/checkout_controller_decorator.rb @@ -88,6 +88,7 @@ CheckoutController.class_eval do order_ship_address.save! @order.ship_address = order_ship_address + @order.bill_address = order_ship_address unless @order.bill_address end @order.save @@ -201,7 +202,7 @@ CheckoutController.class_eval do { :description => "Goods from #{Spree::Config[:site_name]}", # site details... #:page_style => "foobar", # merchant account can set named config - :header_image => "https://#{Spree::Config[:site_name]}/images/logo.png", + :header_image => "https://#{Spree::Config[:site_url]}#{Spree::Config[:logo]}", :background_color => "ffffff", # must be hex only, six chars :header_background_color => "ffffff", :header_border_color => "ffffff", @@ -225,7 +226,7 @@ CheckoutController.class_eval do items = order.line_items.map do |item| price = (item.price * 100).to_i # convert for gateway { :name => item.variant.product.name, - :description => item.variant.product.description[0..120], + :description => (item.variant.product.description[0..120] if item.variant.product.description), :sku => item.variant.sku, :quantity => item.quantity, :amount => price, @@ -261,7 +262,9 @@ CheckoutController.class_eval do :tax => ((order.adjustments.map { |a| a.amount if ( a.source_type == 'Order' && a.label == 'Tax') }.compact.sum) * 100 ).to_i, :shipping => ((order.adjustments.map { |a| a.amount if a.source_type == 'Shipment' }.compact.sum) * 100 ).to_i, :money => (order.total * 100 ).to_i } - + + # add correct tax amount by subtracting subtotal and shipping otherwise tax = 0 -> need to check adjustments.map + opts[:tax] = (order.total*100).to_i - opts.slice(:subtotal, :shipping).values.sum if stage == "checkout" opts[:handling] = 0 From 54db71773e72f3c857bd175e9ce547e005940a06 Mon Sep 17 00:00:00 2001 From: curlyheads Date: Tue, 28 Jun 2011 21:22:02 +0200 Subject: [PATCH 3/3] replaced request.protocol with protocol string --- app/controllers/checkout_controller_decorator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/checkout_controller_decorator.rb b/app/controllers/checkout_controller_decorator.rb index 356ca3f..36c4eee 100644 --- a/app/controllers/checkout_controller_decorator.rb +++ b/app/controllers/checkout_controller_decorator.rb @@ -253,7 +253,8 @@ CheckoutController.class_eval do credits_total = credits.map {|i| i[:amount] * i[:quantity] }.sum end - opts = { :return_url => request.protocol + request.host_with_port + "/orders/#{order.number}/checkout/paypal_confirm?payment_method_id=#{payment_method}", + opts = { #:return_url => request.protocol + request.host_with_port + "/orders/#{order.number}/checkout/paypal_confirm?payment_method_id=#{payment_method}", + :return_url => "http://" + request.host_with_port + "/orders/#{order.number}/checkout/paypal_confirm?payment_method_id=#{payment_method}", :cancel_return_url => "http://" + request.host_with_port + "/orders/#{order.number}/edit", :order_id => order.number, :custom => order.number,