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

- old
+ new

@@ -518,13 +518,15 @@ xml.tag!('grandTotalAmount', localized_amount(money.to_i, options[:currency] || default_currency)) if include_grand_total end end def add_address(xml, payment_method, address, options, shipTo = false) + first_name, last_name = address_names(address[:name], payment_method) + xml.tag! shipTo ? 'shipTo' : 'billTo' do - xml.tag! 'firstName', payment_method.first_name if payment_method - xml.tag! 'lastName', payment_method.last_name if payment_method + xml.tag! 'firstName', first_name if first_name + xml.tag! 'lastName', last_name if last_name xml.tag! 'street1', address[:address1] xml.tag! 'street2', address[:address2] unless address[:address2].blank? xml.tag! 'city', address[:city] xml.tag! 'state', address[:state] xml.tag! 'postalCode', address[:zip] @@ -535,9 +537,19 @@ xml.tag! 'email', options[:email].presence || 'null@cybersource.com' xml.tag! 'ipAddress', options[:ip] unless options[:ip].blank? || shipTo xml.tag! 'driversLicenseNumber', options[:drivers_license_number] unless options[:drivers_license_number].blank? xml.tag! 'driversLicenseState', options[:drivers_license_state] unless options[:drivers_license_state].blank? end + end + + def address_names(address_name, payment_method) + names = split_names(address_name) + return names if names.any?(&:present?) + + [ + payment_method&.first_name, + payment_method&.last_name + ] end def add_creditcard(xml, creditcard) xml.tag! 'card' do xml.tag! 'accountNumber', creditcard.number