Merge pull request #5 from curlyheads/master
Various fixes and improvements for spree_paypal_express
This commit is contained in:
commit
a08a40b50b
|
@ -88,6 +88,7 @@ CheckoutController.class_eval do
|
||||||
order_ship_address.save!
|
order_ship_address.save!
|
||||||
|
|
||||||
@order.ship_address = order_ship_address
|
@order.ship_address = order_ship_address
|
||||||
|
@order.bill_address = order_ship_address unless @order.bill_address
|
||||||
end
|
end
|
||||||
@order.save
|
@order.save
|
||||||
|
|
||||||
|
@ -150,6 +151,7 @@ CheckoutController.class_eval do
|
||||||
#need to force checkout to complete state
|
#need to force checkout to complete state
|
||||||
until @order.state == "complete"
|
until @order.state == "complete"
|
||||||
if @order.next!
|
if @order.next!
|
||||||
|
@order.update!
|
||||||
state_callback(:after)
|
state_callback(:after)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -201,7 +203,7 @@ CheckoutController.class_eval do
|
||||||
{ :description => "Goods from #{Spree::Config[:site_name]}", # site details...
|
{ :description => "Goods from #{Spree::Config[:site_name]}", # site details...
|
||||||
|
|
||||||
#:page_style => "foobar", # merchant account can set named config
|
#: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
|
:background_color => "ffffff", # must be hex only, six chars
|
||||||
:header_background_color => "ffffff",
|
:header_background_color => "ffffff",
|
||||||
:header_border_color => "ffffff",
|
:header_border_color => "ffffff",
|
||||||
|
@ -227,7 +229,7 @@ CheckoutController.class_eval do
|
||||||
{ :name => item.variant.product.name,
|
{ :name => item.variant.product.name,
|
||||||
:description => (item.variant.product.description[0..120] if item.variant.product.description),
|
:description => (item.variant.product.description[0..120] if item.variant.product.description),
|
||||||
:sku => item.variant.sku,
|
:sku => item.variant.sku,
|
||||||
:qty => item.quantity,
|
:quantity => item.quantity,
|
||||||
:amount => price,
|
:amount => price,
|
||||||
:weight => item.variant.weight,
|
:weight => item.variant.weight,
|
||||||
:height => item.variant.height,
|
:height => item.variant.height,
|
||||||
|
@ -240,7 +242,7 @@ CheckoutController.class_eval do
|
||||||
{ :name => credit.label,
|
{ :name => credit.label,
|
||||||
:description => credit.label,
|
:description => credit.label,
|
||||||
:sku => credit.id,
|
:sku => credit.id,
|
||||||
:qty => 1,
|
:quantity => 1,
|
||||||
:amount => (credit.amount*100).to_i }
|
:amount => (credit.amount*100).to_i }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -249,10 +251,11 @@ CheckoutController.class_eval do
|
||||||
credits.compact!
|
credits.compact!
|
||||||
if credits.present?
|
if credits.present?
|
||||||
items.concat credits
|
items.concat credits
|
||||||
credits_total = credits.map {|i| i[:amount] * i[:qty] }.sum
|
credits_total = credits.map {|i| i[:amount] * i[:quantity] }.sum
|
||||||
end
|
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",
|
:cancel_return_url => "http://" + request.host_with_port + "/orders/#{order.number}/edit",
|
||||||
:order_id => order.number,
|
:order_id => order.number,
|
||||||
:custom => order.number,
|
:custom => order.number,
|
||||||
|
@ -261,7 +264,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,
|
: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,
|
:shipping => ((order.adjustments.map { |a| a.amount if a.source_type == 'Shipment' }.compact.sum) * 100 ).to_i,
|
||||||
:money => (order.total * 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"
|
if stage == "checkout"
|
||||||
opts[:handling] = 0
|
opts[:handling] = 0
|
||||||
|
|
Loading…
Reference in New Issue