Class: ActiveMerchant::Billing::Integrations::Chronopay::Helper
- Defined in:
- lib/active_merchant/billing/integrations/chronopay/helper.rb
Constant Summary collapse
- COUNTRIES_FOR_LANG =
All currently supported checkout languages:
es (Spanish) en (English) de (German) pt (Portuguese) lv (Latvian) cn1 (Chinese Version 1) cn2 (Chinese version 2) nl (Dutch) ru (Russian)
{ 'ES' => %w( AR BO CL CO CR CU DO EC SV GQ GT HN MX NI PA PY PE ES UY VE), 'DE' => %w( DE AT CH LI ), 'PT' => %w( AO BR CV GW MZ PT ST TL), 'RU' => %w( BY KG KZ RU ), 'LV' => %w( LV ), 'CN1' => %w( CN ), 'NL' => %w( NL ) }
- LANG_FOR_COUNTRY =
COUNTRIES_FOR_LANG.inject(Hash.new("EN")) do |memo, (lang, countries)| countries.each do |code| memo[code] = lang end memo end
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
- #billing_address(mapping = {}) ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
Methods inherited from Helper
#add_field, #add_fields, #form_fields, mapping, #shipping_address
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
36 37 38 39 |
# File 'lib/active_merchant/billing/integrations/chronopay/helper.rb', line 36 def initialize(order, account, = {}) super add_field('cb_type', 'p') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper
Instance Method Details
#billing_address(mapping = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/active_merchant/billing/integrations/chronopay/helper.rb', line 71 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 |