cancel
Showing results for 
Search instead for 
Did you mean: 

VB.NET createCustomerProfileRequest always returns null response

In the "Try it" section of the API documentation, I am able to submit a request with no problem, however the code there is JSON or XML, I use VB.NET and yes I use TLS 1.2.

Assumptions:

    I assume that creating a customer profile with CIM  does not submit a transaction for processing.

    I assume that the information submitted is stored on Authorize,NET servers when in production

    mode, but not in test mode.

 

Basic questions:

    1. Can I use "Production Mode in the sandbox?

    2. If so, is a customer profile created and stored on the sandbox server?

 

The Problem:

    Execution of the code always returns NULL.

 

Any assistance would be greatly appreciated.

 

My Code:

    This application I'm updating is a legacy application written in VB.NET, so it was necessary to

    convert the provided code example to VB.NET.  I return any errors/response objects via reference

    variables.  I do this so I can examine both objects on completion of the request.  The code is below:

 

    Public Shared Function CreateCustomerProfile(ByVal ApiLoginID As String, ByVal ApiTransactionKey As String, ByRef pProfileID As String, ByRef pResponse As createCustomerProfileResponse) As ANetApiResponse
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
        Dim MySubRecord As clsSubpaymentInfo = Current.Session("MySubRecord")
        ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.SANDBOX
        ApiOperationBase(Of ANetApiRequest, ANetApiResponse).MerchantAuthentication = New merchantAuthenticationType() With {.name = ApiLoginID, .ItemElementName = ItemChoiceType.transactionKey, .Item = ApiTransactionKey}
        Dim creditCard = New creditCardType With {.cardNumber = MySubRecord.CardNumber, .expirationDate = MySubRecord.ExpireMonth & MySubRecord.ExpireYear}
        Dim bankAccount = New bankAccountType With {.accountNumber = MySubRecord.BankAccountNumber, .routingNumber = MySubRecord.RoutingNumber, .accountType = bankAccountTypeEnum.checking, .echeckType = echeckTypeEnum.WEB, .nameOnAccount = MySubRecord.Firstname & " " & MySubRecord.Lastname, .bankName = MySubRecord.BankName}
        Dim cc As paymentType = New paymentType With {.Item = creditCard}
        Dim echeck As paymentType = New paymentType With {.Item = bankAccount}
        Dim paymentProfileList As List(Of customerPaymentProfileType) = New List(Of customerPaymentProfileType)()
        Dim ccPaymentProfile As customerPaymentProfileType = New customerPaymentProfileType()
        ccPaymentProfile.payment = cc
        Dim echeckPaymentProfile As customerPaymentProfileType = New customerPaymentProfileType()
        echeckPaymentProfile.payment = echeck
        paymentProfileList.Add(ccPaymentProfile)
        paymentProfileList.Add(echeckPaymentProfile)
        Dim addressInfoList As List(Of customerAddressType) = New List(Of customerAddressType)()
        Dim homeAddress As customerAddressType = New customerAddressType()
        homeAddress.address = MySubRecord.Address
        homeAddress.city = MySubRecord.City
        homeAddress.zip = MySubRecord.ZipCode
        addressInfoList.Add(homeAddress)
        Dim customerProfile As customerProfileType = New customerProfileType()
        customerProfile.merchantCustomerId = Current.Session("UserName")
        customerProfile.email = MySubRecord.EmailAddress
        customerProfile.paymentProfiles = paymentProfileList.ToArray()
        customerProfile.shipToList = addressInfoList.ToArray()
        Dim request = New createCustomerProfileRequest With {.profile = customerProfile, .validationMode = validationModeEnum.none}
        Dim controller = New createCustomerProfileController(request)
        controller.Execute()
        Dim response As createCustomerProfileResponse = controller.GetApiResponse()
        If response IsNot Nothing Then
            If response.messages.resultCode = messageTypeEnum.Ok Then
                If response.messages.message IsNot Nothing Then
                    'Console.WriteLine("Success!")
                    pProfileID = response.customerProfileId
                    pResponse = response
                    'Console.WriteLine("Customer Profile ID: " & response.customerProfileId)
                    'Console.WriteLine("Payment Profile ID: " & response.customerPaymentProfileIdList(0))
                    'Console.WriteLine("Shipping Profile ID: " & response.customerShippingAddressIdList(0))
                End If
            Else
                pProfileID = "ERROR: Code = " & response.messages.message(0).code & "  Message = " & response.messages.message(0).text
                'Console.WriteLine("Customer Profile Creation Failed.")
                'Console.WriteLine("Error Code: " & response.messages.message(0).code)
                'Console.WriteLine("Error message: " & response.messages.message(0).text)
            End If
        Else
            If controller.GetErrorResponse().messages.message.Length > 0 Then
                pProfileID = "ERROR: Code = " & response.messages.message(0).code & "  Message = " & response.messages.message(0).text
                'Console.WriteLine("Customer Profile Creation Failed.")
                'Console.WriteLine("Error Code: " & response.messages.message(0).code)
                'Console.WriteLine("Error message: " & response.messages.message(0).text)
            Else
                pProfileID = "ERROR (NULL response: Code = NULL  Message = NULL"
                'Console.WriteLine("Null Response.")
            End If
        End If
        Return response
    End Function

chartierpw
Contributor
1 REPLY 1

Ok, I figured it out.

 

Turns out that the credit card number contained dashes.  When I set up the screen I used a jQuery input mask to format the credit card number.  Forgot all about it.  Works properly now.

 

 

chartierpw
Contributor