test/unit/gateways/exact_test.rb in activemerchant-1.2.1 vs test/unit/gateways/exact_test.rb in activemerchant-1.3.0

- old
+ new

@@ -3,53 +3,45 @@ class ExactTest < Test::Unit::TestCase def setup @gateway = ExactGateway.new( :login => "A00427-01", :password => "testus" ) - @credit_card = credit_card("4111111111111111") - - @options = { :address => { :address1 => "1234 Testing Ave.", - :zip => "55555" } } + @credit_card = credit_card + @amount = 100 + @options = { + :order_id => '1', + :billing_address => address, + :description => 'Store Purchase' + } end - def test_successful_request - @credit_card.number = "1" - assert response = @gateway.purchase(100, @credit_card, {}) + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal '5555', response.authorization + assert_equal 'ET1700;106625152', response.authorization assert response.test? + assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message + + ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) } end - - def test_unsuccessful_request - @credit_card.number = "2" - assert response = @gateway.purchase(100, @credit_card, {}) + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_instance_of Response, response assert_failure response - assert response.test? end - - def test_request_error - @credit_card.number = "3" - assert_raise(Error){ @gateway.purchase(100, @credit_card, {}) } - end + def test_expdate assert_equal( "%02d%s" % [ @credit_card.month, @credit_card.year.to_s[-2..-1] ], @gateway.send(:expdate, @credit_card) ) end - - def test_successful_purchase - @gateway.expects(:ssl_post).returns(successful_purchase_response) - assert response = @gateway.purchase(100, @credit_card, {}) - assert_success response - assert_equal 'ET0426;80928103', response.authorization - assert response.test? - assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message - ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) } - end - def test_soap_fault @gateway.expects(:ssl_post).returns(soap_fault_response) assert response = @gateway.purchase(100, @credit_card, {}) assert_failure response assert response.test? @@ -62,43 +54,89 @@ def test_supported_card_types assert_equal [:visa, :master, :american_express, :jcb, :discover], ExactGateway.supported_cardtypes end + def test_avs_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card) + assert_equal 'U', response.avs_result['code'] + end + + def test_cvv_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card) + assert_equal 'M', response.cvv_result['code'] + end + + private def successful_purchase_response <<-RESPONSE -<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4111111111111111</Card_Number><Verification_Str2 xsi:type="xsd:string">123</Verification_Str2><Transaction_Tag xsi:type="xsd:string">80928103</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET0426</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Active Merchant</CardHoldersName><CVD_Presence_Ind xsi:type="xsd:string">0</CVD_Presence_Ind><ZipCode xsi:type="xsd:string">55555</ZipCode><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by: -E-xact Transaction Gateway :- Version 8.4.0 B19 -Copyright 2006 -{34:2652}</LogonMessage><Error_Number xsi:type="xsd:string">0</Error_Number><Error_Description xsi:type="xsd:string" /><Transaction_Error xsi:type="xsd:boolean">false</Transaction_Error><Transaction_Approved xsi:type="xsd:boolean">true</Transaction_Approved><EXact_Resp_Code xsi:type="xsd:string">00</EXact_Resp_Code><EXact_Message xsi:type="xsd:string">Transaction Normal</EXact_Message><Bank_Resp_Code xsi:type="xsd:string">00</Bank_Resp_Code><Bank_Message xsi:type="xsd:string">VER UNAVAILABLE </Bank_Message><SequenceNo xsi:type="xsd:string">431</SequenceNo><AVS xsi:type="xsd:string">U</AVS><Retrieval_Ref_No xsi:type="xsd:string">200703280426</Retrieval_Ref_No><MerchantName xsi:type="xsd:string">E-xact ConnectionShop</MerchantName><MerchantAddress xsi:type="xsd:string">Suite 304 - 134 Abbott Street</MerchantAddress><MerchantCity xsi:type="xsd:string">Vancouver</MerchantCity><MerchantProvince xsi:type="xsd:string">BC</MerchantProvince><MerchantCountry xsi:type="xsd:string">Canada</MerchantCountry><MerchantPostal xsi:type="xsd:string">V6B 2K4</MerchantPostal><MerchantURL xsi:type="xsd:string">www.e-xact.com</MerchantURL><CTR xsi:type="xsd:string">========== TRANSACTION RECORD ========= +<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4242424242424242</Card_Number><Transaction_Tag xsi:type="xsd:string">106625152</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET1700</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Longbob Longsen</CardHoldersName><VerificationStr2 xsi:type="xsd:string">123</VerificationStr2><CVD_Presence_Ind xsi:type="xsd:string">1</CVD_Presence_Ind><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Reference_No xsi:type="xsd:string">1</Reference_No><Reference_3 xsi:type="xsd:string">Store Purchase</Reference_3><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by: +E-xact Transaction Gateway :- Version 8.4.0 B19b +Copyright 2006 +{34:2652}</LogonMessage><Error_Number xsi:type="xsd:string">0</Error_Number><Error_Description xsi:type="xsd:string" /><Transaction_Error xsi:type="xsd:boolean">false</Transaction_Error><Transaction_Approved xsi:type="xsd:boolean">true</Transaction_Approved><EXact_Resp_Code xsi:type="xsd:string">00</EXact_Resp_Code><EXact_Message xsi:type="xsd:string">Transaction Normal</EXact_Message><Bank_Resp_Code xsi:type="xsd:string">00</Bank_Resp_Code><Bank_Message xsi:type="xsd:string">VER UNAVAILABLE </Bank_Message><SequenceNo xsi:type="xsd:string">377</SequenceNo><AVS xsi:type="xsd:string">U</AVS><CVV2 xsi:type="xsd:string">M</CVV2><Retrieval_Ref_No xsi:type="xsd:string">200801181700</Retrieval_Ref_No><MerchantName xsi:type="xsd:string">E-xact ConnectionShop</MerchantName><MerchantAddress xsi:type="xsd:string">Suite 400 - 1152 Mainland St.</MerchantAddress><MerchantCity xsi:type="xsd:string">Vancouver</MerchantCity><MerchantProvince xsi:type="xsd:string">BC</MerchantProvince><MerchantCountry xsi:type="xsd:string">Canada</MerchantCountry><MerchantPostal xsi:type="xsd:string">V6B 4X2</MerchantPostal><MerchantURL xsi:type="xsd:string">www.e-xact.com</MerchantURL><CTR xsi:type="xsd:string">========== TRANSACTION RECORD ========= + +E-xact ConnectionShop +Suite 400 - 1152 Mainland St. +Vancouver, BC V6B 4X2 +www.e-xact.com + +TYPE: Purchase + +ACCT: Visa $1.00 USD + +CARD NUMBER : ############4242 +TRANS. REF. : 1 +CARD HOLDER : Longbob Longsen +EXPIRY DATE : xx/xx +DATE/TIME : 18 Jan 08 14:17:00 +REFERENCE # : 5999 377 M +AUTHOR.# : ET1700 + + Approved - Thank You 00 + +SIGNATURE -E-xact ConnectionShop -Suite 304 - 134 Abbott Street -Vancouver, BC V6B 2K4 -www.e-xact.com -TYPE: Purchase -ACCT: Visa $1.00 USD +_______________________________________ -CARD NUMBER : ############1111 -TRANS. REF. : -CARD HOLDER : Active Merchant -EXPIRY DATE : xx/xx -DATE/TIME : 28 Mar 07 12:04:26 -REFERENCE # : 5999 431 M -AUTHOR.# : ET0426 - - Approved - Thank You 00 - -SIGNATURE - - - -_______________________________________ - </CTR></types:TransactionResult></soap:Body></soap:Envelope> + RESPONSE + end + + def failed_purchase_response + <<-RESPONSE +<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">5013</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4111111111111111</Card_Number><Transaction_Tag xsi:type="xsd:string">106624668</Transaction_Tag><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Longbob Longsen</CardHoldersName><VerificationStr2 xsi:type="xsd:string">123</VerificationStr2><CVD_Presence_Ind xsi:type="xsd:string">1</CVD_Presence_Ind><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Reference_No xsi:type="xsd:string">1</Reference_No><Reference_3 xsi:type="xsd:string">Store Purchase</Reference_3><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by: +E-xact Transaction Gateway :- Version 8.4.0 B19b +Copyright 2006 +{34:2652}</LogonMessage><Error_Number xsi:type="xsd:string">0</Error_Number><Error_Description xsi:type="xsd:string" /><Transaction_Error xsi:type="xsd:boolean">false</Transaction_Error><Transaction_Approved xsi:type="xsd:boolean">false</Transaction_Approved><EXact_Resp_Code xsi:type="xsd:string">00</EXact_Resp_Code><EXact_Message xsi:type="xsd:string">Transaction Normal</EXact_Message><Bank_Resp_Code xsi:type="xsd:string">13</Bank_Resp_Code><Bank_Message xsi:type="xsd:string">AMOUNT ERR</Bank_Message><SequenceNo xsi:type="xsd:string">376</SequenceNo><AVS xsi:type="xsd:string">U</AVS><CVV2 xsi:type="xsd:string">M</CVV2><MerchantName xsi:type="xsd:string">E-xact ConnectionShop</MerchantName><MerchantAddress xsi:type="xsd:string">Suite 400 - 1152 Mainland St.</MerchantAddress><MerchantCity xsi:type="xsd:string">Vancouver</MerchantCity><MerchantProvince xsi:type="xsd:string">BC</MerchantProvince><MerchantCountry xsi:type="xsd:string">Canada</MerchantCountry><MerchantPostal xsi:type="xsd:string">V6B 4X2</MerchantPostal><MerchantURL xsi:type="xsd:string">www.e-xact.com</MerchantURL><CTR xsi:type="xsd:string">========== TRANSACTION RECORD ========= + +E-xact ConnectionShop +Suite 400 - 1152 Mainland St. +Vancouver, BC V6B 4X2 +www.e-xact.com + +TYPE: Purchase + +ACCT: Visa $5,013.00 USD + +CARD NUMBER : ############1111 +TRANS. REF. : 1 +CARD HOLDER : Longbob Longsen +EXPIRY DATE : xx/xx +DATE/TIME : 18 Jan 08 14:11:09 +REFERENCE # : 5999 376 M +AUTHOR.# : + + Transaction not Approved 13 + + +</CTR></types:TransactionResult></soap:Body></soap:Envelope> RESPONSE end def soap_fault_response <<-RESPONSE \ No newline at end of file