cancel
Showing results for 
Search instead for 
Did you mean: 

c# CreateCustomerProfileFromTransaction and ARBCreateSubscriptionRequest - how to handle responses?

Hello!  I'm implementing the creation of ARB recurring payments based on an initial transaction.  I retrieve the necessary information from the successful transaction based on a hosted page, build the createCustomerProfileFromTransactionRequest structure, use it to create the createCustomerProfileFromTransactionController, and retrieve the response with that controller's ExecuteWithApiResponse() method.  Most of my code is copied direct from the API samples in the documentation web pages and GitHub.  Now this is where things get interesting.

 

From the above call, an ARBCreateSubscriptionResponse structure is returned.  The c# sample code suggests that this structure may contain a NULL messages property.  I get this suggestion from the first two lines of this code at https://github.com/AuthorizeNet/sdk-dotnet/blob/maACster/AuthorizeNETtest/Api/Controllers/SampleTest...:

 

 

            //validate
            Assert.NotNull(createResponse);
            Assert.NotNull(createResponse.messages);
            Assert.AreEqual(messageTypeEnum.Ok, createResponse.messages.resultCode);
            Assert.NotNull(createResponse.customerProfileId);
            Assert.NotNull(createResponse.customerPaymentProfileIdList);
            Assert.AreNotEqual(0, createResponse.customerPaymentProfileIdList.Length);

 

and also from this code (from the api reference at https://developer.authorize.net/api/reference/):

 

 

            //validate
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response != null && response.messages.message != null)
                {
                    Console.WriteLine("Success, CustomerProfileID : " + response.customerProfileId);
                    Console.WriteLine("Success, CustomerPaymentProfileID : " + response.customerPaymentProfileIdList[0]);
                    Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]);

The former suggests that the messages property may be null, and the latter suggests that the customer profile id is not retrievable unless response.messages.message is not null.  In the API docs sample code for PHP and Python NEITHER of these condition are checked for, and thus the result code is always available and the customer profile id is always available when the result code indicates success.  The Java API docs look just plain wrong; it appears that somebody cut-and-pasted the wrong code from a mix of transaction processing and profile creation.

 

The ARBCreateSubscriptionResponse has the exact same problem, although at least with it the Java code appears correct.  Again, the C# errors out if the message fields aren't filled out but the other languages don't check for that condition.

 

Could someone please verify what exactly needs to be validated in C#?  Can we assume, as the other languages do, that both response.messages and response.messages.message are never null, and that response.messages.message[0] is always fully and appropriately defined?  This is by far the preferred approach, as it is simplest and aligns with the other languages.

 

I need to know exactly what to expect so that I can define error handling and reporting correctly.  Ideally, the C# API would act exactly as the other languages do.

Please update the documentation, examples, samples and / or tests on both GitHub and the API docs appropriately, but do let us know here asap how we should handle responses so that we all can implement our error handling correctly.

 

Thanks!

 

daves0
Member
1 REPLY 1

Hello

It's been a while since this was first posted. Are you still experiencing this issue?

 

I would recommend subscribing to this topic so that you'll be alerted via email if anyone from the community is able to respond with any comments. To subscribe, click Topic Options at the top of this thread and then select Subscribe. You'll then receive an email once anyone replies.

Thanks,

Richard

RichardH
Administrator Administrator
Administrator