set state_name for shipping address if nothing is found for the given state
This commit is contained in:
parent
fa6d87f465
commit
74265c7525
|
@ -80,6 +80,7 @@ module Spree::PaypalExpress
|
||||||
def paypal_checkout
|
def paypal_checkout
|
||||||
# need build etc? at least to finalise the total?
|
# need build etc? at least to finalise the total?
|
||||||
gateway = paypal_gateway
|
gateway = paypal_gateway
|
||||||
|
order.update_totals
|
||||||
|
|
||||||
opts = all_opts(@order)
|
opts = all_opts(@order)
|
||||||
response = gateway.setup_authorization(opts[:money], opts)
|
response = gateway.setup_authorization(opts[:money], opts)
|
||||||
|
@ -104,15 +105,21 @@ module Spree::PaypalExpress
|
||||||
order.checkout.special_instructions = info.params["note"]
|
order.checkout.special_instructions = info.params["note"]
|
||||||
|
|
||||||
ship_address = info.address
|
ship_address = info.address
|
||||||
order_ship_address = Address.create :firstname => info.params["first_name"],
|
order_ship_address = Address.new :firstname => info.params["first_name"],
|
||||||
:lastname => info.params["last_name"],
|
:lastname => info.params["last_name"],
|
||||||
:address1 => ship_address["address1"],
|
:address1 => ship_address["address1"],
|
||||||
:address2 => ship_address["address2"],
|
:address2 => ship_address["address2"],
|
||||||
:city => ship_address["city"],
|
:city => ship_address["city"],
|
||||||
:state => State.find_by_name(ship_address["state"]),
|
:country => Country.find_by_iso(ship_address["country"]),
|
||||||
:country => Country.find_by_iso(ship_address["country"]),
|
:zipcode => ship_address["zip"],
|
||||||
:zipcode => ship_address["zip"],
|
:phone => ship_address["phone"] || "(not given)"
|
||||||
:phone => ship_address["phone"] || "(not given)"
|
|
||||||
|
if (state = State.find_by_name(ship_address["state"])
|
||||||
|
order_ship_address.state = state
|
||||||
|
else
|
||||||
|
order_ship_address.state_name = ship_address["state"]
|
||||||
|
end
|
||||||
|
order_ship_address.save!
|
||||||
|
|
||||||
order.checkout.update_attributes :ship_address => order_ship_address,
|
order.checkout.update_attributes :ship_address => order_ship_address,
|
||||||
:shipping_method => ShippingMethod.first # TODO: refine/choose
|
:shipping_method => ShippingMethod.first # TODO: refine/choose
|
||||||
|
|
Loading…
Reference in New Issue