require File.dirname(__FILE__) + "/../test_helper" class TransactionDetailsTest < Test::Unit::TestCase def setup @transporter = EWS::Transporter.new(LOCATION) end def test_mandatory request = EWS::Transaction::Request.new(:transaction_type => :transaction_details) assert !request.valid? assert_equal "gateway_id must be supplied", request.errors[:gateway_id] request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id] assert !request.valid? assert_equal "password must be supplied", request.errors[:password] request.password = EMERGIS_BASIC_AUTH[:password] assert !request.valid? assert_equal "transaction_tag must be supplied", request.errors[:transaction_tag] request.transaction_tag = 1234 assert request.valid? end def test_credit_transaction_details # do initial purchase pre_request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :purchase)) pre_request.amount = 10.1 assert pre_request.valid?, pre_request.errors.inspect pre_response = @transporter.submit(pre_request, :json) assert pre_response.approved? request = EWS::Transaction::Request.new({ :transaction_type => :transaction_details, :transaction_tag => pre_response.transaction_tag }.merge(EMERGIS_BASIC_AUTH)) assert request.valid?, request.errors.inspect assert_details_match_original_response pre_response, @transporter.submit(request, :json) assert_details_match_original_response pre_response, @transporter.submit(request, :rest) assert_details_match_original_response pre_response, @transporter.submit(request, :soap) end def test_debit_transaction_details # do initial purchase pre_request = EWS::Transaction::Request.new({ :transaction_type => :idebit_purchase, :amount => 10.1, :pan => TEST_CARD_NUMBER, :cardholder_name => TEST_CARD_HOLDER }.merge(CHASE_BASIC_AUTH)) assert pre_request.valid?, pre_request.errors.inspect pre_response = @transporter.submit(pre_request, :json) assert pre_response.approved? request = EWS::Transaction::Request.new({ :transaction_type => :transaction_details, :transaction_tag => pre_response.transaction_tag }.merge(CHASE_BASIC_AUTH)) assert request.valid?, request.errors.inspect assert_details_match_original_response pre_response, @transporter.submit(request, :json) assert_details_match_original_response pre_response, @transporter.submit(request, :rest) assert_details_match_original_response pre_response, @transporter.submit(request, :soap) end def assert_details_match_original_response(original_response, details_response) [:logon_message, :error_number, :error_description, :transaction_error, :transaction_approved, :exact_resp_code, :exact_message, :bank_resp_code, :bank_message, :bank_resp_code_2, :sequence_no, :avs, :cvv2, :retrieval_ref_no, :cavv_response, :merchant_name, :merchant_address, :merchant_city, :merchant_province, :merchant_country, :merchant_postal, :merchant_url, :gateway_id, :password, :transaction_type, :amount, :surcharge_amount, :cc_number, :transaction_tag, :track1, :track2, :pan, :authorization_num, :cc_expiry, :cardholder_name, :cc_verification_str1, :cc_verification_str2, :cvd_presence_ind, :tax1_amount, :tax1_number, :tax2_amount, :tax2_number, :secure_auth_required, :secure_auth_result, :ecommerce_flag, :xid, :cavv, :cavv_algorithm, :reference_no, :customer_ref, :reference_3, :language, :client_ip, :client_email, :user_name, :zip_code].each do |attr_name| o_value = original_response.send(attr_name).to_s d_value = details_response.send(attr_name).to_s unless o_value == d_value puts "#{attr_name}: #{o_value} / #{d_value}" end end end private :assert_details_match_original_response end