require File.dirname(__FILE__) + "/spec_helper" describe "AVS Request" do it "should pack AVS fields into cc_verification_str1" do 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) r.cc_verification_str1.should == '1234567LOUGHEEDHIGHW|902101234' 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) r.cc_verification_str1.should == 'W1234567LOUGHEEDHIGHW12|902101234' end it "should Prefer Street Address before P.O. Box" do 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) r.cc_verification_str1.should == '1234567LOUGHEEDHIGHW|902101234' end end describe "Submitting AVS Requests" do before :all do @transporter = EWS::Transporter.new(LOCATION) end it "should be Paymentech AVS string" do 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', :gateway_id => "AD0002-01", :password => "63d9934x") r = EWS::Transaction::Request.new(tx_params) r.cc_verification_str1.should == '1234567LOUGHEEDHIGHW|902101234' resp = @transporter.submit(r) r.cc_verification_str1.should == resp.cc_verification_str1 end it "should use default AVS string" do 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', :gateway_id => "AD0007-01", :password => "3uLi726f") r = EWS::Transaction::Request.new(tx_params) resp = @transporter.submit(r) resp.cc_verification_str1.should == '1234567LOUGHEEDHIGHW902101234' end it "should put space between numeral and zip code for Tsys" do 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', :gateway_id => "AD0001-01", :password => "8q53g4ef") r = EWS::Transaction::Request.new(tx_params) resp = @transporter.submit(r) resp.cc_verification_str1.should == 'P.O.BOX24356 902101234' end it "should not put space if not numerals for Tsys" do 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', :gateway_id => "AD0001-01", :password => "8q53g4ef") r = EWS::Transaction::Request.new(tx_params) resp = @transporter.submit(r) resp.cc_verification_str1.should == '1234567LOUGHEEDHIGHW902101234' end end