paypal: Do no guess the state as this can cuase validation errors
States are not common to use for addresses in Germany, a customer was putting 'DE' into the state, this is the abbreviation for Delaware. When trying to save the Address record the validation failed as the country of the address and the country of the state do not match at all. Fix it by always using the text form for addresses returned by PayPal. Make sure that the state is never blank.
This commit is contained in:
parent
d2db33ad1d
commit
143ffe4da1
|
@ -88,15 +88,11 @@ module Spree
|
|||
# phone is currently blanked in AM's PPX response lib
|
||||
:phone => @ppx_details.params["phone"] || "(not given)"
|
||||
|
||||
state = Spree::State.find_by_abbr(ship_address["state"].upcase) if ship_address["state"].present?
|
||||
if state
|
||||
order_ship_address.state = state
|
||||
else
|
||||
order_ship_address.state_name = ship_address["state"]
|
||||
end
|
||||
# Do not guess the state as it might be a state from the wrong country
|
||||
order_ship_address.state_name = ship_address["state"]
|
||||
|
||||
# Paypal requires us to have a state for US and on some states it is empty
|
||||
if order_ship_address.state_name.nil? && order_ship_address.state.nil?
|
||||
if order_ship_address.state_name.nil? || order_ship_address.state_name.empty?
|
||||
order_ship_address.state_name = "N/A"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue