Reply
Highlighted
Member
Posts: 6
Registered: ‎09-25-2017

E00039 A duplicate record already exists

I havent found an answer to my problem yet, so i figured i would start a new thread.

I am using the GitHub Sample C# project to test out how Authorize.Net works and how i would implement it into our current system.

I have a sandbox account, i can run all of the code samples, but i am getting an error when i try to create a new customer profile.

I have changed all of the data so nothing is the same, still getting the error.  I went to the online sandbox pages and deleted the one and only customer profile i had in there.

Run GetCustomer...  (all of them) they all return empty.

I run CreateCustomerProfile again, and I still get the E00039 returned.

 

What am i doing wrong?  

Highlighted
All Star
Posts: 699
Registered: ‎11-03-2016

Re: E00039 A duplicate record already exists

Hi @mts176,

 

The duplicate checking on profile creation is explained in the Customer Profiles documentation. For each API call in the table, at least one of those fields must be unique to create a new profile and avoid this error.

 

In our online API Reference Guide, each section has a "Try it" tab with an interactive window allowing you to send requests directly to our API. If you try a createCustomerProfile request there with your sandbox credentials and that works, then the problem is in your code somewhere.

 

If you're still not finding success, you may want to post a sample here of the code that's generating the error (so we can see how you're populating the various fields).

Highlighted
Member
Posts: 6
Registered: ‎09-25-2017

Re: E00039 A duplicate record already exists

I can't get it to work.

This is my code.

 

Snippet

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
         ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
         {
             name = AuthNetLoginID,
             ItemElementName = ItemChoiceType.transactionKey,
             Item = AuthNetTransActionKey,
         };
 
         List<customerAddressType> addressInfoList = new List<customerAddressType>();
 
         customerAddressType officeAddress = new customerAddressType
         {
             firstName = ppai.FirstName,
             lastName = ppai.LastName,
             address = ppai.Address,
             city = ppai.City,
             state = ppai.State,
             zip = ppai.Zip,
             phoneNumber = ppai.Phone
         };
 
         addressInfoList.Add(officeAddress);
 
         customerProfileType customerProfile = new customerProfileType
         {
             merchantCustomerId = ppai.FirstName + "." + ppai.LastName,
             description = ppai.FirstName + " " + ppai.LastName + "/" + ppai.DealerName,
             email = ppai.Email,
             shipToList = addressInfoList.ToArray()
         };
 
         var request = new createCustomerProfileRequest
         {
             profile = customerProfile
            // validationMode = validationModeEnum.none
         };
 
         var controller = new createCustomerProfileController(request);
         // instantiate the contoller that will call the service
         controller.Execute();
 
         createCustomerProfileResponse response = controller.GetApiResponse();

 

I have made sure the merchantCUstomerID, description, and email are always different.  I have 2 fake customers in currently.  I made them both through the online Customer Information Manager tool supplied by Sandbox.Authorize.net.

I have also deleted all customers and tried to run this code but i still got the error.

 

Any help would be much appreciated.

 

Highlighted
Authorize.Net Expert
Posts: 84
Registered: ‎11-16-2017

Re: E00039 A duplicate record already exists

@mts176

I have copied your code and tried out the request. I have replaced with string values for address. I am able to successfully get the customerProfileID. 

 

From your post, i see that your emailID is already unique. Can you please put your code in debug mode and make sure the variable is changing ?

 

FYI to try randomize the emailID. (https://stackoverflow.com/questions/1344221/how-can-i-generate-random-alphanumeric-strings-in-c) 

string emailId = string.Format("{0}@test.com", RandomString(5));

 

Pls. let us know if you are still facing the issue. 

 

-Bhavana

 

======Customized code copied from yours====

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

List<customerAddressType> addressInfoList = new List<customerAddressType>();

customerAddressType officeAddress = new customerAddressType
{
firstName = "Test",
lastName = "Test",
address = "Test",
city = "Test",
state = "WA",
zip = "98052",
phoneNumber = "4448999098"
};

addressInfoList.Add(officeAddress);

customerProfileType customerProfile = new customerProfileType
{
merchantCustomerId = "FirstName" + "." + "LastName",
description = "FirstName" + " " + "/" + "DealerName",
email = emailId,
shipToList = addressInfoList.ToArray()
};

var request = new createCustomerProfileRequest
{
profile = customerProfile
// validationMode = validationModeEnum.none
};

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

createCustomerProfileResponse response = controller.GetApiResponse();