cancel
Showing results for 
Search instead for 
Did you mean: 

C# API getTransactionDetailsController returning null customer profile

Am trying to add a subscription to a previously created transaction using the C# API.  The customer profile was created as part of the transaction.  Confirmed that the transaction and customer profile were created as expected.

 

Before I can make an API call to create a subscription from a customer profile, I need to retrieve the customer profile ID and the payment profile ID from the transaction detail. However, when I call getTransactionDetailsController with the transaction ID, it returns a null profile object.

 

I'm new to the Auth.Net so I think I'm missing something simple.  Here's the code:

 

static void GetTransactionCustomerProfileID(string transactionID, 
                                            out string customerProfileID, 
                                            out string customerPaymentProfileID)
{
    customerProfileID = null;
    customerPaymentProfileID = null;

    ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
    ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
    {
        name = ApiLoginID,
        ItemElementName = ItemChoiceType.transactionKey,
        Item = ApiTransactionKey,
    };

    var request = new getTransactionDetailsRequest();
    request.transId = transactionID;

    // instantiate the controller that will call the service
    var controller = new getTransactionDetailsController(request);
    controller.Execute();

    // get the response from the service (errors contained if any)
    var response = controller.GetApiResponse();

    if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
    {
        if (response.transaction != null)
        {
            Console.WriteLine("Transaction Id: {0}", response.transaction.transId);
            Console.WriteLine("Transaction type: {0}", response.transaction.transactionType);
            Console.WriteLine("Transaction status: {0}", response.transaction.transactionStatus);
            Console.WriteLine("Transaction auth amount: {0}", response.transaction.authAmount);
            Console.WriteLine("Transaction settle amount: {0}", response.transaction.settleAmount);
            // ====================  profile is NULL! ============================= 
            customerProfileID = response.transaction.profile.customerProfileId;  // profile is NULL! 
            customerPaymentProfileID = response.transaction.profile.customerPaymentProfileId;
        }
    }
    else if (response != null)
    {
        Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                          response.messages.message[0].text);
    }

return;
}

 

 

 

 

 

 

jwilson2000
Member
1 ACCEPTED SOLUTION

Accepted Solutions

This does appear to be the case and I somehow missed that there is an API function to create a customer profile from an existing transaction (createCustomerProfileFromTransactionRequest) that appears to return the existing IDs if they were actually created within the transaction (or in a previous transaction).  This should let me do what I need to.

View solution in original post

3 REPLIES 3

The customer profile details of the transaction do not appear in the virtual terminal's transaction detail screen or if I retrieve the details through the API Live console in the API documentation for Get Transaction Details.  I don't think my problem is specifically related the C# API.

 

When a new charge transaction is created with the flag set to create customer profile record, does it not tie that new record to the transaction that caused it to be created?

jwilson2000
Member

After some more experimentation, it looks like the profile fields are only populated on a transaction when the transaction is initially created from a customer profile and not when the transaction creates the customer profile.

 

Can someone confirm?

This does appear to be the case and I somehow missed that there is an API function to create a customer profile from an existing transaction (createCustomerProfileFromTransactionRequest) that appears to return the existing IDs if they were actually created within the transaction (or in a previous transaction).  This should let me do what I need to.