Validation error 331: The tender amount or change is incorrect

Aug 20, 2006 0 Replies

I have a custom process button the that tenders a transaction for a unique payment method. Towards the end of the process I get the 331 error. Here is an example of my totals:



Subtotal $77.94 Tax $6.61 Shipping $15.00 Total $99.45 Tender amount $99.45


My tender amount and total are the same. What could be gifing me the error?



Here is a snippet of my code:


Public Class Program



Public Function Process(ByVal session As Object) As Boolean



Try



Dim transaction As Object



transaction = session.Transaction


If Not transaction.IsOrder Then



MsgBox("There is no order available to proceed")



Return False



End If


If transaction.OrderClosed Then



MsgBox("Order is closed")



Return False



End If


If transaction.TransactionType 2 Then



MsgBox("Transaction can be performed just on work order")



Return False



End If


Dim orderTotal As Double



orderTotal = transaction.Total



Dim orderID As Integer



orderID = transaction.OrderID


Dim webService As New NwsWebService.SyncService()



Dim response As NwsWebService.WebServiceResponse


Dim userName As String



Dim password As String


Dim rk As Microsoft.Win32.RegistryKey



rk = Nothing


Try



rk Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Tawny\WebStore\Sy ncService", False)


userName = rk.GetValue("WSU")



password = rk.GetValue("WSP")



webService.Url = rk.GetValue("Url")



Catch e As Exception



MsgBox("Exception was trown: " + e.Message)



Return False



Finally



If Not rk Is Nothing Then



rk.Close()



End If



End Try


Try



response = webService.ProcessOrder(userName, password, orderID, orderTotal)



Catch e As Exception



MsgBox(e.Message)



Return False



End Try


If response Is Nothing Then



MsgBox("Tawny RMS Web Service is unavailable")



Return False



End If


If response.Result = 0 Then



If response.PaymentProcessorResponse.Result = 0 Then



MsgBox("Customer is charged " + orderTotal.ToString())



Else



MsgBox("Payment processor answer: " + response.PaymentProcessorResponse.RespMSG)



Return False



End If



Else



MsgBox(response.Message)



Return False



'MsgBox("Execution continues for test purposes")



End If


Dim tenderAmountIn As Double



tenderAmountIn = transaction.OrderBalance 'orderTotal - transaction.DepositTotal ' transaction.OrderBalance



transaction.TenderDefault.AmountIn = tenderAmountIn


MsgBox("Order total: " + orderTotal.ToString() + " Balance: " + tenderAmountIn.ToString())


Dim preTenderValidateResult As Integer



preTenderValidateResult = transaction.PreTenderValidate()



MsgBox("PreTenderValidate result code: " + preTenderValidateResult.ToString())


transaction.TendersForceValidation()


Dim transactionPostResult As Integer



transactionPostResult = transaction.Post(session.Cashier.ID)



MsgBox("Transaction Post result code: " + transactionPostResult.ToString())


Dim postTenderValidateResult As Integer



postTenderValidateResult = transaction.PostTenderValidate()



MsgBox("PostTenderValidate result code: " + postTenderValidateResult.ToString())


'System.Windows.Forms.SendKeys.SendWait("{DOWN}")



'System.Windows.Forms.SendKeys.SendWait("{DOWN}")



'System.Windows.Forms.SendKeys.SendWait("{ENTER}")



'System.Windows.Forms.SendKeys.SendWait("{UP}")



'System.Windows.Forms.SendKeys.SendWait("{UP}")


Return True



Catch globalException As Exception



MsgBox("Exception thrown: " + globalException.Message)



End Try



End Function



End Class


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required