require File.dirname(__FILE__) + "/../test_helper" class PurchaseCorrectionTest < Test::Unit::TestCase # NOTE: ONLY supported bu Moneris processors # This is used to VOID a previous Purchase transaction. However, we strongly recommend # using a normal Void transaction instead of a Purchase Correction. def setup @transporter = EWS::Transporter.new(LOCATION) end def test_mandatory request = EWS::Transaction::Request.new(:transaction_type => :purchase_correction) assert !request.valid? assert_equal "gateway_id must be supplied", request.errors[:gateway_id] request.gateway_id = MONERIS_BASIC_AUTH[:gateway_id] assert !request.valid? assert_equal "password must be supplied", request.errors[:password] request.password = MONERIS_BASIC_AUTH[:password] assert !request.valid? assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base] request.cc_number = "4111111111111111" assert !request.valid? assert_equal "cc_expiry must be supplied", request.errors[:cc_expiry] request.cc_expiry = "0913" assert !request.valid? assert_equal "cardholder_name must be supplied", request.errors[:cardholder_name] request.cardholder_name = "Simon Jones" assert !request.valid? assert_equal "amount must be supplied", request.errors[:amount] request.amount = 10 assert !request.valid? assert_equal "authorization_num must be supplied", request.errors[:authorization_num] request.authorization_num = "TH6754" assert request.valid? end def test_by_credit_card request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :purchase_correction).merge(MONERIS_BASIC_AUTH)) request.amount = 11.25 request.authorization_num = "1234" assert request.valid?, request.errors.inspect assert_details_correct request, @transporter.submit(request, :json) assert_details_correct request, @transporter.submit(request, :rest) assert_details_correct request, @transporter.submit(request, :soap) end def test_by_track1 request = EWS::Transaction::Request.new(track1_params.merge(:transaction_type => :purchase_correction).merge(MONERIS_BASIC_AUTH)) request.amount = 11.25 request.authorization_num = "1234" assert request.valid?, request.errors.inspect assert_details_correct request, @transporter.submit(request, :json) assert_details_correct request, @transporter.submit(request, :rest) assert_details_correct request, @transporter.submit(request, :soap) end def test_by_track2 request = EWS::Transaction::Request.new(track2_params.merge(:transaction_type => :purchase_correction).merge(MONERIS_BASIC_AUTH)) request.amount = 11.25 request.authorization_num = "1234" assert request.valid?, request.errors.inspect assert_details_correct request, @transporter.submit(request, :json) assert_details_correct request, @transporter.submit(request, :rest) assert_details_correct request, @transporter.submit(request, :soap) end end