I am trying to set the merchantCustomerID and Description in the customer profile and when I set the ID the description is blank, but when I comment out that code the description is populated. This is just a simple property assignment, at least so I thought. Can you not have both filled in??
I'm using the C# XML example CustomerProfileAPIXML.
Solved! Go to Solution.
โ10-16-2012 03:17 PM
Unfortunately, I am being paid to do this, so I can't waist my time on something like this. I will just populate all three fields to get the two I want populated and then write some code to go in and delete the email field later. Thanks for your help though.
โ10-17-2012 03:38 PM
It should work with both fields fill in. Can you post your code?
โ10-16-2012 03:50 PM
Here is the code... The values that are being passed are just strings.
/// <summary> /// Create the customer profile /// </summary> /// <returns>The result of the operation</returns> public static long CreateCustomerProfile(CC_Customer cus) { long out_id = 0; createCustomerProfileRequest request = new createCustomerProfileRequest(); XmlAPIUtilities.PopulateMerchantAuthentication((ANetApiRequest)request); customerProfileType m_new_cust = new customerProfileType(); //m_new_cust.email = "fake@example.com"; //m_new_cust.description = "Example customer " + (DateTime.Now.Ticks.ToString()); m_new_cust.merchantCustomerId = cus.AcctNum; m_new_cust.description = cus.Name; request.profile = m_new_cust; System.Xml.XmlDocument response_xml = null; bool bResult = XmlAPIUtilities.PostRequest(request, out response_xml); object response = null; createCustomerProfileResponse api_response = null; if (bResult) bResult = XmlAPIUtilities.ProcessXmlResponse(response_xml,out response); if (!(response is createCustomerProfileResponse)) { ANetApiResponse ErrorResponse = (ANetApiResponse)response; Console.WriteLine(String.Format("Create Customer Profile\n code: {0}\n msg: {1}", ErrorResponse.messages.message[0].code, ErrorResponse.messages.message[0].text)); return out_id; } if (bResult) api_response = (createCustomerProfileResponse)response; if (api_response != null) { out_id = Convert.ToInt64(api_response.customerProfileId); Console.WriteLine("Created Profile #" + out_id); Console.WriteLine(String.Format(" code: {0}\n msg: {1}", api_response.messages.message[0].code, api_response.messages.message[0].text)); } return out_id; }
โ10-17-2012 09:36 AM - edited โ10-17-2012 09:37 AM
So it from the sample CIM XML C# code. I try it and it work fine. I did use a test string of "123" and "abc". Did the console output show the xml input?
โ10-17-2012 11:14 AM
Yeah, no errors when it ran. Just the CustomerID/Description doesn't populate when I see it on the Authorize.NET website. Are only one of these fields supposed to be populated?
โ10-17-2012 11:28 AM
It not the error the console show the xml input. can you post that and masked out your loginID and transactionKey.
โ10-17-2012 11:49 AM
I can't upload pictures locally... There are no errors. Everything comes back successful.
โ10-17-2012 12:36 PM
Is there anyway to debug this? It is referencing AnetApiSchema.cs and using XMLAPIUtilities which is using a web request. I can't get to the source file(s).
After running my code, the description didn't update, so I was able to manually update it through the Authorize.NET site. So the two fields can be populated.
โ10-17-2012 01:06 PM
Just ran it again and uncommented out the email so I was setting all three fields and it ran successfully and the description got popualted with the email and the email got populated correctly. How can we use this if the classes are not working correctly?
โ10-17-2012 01:08 PM
You should be able debug it in PostRequest method and see what the xml generated. Again there isn't any error because the it did get create/update. Maybe it something in your data. it is XML encoded?
What we need is that input xml to see why.
example
<?xml version="1.0" encoding="utf-8"?> <createCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/ AnetApiSchema.xsd"> <merchantAuthentication> <name>API Login ID here</name> <transactionKey>Transaction Key here</transactionKey> </merchantAuthentication> <profile> <merchantCustomerId>Merchant Customer ID here</merchantCustomerId> <description>Profile description here</description> <email>customer profile email address here</email> <paymentProfiles> <customerType>individual</customerType> </paymentProfiles> </profile> <validationMode>none</validationMode> </createCustomerProfileRequest>
โ10-17-2012 01:14 PM - edited โ10-17-2012 01:19 PM