lib/active_merchant/billing/integrations/helper.rb in activemerchant-1.1.0 vs lib/active_merchant/billing/integrations/helper.rb in activemerchant-1.2.0
- old
+ new
@@ -5,10 +5,15 @@
attr_reader :fields
class_inheritable_accessor :service_url
class_inheritable_hash :mappings
class_inheritable_accessor :country_format
self.country_format = :alpha2
+
+ # The application making the calls to the gateway
+ # Useful for things like the PayPal build notation (BN) id fields
+ class_inheritable_accessor :application_id
+ self.application_id = 'ActiveMerchant'
def initialize(order, account, options = {})
options.assert_valid_keys([:amount, :currency, :test])
@fields = {}
self.order = order
@@ -47,11 +52,13 @@
end
private
def add_address(key, params)
+ return if mappings[key].nil?
+
code = lookup_country_code(params.delete(:country))
- add_field(mappings[key][:country], code) if mappings[key]
+ add_field(mappings[key][:country], code)
add_fields(key, params)
end
def lookup_country_code(name_or_code)
country = Country.find(name_or_code)