require File.dirname(__FILE__) + "/../test_helper" class AvsTest < Test::Unit::TestCase def test_packing_to_cc_verification_str1 tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => nil, :avs_po_box => nil, :avs_postal_code => '902101234') r = EWS::Transaction::Request.new(tx_params) assert_equal '1234567LOUGHEEDHIGHW|902101234', r.cc_verification_str1 tx_params = basic_params.merge(:avs_test_flag => 'W', :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => '12', :avs_po_box => nil, :avs_postal_code => '902101234') r = EWS::Transaction::Request.new(tx_params) assert_equal 'W1234567LOUGHEEDHIGHW12|902101234', r.cc_verification_str1 end def test_street_address_trumps_po_box tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => nil, :avs_po_box => 'P.O.BOX24356', :avs_postal_code => '902101234') r = EWS::Transaction::Request.new(tx_params) assert_equal '1234567LOUGHEEDHIGHW|902101234', r.cc_verification_str1 end def test_encodes_for_paymentech tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => nil, :avs_po_box => nil, :avs_postal_code => '902101234').merge(CHASE_BASIC_AUTH) r = EWS::Transaction::Request.new(tx_params) assert_equal '1234567LOUGHEEDHIGHW|902101234', r.cc_verification_str1 resp = EWS::Transporter.new(LOCATION).submit(r) assert_equal r.cc_verification_str1, resp.cc_verification_str1 end def test_uses_default_avs_string tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => nil, :avs_po_box => nil, :avs_postal_code => '902101234').merge(EMERGIS_BASIC_AUTH) r = EWS::Transaction::Request.new(tx_params) resp = EWS::Transporter.new(LOCATION).submit(r) assert_equal '1234567LOUGHEEDHIGHW902101234', resp.cc_verification_str1 end def test_space_with_numerals_for_tsys transporter = EWS::Transporter.new(LOCATION) # should put space between numeral and zip code for Tsys tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => nil, :avs_unit_no => nil, :avs_po_box => 'P.O.BOX24356', :avs_postal_code => '902101234').merge(VITAL_BASIC_AUTH) r = EWS::Transaction::Request.new(tx_params) resp = transporter.submit(r) assert_equal 'P.O.BOX24356 902101234', resp.cc_verification_str1 # should not put space if no numerals for Tsys tx_params = basic_params.merge(:avs_test_flag => nil, :avs_street_address => '1234567LOUGHEEDHIGHW', :avs_unit_no => nil, :avs_po_box => nil, :avs_postal_code => '902101234').merge(EMERGIS_BASIC_AUTH) r = EWS::Transaction::Request.new(tx_params) resp = transporter.submit(r) assert_equal '1234567LOUGHEEDHIGHW902101234', resp.cc_verification_str1 end end