Class: OffsitePayments::Integrations::Chronopay::Helper
- Defined in:
- lib/offsite_payments/integrations/chronopay.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, #add_raw_html_field, #form_fields, #form_method, inherited, mapping, #raw_html_fields, #shipping_address, #test?
Methods included from MoneyCompatibility
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
46 47 48 49 |
# File 'lib/offsite_payments/integrations/chronopay.rb', line 46 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 OffsitePayments::Helper
Instance Method Details
#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 |