./test/exhaustive/void_test.rb in exact4r-1.2 vs ./test/exhaustive/void_test.rb in exact4r-1.4
- old
+ new
@@ -38,44 +38,81 @@
request.authorization_num = "TH6754"
assert request.valid?
end
def test_by_credit_card
- return if @@credentials.chase? || @@credentials.moneris?
-
+ return if @@credentials.moneris?
+
+ response = send_purchase(cc_number_params)
+
request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :void))
request.amount = 11.25
- request.authorization_num = "1234"
+ request.authorization_num = response.authorization_num
assert request.valid?, request.errors.inspect
assert_details_correct request, @transporter.submit(request, :json)
+
+ response = send_purchase(cc_number_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :rest)
+
+ response = send_purchase(cc_number_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :soap)
end
def test_by_track1
- return if @@credentials.chase? || @@credentials.moneris?
+ return if @@credentials.moneris?
+ response = send_purchase(track1_params)
+
request = EWS::Transaction::Request.new(track1_params.merge(:transaction_type => :void))
request.amount = 11.25
- request.authorization_num = "1234"
+ request.authorization_num = response.authorization_num
assert request.valid?, request.errors.inspect
assert_details_correct request, @transporter.submit(request, :json)
+
+ response = send_purchase(track1_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :rest)
+
+ response = send_purchase(track1_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :soap)
end
def test_by_track2
- return if @@credentials.chase? || @@credentials.moneris?
+ return if @@credentials.moneris?
+ response = send_purchase(track2_params)
+
request = EWS::Transaction::Request.new(track2_params.merge(:transaction_type => :void))
request.amount = 11.25
- request.authorization_num = "1234"
+ request.authorization_num = response.authorization_num
assert request.valid?, request.errors.inspect
assert_details_correct request, @transporter.submit(request, :json)
+
+ response = send_purchase(track2_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :rest)
+
+ response = send_purchase(track2_params)
+ request.authorization_num = response.authorization_num
+
assert_details_correct request, @transporter.submit(request, :soap)
end
+ def send_purchase(params)
+ request = EWS::Transaction::Request.new(params.merge(:transaction_type => :purchase, :amount => 11.25))
+ assert request.valid?, request.errors.inspect
+ response = @transporter.submit(request, :json)
+ assert response.approved?
+ response
+ end
end