Showing results for 
Search instead for 
Did you mean: 

SDK C# - AuthorizeAndCapture send a System.NullReferenceException


now i am a fresh in


I had a developer account.

when i set ApiLogin and TransactionKey to sandbox account, all of adding shipping address, payment method, and checkout page is working fine.


but when i set ApiLogin and TransactionKey to live account(but the account is in Test mode),in checkout page, customerGateway.AuthorizeAndCapture send a  System.NullReferenceException.


Therefore, i check the customerGateway is null or not. but it never be null.

and when i add payment method, i did validation checking like the following...


var response = gateway.ValidateProfile(profileId, creditCardId, validationModeEnum.testMode);

(the live account is in test mode, so i set the validationMode to testMode)


It gets a correct response.


but now in checkout page,

the following code send a NullReferenceException...


var response = customerGateway.AuthorizeAndCapture(user.ProfileId,


I am sure, user.ProfileId, paymentMethod.ProfileID, and total value are all correct. I double checked.


but unfortunately it sends NullReferenceException.

Here is details exception message.


System.NullReferenceException was caught
  Message=Object reference not set to an instance of an object.
       at AuthorizeNet.HttpXmlUtility.CheckForErrors(ANetApiResponse response)
       at AuthorizeNet.HttpXmlUtility.Send(ANetApiRequest apiRequest)
       at AuthorizeNet.CustomerGateway.AuthorizeAndCapture(Order order)
       at AuthorizeNet.CustomerGateway.AuthorizeAndCapture(String profileID, String paymentProfileID, Decimal amount, Decimal tax, Decimal shipping)
       at AuthorizeNet.CustomerGateway.AuthorizeAndCapture(String profileID, String paymentProfileID, Decimal amount)
       at Pump.Monday.Web.Extensions.CheckoutService.PlaceOrderVDNA(Int64 userId, MCheckoutModel model, FormCollection formValues) in D:\oDesk\codebasehq\vitamindna\vitamindna\Web\Extensions\CheckoutService.cs:line 260
       at Pump.Monday.Web.Controllers.EvaluationController.Checkout(MCheckoutModel model, FormCollection formValues) in D:\oDesk\codebasehq\vitamindna\vitamindna\Web\Controllers\EvaluationController.cs:line 637


Please help me to fix this issue.

I already spend 3 whole days to fix this issue.

Quick reply is really appreciated.

Thanks for your time.


Any potential code issues here are unlikely to be the source of the problem.  It's important to understand that "test mode" is to be used for only very basic account connectivity testing using AIM or SIM.  When using test mode, no transaction data is stored at any time and add on services such as Automated Recurring Billing (ARB) and Customer Information Manager (CIM) cannot be used.


The error that you are seeing is most likely due to the fact that you are attempting to use CIM while your account is in test mode. CIM can be tested using one of our developer test accounts, but it can only be used in live mode on a production account.

Administrator Administrator

i have also faced this problem.

i downloaded the Source and debugged through the code.


When the account is in test mode, there seems to be a bug in the CheckForErrors Method where it is trying to access a non existing child element , whereas in live mode it works fine.