lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.69.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.70.0
- old
+ new
@@ -553,18 +553,19 @@
def add_billing_address(xml, payment_source, options)
address = options[:billing_address] || options[:address] || {}
xml.billTo do
first_name, last_name = names_from(payment_source, address, options)
+ state = state_from(address, options)
full_address = "#{address[:address1]} #{address[:address2]}".strip
xml.firstName(truncate(first_name, 50)) unless empty?(first_name)
xml.lastName(truncate(last_name, 50)) unless empty?(last_name)
xml.company(truncate(address[:company], 50)) unless empty?(address[:company])
xml.address(truncate(full_address, 60))
xml.city(truncate(address[:city], 40))
- xml.state(empty?(address[:state]) ? 'n/a' : truncate(address[:state], 40))
+ xml.state(truncate(state, 40))
xml.zip(truncate((address[:zip] || options[:zip]), 20))
xml.country(truncate(address[:country], 60))
xml.phoneNumber(truncate(address[:phone], 25)) unless empty?(address[:phone])
xml.faxNumber(truncate(address[:fax], 25)) unless empty?(address[:fax])
end
@@ -709,9 +710,17 @@
if payment_source && !payment_source.is_a?(PaymentToken) && !payment_source.is_a?(String)
first_name, last_name = split_names(address[:name])
[(payment_source.first_name || first_name), (payment_source.last_name || last_name)]
else
[options[:first_name], options[:last_name]]
+ end
+ end
+
+ def state_from(address, options)
+ if ["US", "CA"].include?(address[:country])
+ address[:state] || 'NC'
+ else
+ address[:state]
end
end
def headers
{ 'Content-Type' => 'text/xml' }