Class: AbtainBilling::Billing::Integrations::Chronopay::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/abtain_billing/billing/integrations/chronopay/helper.rb

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

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.



8
9
10
11
12
# File 'lib/abtain_billing/billing/integrations/chronopay/helper.rb', line 8

def initialize(order, , options = {})
  super
  add_field('cb_type', 'p')
  add_field('language', 'EN')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AbtainBilling::Billing::Integrations::Helper

Instance Method Details

#billing_address(mapping = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/abtain_billing/billing/integrations/chronopay/helper.rb', line 44

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 
end