require File.dirname(__FILE__) + "/../test_helper" class TransactionDetailsTest < Test::Unit::TestCase def setup @transporter = EWS::Transporter.new(@@credentials.config['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 = @@credentials.current_gateway[:gateway_id] assert !request.valid? assert_equal "password must be supplied", request.errors[:password] request.password = @@credentials.current_gateway[: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(@@credentials.current_gateway)) 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 return unless @@credentials.chase? # 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(@@credentials.current_gateway)) 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(@@credentials.current_gateway)) 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) # exclude: client_ip, pan [: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, :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_email, :user_name, :zip_code].each do |attr_name| next if attr_name == :cc_expiry && %(35 50 54).include?(original_response.transaction_type) o_value = original_response.send(attr_name).to_s d_value = details_response.send(attr_name).to_s assert_equal o_value, d_value, "#{attr_name}: #{o_value} / #{d_value}" end end private :assert_details_match_original_response end