lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.107.2 vs lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.107.3
- old
+ new
@@ -228,17 +228,18 @@
end
def add_address_and_customer_info(xml, options)
billing_address = options[:billing_address] || options[:address]
shipping_address = options[:shipping_address]
+ ipv4_address = ipv4?(options[:ip]) ? options[:ip] : nil
- return unless billing_address || shipping_address || options[:customer] || options[:invoice] || options[:ip]
+ return unless billing_address || shipping_address || options[:customer] || options[:invoice] || ipv4_address
xml.tag! 'tssinfo' do
xml.tag! 'custnum', options[:customer] if options[:customer]
xml.tag! 'prodid', options[:invoice] if options[:invoice]
- xml.tag! 'custipaddress', options[:ip] if options[:ip]
+ xml.tag! 'custipaddress', options[:ip] if ipv4_address
if billing_address
xml.tag! 'address', 'type' => 'billing' do
xml.tag! 'code', format_address_code(billing_address)
xml.tag! 'country', billing_address[:country]
@@ -366,9 +367,14 @@
end
end
def sanitize_order_id(order_id)
order_id.to_s.gsub(/[^a-zA-Z0-9\-_]/, '')
+ end
+
+ def ipv4?(ip_address)
+ return false if ip_address.nil?
+ !!ip_address[/\A\d+\.\d+\.\d+\.\d+\z/]
end
end
end
end