./test/exhaustive/transaction_details_test.rb in exact4r-1.4 vs ./test/exhaustive/transaction_details_test.rb in exact4r-1.5
- old
+ new
@@ -36,15 +36,69 @@
: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)
+ [:json, :rest, :soap].each do |encoding|
+ response = @transporter.submit(request, encoding)
+ assert_equal "############1111", response.cc_number
+ assert_details_match_original_response pre_response, response, encoding
+ end
end
+
+ def test_supplying_auth_num_decrypts_cc_number
+ # 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,
+ :authorization_num => pre_response.authorization_num
+ }.merge(@@credentials.current_gateway))
+ assert request.valid?, request.errors.inspect
+
+ [:json, :rest, :soap].each do |encoding|
+ response = @transporter.submit(request, encoding)
+ assert_equal "4111111111111111", response.cc_number
+ assert_details_match_original_response pre_response, response, encoding
+ end
+ end
+ def test_encodes_parameters
+ # do initial purchase
+ pre_request = EWS::Transaction::Request.new(cc_number_params.merge({
+ :transaction_type => :purchase,
+ :reference_no => "barry&=x=jones"
+ }))
+ 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,
+ :authorization_num => pre_response.authorization_num,
+ :reference_no => "barry&=x=jones"
+ }.merge(@@credentials.current_gateway))
+ assert request.valid?, request.errors.inspect
+
+ [:json, :rest, :soap].each do |encoding|
+ response = @transporter.submit(request, encoding)
+ assert_not_nil response, "should not be nil for #{encoding}"
+ assert response.approved?, "#{encoding}: #{response.error_number} / #{response.error_description} / #{response.exact_message}"
+ assert_equal "4111111111111111", response.cc_number, "should match for #{encoding}"
+ assert_details_match_original_response pre_response, response, encoding
+ end
+ end
+
def test_debit_transaction_details
return unless @@credentials.chase?
# do initial purchase
pre_request = EWS::Transaction::Request.new({
@@ -62,28 +116,30 @@
: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)
+ [:json, :rest, :soap].each do |encoding|
+ response = @transporter.submit(request, encoding)
+ assert_equal "############1111", response.cc_number
+ assert_details_match_original_response pre_response, response, encoding
+ end
end
- def assert_details_match_original_response(original_response, details_response)
- # exclude: client_ip, pan
+ def assert_details_match_original_response(original_response, details_response, encoding)
+ # exclude: client_ip, pan, cc_number
[: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,
+ :transaction_type, :amount, :surcharge_amount, :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}"
+ assert_equal o_value, d_value, "Encoding: #{encoding} - #{attr_name}: #{o_value} / #{d_value}"
end
end
private :assert_details_match_original_response
end