cancel
Showing results for 
Search instead for 
Did you mean: 

E00003 – An error occurred while parsing the XML request...I don't send XML

How could I get an XML parsing error when I don't send XML.  Here is my Authorize.Net ACH Processing function:

 

    Private Function AuthNet_ACH(ByVal oGtwy As Gateway,
                                 ByVal oInv As InvoiceDet,
                                 ByVal oACHDet As ACHDet) As Results
        Try
            '* Set the security protocol
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
            System.Net.ServicePointManager.ServerCertificateValidationCallback = (Function(sender, certificate, chain, sslPolicyErrors) True)

            '* Create the request
            If oGtwy.TestMode Then
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.SANDBOX
            Else
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.PRODUCTION
            End If
            ApiOperationBase(Of ANetApiRequest, ANetApiResponse).MerchantAuthentication = New merchantAuthenticationType() With {
                .name = oGtwy.LoginID,
                .ItemElementName = ItemChoiceType.transactionKey,
                .Item = oGtwy.Password
                }

            Dim bankAccount As New bankAccountType
            Select Case oACHDet.AcctType
                Case ACHDet.AcctTypes.S
                    bankAccount.accountType = bankAccountTypeEnum.savings
                Case Else
                    bankAccount.accountType = bankAccountTypeEnum.checking
            End Select
            bankAccount.routingNumber = oACHDet.ABA
            bankAccount.accountNumber = oACHDet.AcctNum
            bankAccount.nameOnAccount = oACHDet.AcctName
            Select Case oACHDet.AuthType
                Case ACHDet.AuthTypes.ARC
                    bankAccount.echeckType = echeckTypeEnum.ARC
                Case ACHDet.AuthTypes.BOC
                    bankAccount.echeckType = echeckTypeEnum.BOC
                Case ACHDet.AuthTypes.CCD
                    bankAccount.echeckType = echeckTypeEnum.CCD
                Case ACHDet.AuthTypes.PPD
                    bankAccount.echeckType = echeckTypeEnum.PPD
                Case ACHDet.AuthTypes.TEL
                    bankAccount.echeckType = echeckTypeEnum.TEL
                Case Else
                    bankAccount.echeckType = echeckTypeEnum.WEB
            End Select
            'bankAccount.bankName = "Wells Fargo Bank NA"

            Dim paymentType = New paymentType With {
                .Item = bankAccount
                }

            Dim transRequest As New transactionRequestType
            transRequest.amount = oInv.Amount

            Dim arrSettings As New List(Of settingType)
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.emailCustomer.ToString,
                                .settingValue = oGtwy.SendEmail
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.headerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailHeader.ToString
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.footerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailFooter.ToString
                                })

            Select Case oACHDet.TransType
                Case TransTypes.SALE
                    transRequest.transactionType = transactionTypeEnum.authCaptureTransaction.ToString
                Case TransTypes.VOID
                    'transRequest.transactionType = transactionTypeEnum.voidTransaction.ToString
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case TransTypes.CRED
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case Else   '* Use Authorize as the Default
                    transRequest.transactionType = transactionTypeEnum.authOnlyTransaction.ToString
                    transRequest.amount = 0.01D
                    arrSettings(0).settingValue = False
            End Select

            transRequest.transactionSettings = arrSettings.ToArray
            transRequest.payment = paymentType
            transRequest.lineItems = Nothing

            Dim arrFields As New List(Of userField)
            arrFields.Add(New userField With {
                            .name = "Market",
                            .value = oInv.Comment1.Split(":")(0)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctName",
                            .value = oInv.Comment1.Split(":")(1)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctNum",
                            .value = oInv.Comment2.ToString
                            })
            transRequest.userFields = arrFields.ToArray

            Dim Cust = New customerDataType With {
                .email = oInv.EmailAddr.ToString
                }
            transRequest.customer = Cust

            Dim request = New createTransactionRequest With {
                .transactionRequest = transRequest
                }

            ' Step 3 - Send the request to the gateway
            Dim controller = New createTransactionController(request)
            controller.Execute()
            Dim Resp = controller.GetApiResponse()

            If Not Resp Is Nothing Then
                Dim oResp As Results = New Results(DirectCast(Resp, createTransactionResponse))

                Try
                    If ConfigurationManager.AppSettings("AUTHNET_RES_LOG") IsNot Nothing Then
                        If CBool(ConfigurationManager.AppSettings("AUTHNET_RES_LOG")) Then
                            SimpleLog.WriteLog(oResp)
                        End If
                    End If
                Catch ex As Exception
                End Try

                Return oResp
            Else
                Dim oRes = New Results
                Dim errorResponse As ANetApiResponse = controller.GetErrorResponse()

                If errorResponse.messages.message.Length > 0 Then
                    oRes.Response = "Controller_Name Creation Failed."
                    oRes.RespMsg = "Error message: " & errorResponse.messages.message(0).text
                    oRes.Result = errorResponse.messages.message(0).code
                Else
                    oRes.Response = "Null Response."
                End If

                Return oRes
            End If

        Catch ex As Exception
            SimpleLog.WriteLog(ex)
            Throw CustomException(ex)
        End Try
    End Function

And here's the fun part.  Sometimes it works...sometimes it doesn't.  Works all the time for most clients, and sporadically for one client.  

 

SSirica
Member
0 REPLIES 0