Method: OffsitePayments::Integrations::Chronopay::Helper#billing_address

Defined in:
lib/offsite_payments/integrations/chronopay.rb

#billing_address(mapping = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/offsite_payments/integrations/chronopay.rb', line 81

def billing_address(mapping = {})
  # Gets the country code in the appropriate format or returns what we were given
  # The appropriate format for Chronopay is the alpha 3 country code
  country_code = lookup_country_code(mapping.delete(:country))
  add_field(mappings[:billing_address][:country], country_code)

  countries_with_supported_states = ['USA', 'CAN']
  if !countries_with_supported_states.include?(country_code)
    mapping.delete(:state)
    add_field(mappings[:billing_address][:state], 'XX')
  end
  mapping.each do |k, v|
    field = mappings[:billing_address][k]
    add_field(field, v) unless field.nil?
  end
  add_field('language', checkout_language_from_country(country_code))
end