Module: SolidusBraintree::CountryMapper

Extended by:
ActiveSupport::Concern
Included in:
TransactionAddress
Defined in:
lib/solidus_braintree/country_mapper.rb

Constant Summary collapse

USA_VARIANTS =
[
  "the united states of america",
  "united states of america",
  "the united states",
  "united states",
  "us of a",
  "u.s.a.",
  "usa",
  "u.s.",
  "us"
].freeze
CANADA_VARIANTS =
[
  "canada",
  "ca"
].freeze
COUNTRY_MAP =

Generates a hash mapping each variant of the country name to the same ISO ie: { “usa” => “US”, “united states” => “US”, “canada” => “CA”, … }

{
  USA_VARIANTS => "US",
  CANADA_VARIANTS => "CA"
}.flat_map { |variants, iso| variants.map { |v| [v, iso] } }.to_h