Skip to content

Commit

Permalink
Merge pull request #16 from ShopFelixGray/master
Browse files Browse the repository at this point in the history
Fix issue with State Lookup
  • Loading branch information
jkhaykin authored Apr 12, 2019
2 parents 3190860 + 8e6ee8f commit 6c330fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/spree/affirm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ def completion_route(order)

def generate_spree_address(affirm_address)
# find the state and country in spree
_state = Spree::State.find_by_abbr(affirm_address["address"]["region1_code"]) or
Spree::State.find_by_name(affirm_address["address"]["region1_code"])
_country = Spree::Country.find_by_iso3(affirm_address["address"]["country_code"]) or
Spree::Country.find_by_iso(affirm_address["address"]["country_code"])


_state = Spree::State.find_by(abbr: affirm_address["address"]["region1_code"], country: _country) or
Spree::State.find_by_abbr(affirm_address["address"]["region1_code"]) or
Spree::State.find_by_name(affirm_address["address"]["region1_code"])

# try to get the name from first and last
_firstname = affirm_address["name"]["first"] if affirm_address["name"]["first"].present?
_lastname = affirm_address["name"]["last"] if affirm_address["name"]["last"].present?
Expand Down

0 comments on commit 6c330fc

Please sign in to comment.