class OffsitePayments::Integrations::Chronopay::Helper
Constants
- 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)
- LANG_FOR_COUNTRY
Public Class Methods
new(order, account, options = {})
click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/chronopay.rb, line 46 def initialize(order, account, options = {}) super add_field('cb_type', 'p') end
Public Instance Methods
billing_address(mapping = {})
click to toggle source
# 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
Private Instance Methods
checkout_language_from_country(country_code)
click to toggle source
cs2 cs3 decline_url
# File lib/offsite_payments/integrations/chronopay.rb, line 119 def checkout_language_from_country(country_code) country = ActiveMerchant::Country.find(country_code) short_code = country.code(:alpha2).to_s LANG_FOR_COUNTRY[short_code] rescue ActiveMerchant::InvalidCountryCodeError 'EN' end