require 'test_helper' class PaymentechOrbitalTest < Test::Unit::TestCase def setup @gateway = PaymentechOrbitalGateway.new( :login => 'login', :password => 'password', :merchant_id => '000000', :terminal_id => '000', :bin => '000000' ) @credit_card = credit_card @amount = 100 @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of PaymentechOrbitalResponse, response assert_success response assert_equal '1', response.authorization assert response.test? end def test_unsuccessful_request @gateway.expects(:ssl_post).returns(failed_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? end private def successful_purchase_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <Response> <NewOrderResp> <IndustryType/> <MessageType>AC</MessageType> <MerchantID>000000</MerchantID> <TerminalID>000</TerminalID> <CardBrand>MC</CardBrand> <AccountNum>5454545454545454</AccountNum> <OrderID>1</OrderID> <TxRefNum>4A785F5106CCDC41A936BFF628BF73036FEC5401</TxRefNum> <TxRefIdx>1</TxRefIdx> <ProcStatus>0</ProcStatus> <ApprovalStatus>1</ApprovalStatus> <RespCode>00</RespCode> <AVSRespCode>B </AVSRespCode> <CVV2RespCode>M</CVV2RespCode> <AuthCode>tst554</AuthCode> <RecurringAdviceCd/> <CAVVRespCode/> <StatusMsg>Approved</StatusMsg> <RespMsg/> <HostRespCode>100</HostRespCode> <HostAVSRespCode>I3</HostAVSRespCode> <HostCVV2RespCode>M</HostCVV2RespCode> <CustomerRefNum>2145108</CustomerRefNum> <CustomerName>JOE SMITH</CustomerName> <ProfileProcStatus>0</ProfileProcStatus> <CustomerProfileMessage>Profile Created</CustomerProfileMessage> <RespTime>121825</RespTime> </NewOrderResp> </Response> RESPONSE end def failed_purchase_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <Response> <QuickResp> <ProcStatus>841</ProcStatus> <StatusMsg>Error validating card/account number range</StatusMsg> <CustomerBin></CustomerBin> <CustomerMerchantID></CustomerMerchantID> <CustomerName></CustomerName> <CustomerRefNum></CustomerRefNum> <CustomerProfileAction></CustomerProfileAction> <ProfileProcStatus>9576</ProfileProcStatus> <CustomerProfileMessage>Profile: Unable to Perform Profile Transaction. The Associated Transaction Failed. </CustomerProfileMessage> <CustomerAddress1></CustomerAddress1> <CustomerAddress2></CustomerAddress2> <CustomerCity></CustomerCity> <CustomerState></CustomerState> <CustomerZIP></CustomerZIP> <CustomerEmail></CustomerEmail> <CustomerPhone></CustomerPhone> <CustomerProfileOrderOverrideInd></CustomerProfileOrderOverrideInd> <OrderDefaultDescription></OrderDefaultDescription> <OrderDefaultAmount></OrderDefaultAmount> <CustomerAccountType></CustomerAccountType> <CCAccountNum></CCAccountNum> <CCExpireDate></CCExpireDate> <ECPAccountDDA></ECPAccountDDA> <ECPAccountType></ECPAccountType> <ECPAccountRT></ECPAccountRT> <ECPBankPmtDlv></ECPBankPmtDlv> <SwitchSoloStartDate></SwitchSoloStartDate> <SwitchSoloIssueNum></SwitchSoloIssueNum> </QuickResp> </Response> RESPONSE end end