Showing results for 
Search instead for 
Did you mean: 

The type AuthorizeNet.BankAccount was not expected



I followed the C# example payment example and converted it to VB.Net, but I'm having trouble processing bank account. When I execute my transactionController I'm getting an error

"The type AuthorizeNet.BankAccount was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.



I looked around online and most of the solutions say I have to add XmlInclude attribute to the base class. This doesn't work because I'm using an API and I don't have access to the source code.


I also found this post

that says this can happen because nameOnAccount is null but my nameOnAccount field is not null.


How do I solve this issue?


            Dim bankAccount As BankAccount = New BankAccount()
            bankAccount.routingNumber = "123123123"
            bankAccount.accountNumber = "1234567890"
            bankAccount.accountType = bankAccountTypeEnum.checking
            bankAccount.bankName = "fake bank"
            bankAccount.nameOnAccount = "fake name"
            bankAccount.echeckType = EcheckType.WEB

            Dim paymentType As paymentType = New paymentType() _
                With {.Item = bankAccount}

            Dim lineItems(2) As lineItemType
            lineItems(0) = New lineItemType() _
                With {.itemId = "1", .name = "t-shirt", .quantity = 2, .unitPrice = New Decimal(1.0)}
            lineItems(1) = New lineItemType() _
                With {.itemId = "2", .name = "snowboard", .quantity = 1, .unitPrice = New Decimal(1.0)}

            Dim tax As extendedAmountType = New extendedAmountType() _
                With {.amount = "123",
                      .description = "total taxed amount",
                      .name = "tax"}

            Dim transactionRequest As transactionRequestType = New transactionRequestType() _
                With {.transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
                      .amount = New Decimal(480.0),
                      .billTo = billingAddress,
                      .payment = paymentType,
                      .lineItems = lineItems,
                      .transactionSettings = settings,
                      .customer = customer,
                      .tax = tax}

            Dim request As createTransactionRequest = New createTransactionRequest() _
                With {.transactionRequest = transactionRequest}
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
            Dim controller As createTransactionController = New createTransactionController(request)