lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.117.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.118.0

- old
+ new

@@ -254,23 +254,34 @@ response.params['reasonCode'] == '102' end private - # Create all address hash key value pairs so that we still function if we - # were only provided with one or two of them or even none + # Create all required address hash key value pairs + # If a value of nil is received, that value will be passed on to the gateway and will not be replaced with a default value + # Billing address fields received without an override value or with an empty string value will be replaced with the default_address values def setup_address_hash(options) default_address = { address1: 'Unspecified', city: 'Unspecified', state: 'NC', zip: '00000', country: 'US' } submitted_address = options[:billing_address] || options[:address] || default_address - options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| submitted.blank? ? default : submitted } + options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) } options[:shipping_address] = options[:shipping_address] || {} + end + + def check_billing_field_value(default, submitted) + if submitted.nil? + nil + elsif submitted.blank? + default + else + submitted + end end def build_auth_request(money, creditcard_or_reference, options) xml = Builder::XmlMarkup.new indent: 2 add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)