require File.dirname(__FILE__) + "/../test_helper" class OnlineDebitPurchaseTest < Test::Unit::TestCase # NOTE: INTERAC Online Debit transactions are ONLY supported by Chase merchants def setup @transporter = EWS::Transporter.new(@@credentials.config['location']) end def test_mandatory request = EWS::Transaction::Request.new(:transaction_type => :idebit_purchase) 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 "pan must be supplied", request.errors[:pan] request.pan = "4111111111111111" 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? end # PAN may be specificed as a simple account number... def test_by_pan_as_cc_number return unless @@credentials.chase? request = EWS::Transaction::Request.new({ :transaction_type => :idebit_purchase, :amount => 11.25, :pan => TEST_CARD_NUMBER, :cardholder_name => TEST_CARD_HOLDER }.merge(@@credentials.current_gateway)) 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 # ...or in track2 format def test_by_pan_as_cc_number return unless @@credentials.chase? request = EWS::Transaction::Request.new({ :transaction_type => :idebit_purchase, :amount => 11.25, :pan => TEST_TRACK2, :cardholder_name => TEST_CARD_HOLDER }.merge(@@credentials.current_gateway)) 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