lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.38.1 vs lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.39.0
- old
+ new
@@ -32,11 +32,11 @@
}
self.money_format = :cents
self.default_currency = 'EUR'
self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ]
- self.supported_countries = [ 'IE', 'GB' ]
+ self.supported_countries = %w(IE GB FR BE NL LU IT)
self.homepage_url = 'http://www.realexpayments.com/'
self.display_name = 'Realex'
SUCCESS, DECLINED = "Successful", "Declined"
BANK_ERROR = REALEX_ERROR = "Gateway is in maintenance. Please try again later."
@@ -84,12 +84,15 @@
private
def commit(request)
response = parse(ssl_post(self.live_url, request))
- Response.new(response[:result] == "00", message_from(response), response,
- :test => response[:message] =~ /\[ test system \]/,
+ Response.new(
+ (response[:result] == "00"),
+ message_from(response),
+ response,
+ :test => (response[:message] =~ %r{\[ test system \]}),
:authorization => authorization_from(response),
:cvv_result => response[:cvnresult],
:avs_result => {
:street_match => response[:avspostcoderesponse],
:postal_match => response[:avspostcoderesponse]
@@ -185,18 +188,18 @@
xml.tag! 'prodid', options[:invoice] if options[:invoice]
xml.tag! 'custipaddress', options[:ip] if options[:ip]
if billing_address
xml.tag! 'address', 'type' => 'billing' do
- xml.tag! 'code', format_shipping_zip_code(billing_address[:zip])
+ xml.tag! 'code', format_address_code(billing_address)
xml.tag! 'country', billing_address[:country]
end
end
if shipping_address
xml.tag! 'address', 'type' => 'shipping' do
- xml.tag! 'code', format_shipping_zip_code(shipping_address[:zip])
+ xml.tag! 'code', format_address_code(shipping_address)
xml.tag! 'country', shipping_address[:country]
end
end
end
end
@@ -238,11 +241,12 @@
xml.tag! 'presind', (options['presind'] || (credit_card.verification_value? ? 1 : nil))
end
end
end
- def format_shipping_zip_code(zip)
- zip.to_s.gsub(/\W/, '')
+ def format_address_code(address)
+ code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
+ code.collect{|e| e.gsub(/\D/, "")}.reject{|e| e.empty?}.join("|")
end
def new_timestamp
Time.now.strftime('%Y%m%d%H%M%S')
end