test/unit/gateways/secure_pay_test.rb in activemerchant-1.4.2 vs test/unit/gateways/secure_pay_test.rb in activemerchant-1.5.0

- old
+ new

@@ -1,36 +1,46 @@ -require File.dirname(__FILE__) + '/../../test_helper' - +require 'test_helper' + class SecurePayTest < Test::Unit::TestCase - + def setup @gateway = SecurePayGateway.new( :login => 'X', :password => 'Y' ) - + @credit_card = credit_card @options = { :order_id => generate_unique_id, :description => 'Store purchase', :billing_address => address } @amount = 100 end - + def test_failed_purchase @gateway.stubs(:ssl_post).returns(failure_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? assert_equal 'This transaction has been declined', response.message assert_equal '3377475', response.authorization end + def test_failed_production_purchase + @gateway.stubs(:ssl_post).returns(failed_production_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert response.test? + assert_equal 'This transaction has been declined', response.message + assert_equal '7416654', response.authorization + end + def test_successful_purchase @gateway.stubs(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -72,16 +82,20 @@ end private def successful_purchase_response - '1%%1%This transaction has been approved.%100721%X%3377575%f6af895031c07d88399ed9fdb48c8476%Store+purchase%0.01%%AUTH_CAPTURE%%Cody%Fauser%%100+Example+St.%Ottawa%ON%K2A5P7%Canada%%%%%%%%%%%%%%%%%%%' + '1,,1,This transaction has been approved.,100721,X,3377575,f6af895031c07d88399ed9fdb48c8476,Store+purchase,0.01,,AUTH_CAPTURE,,Cody,Fauser,,100+Example+St.%Ottawa,ON,K2A5P7,Canada,,,,,,,,,,,,,,,,,,,' end - + def failure_response - '2%%2%This transaction has been declined.%NOT APPROVED%U%3377475%55adbbaed13aa7e2526846d672fdb594%Store+purchase%1.00%%AUTH_CAPTURE%%Longbob%Longsen%%1234+Test+St.%Ottawa%ON%K1N5P8%Canada%%%%%%%%%%%%%%%%%%%' + '2,,2,This transaction has been declined.,NOT APPROVED,U,3377475,55adbbaed13aa7e2526846d672fdb594,Store+purchase,1.00,,AUTH_CAPTURE,,Longbob,Longsen,,1234+Test+St.,Ottawa,ON,K1N5P8,Canada,,,,,,,,,,,,,,,,,,,' end def failed_capture_response - '3%%6%The credit card number is invalid.%%%%%%0.01%%PRIOR_AUTH_CAPTURE%%%%%%%%%%%%%%%%%%%%%%%%%%%%' + '3,,6,The credit card number is invalid.,,,,,,0.01,,PRIOR_AUTH_CAPTURE,,,,,,,,,,,,,,,,,,,,,,,,,,,,' end -end + + def failed_production_response + '2,,2,This transaction has been declined.,NOT APPROVED,U,7416654,%231014.11,,7.95,,AUTH_CAPTURE,321hunter%40comcast.net,David,Hunter,,260+Windsor+Ave,Haddonfield,NJ,08033,US,856+795+7941,,321hunter%40comcast.net,,,,260+Windsor+Ave,Haddonfield,Haddonfield,NJ,08033,,,,,,,,' + end +end \ No newline at end of file