Reply
Member
Posts: 2
Registered: ‎04-05-2013

Updating Customer Profile

Hi,

 

I trying to update a customer profile (no CC credit info) without modifying any data(read, update) using the following code:

 

$customerProfile = $request->getCustomerProfile($customerProfileId);
   print_r($customerProfile);
   $response = $request->updateCustomerProfile($customerProfileId, $customerProfile);
      print_r($response);

 

Here are the results:

 

AuthorizeNetCIM_Response Object ( [xml] => SimpleXMLElement Object ( [messages] => SimpleXMLElement Object ( [resultCode] => Ok [message] => SimpleXMLElement Object ( [code] => I00001 [text] => Successful. ) ) [profile] => SimpleXMLElement Object ( [merchantCustomerId] => 10752 [description] => 97SA-XBPS-2JYN-DHQ2-EXME-HQTV-U6TA [email] => paul@bpo-automation.com [customerProfileId] => 61505362 [shipToList] => SimpleXMLElement Object ( [firstName] => paul [lastName] => zimmerman [company] => bpo-automation [address] => 3306 del monte blvd. # 60 [city] => marina [state] => ca [zip] => 93933 [country] => usa [phoneNumber] => 6503800207 [faxNumber] => SimpleXMLElement Object ( ) [customerAddressId] => 68994490 ) ) ) [response] => OkI00001Successful.1075297SA-XBPS-2JYN-DHQ2-EXME-HQTV-U6TApaul@bpo-automation.com61505362paulzimm...
3306 del monte blvd. # 60
marinaca93933usa650380020768994490 [xpath_xml] => SimpleXMLElement Object ( [messages] => SimpleXMLElement Object ( [resultCode] => Ok [message] => SimpleXMLElement Object ( [code] => I00001 [text] => Successful. ) ) [profile] => SimpleXMLElement Object ( [merchantCustomerId] => 10752 [description] => 97SA-XBPS-2JYN-DHQ2-EXME-HQTV-U6TA [email] => paul@bpo-automation.com [customerProfileId] => 61505362 [shipToList] => SimpleXMLElement Object ( [firstName] => paul [lastName] => zimmerman [company] => bpo-automation [address] => 3306 del monte blvd. # 60 [city] => marina [state] => ca [zip] => 93933 [country] => usa [phoneNumber] => 6503800207 [faxNumber] => SimpleXMLElement Object ( ) [customerAddressId] => 68994490 ) ) ) ) AuthorizeNetCIM_Response Object ( [xml] => SimpleXMLElement Object ( [messages] => SimpleXMLElement Object ( [resultCode] => Error [message] => SimpleXMLElement Object ( [code] => E00003 [text] => The element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'xml' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'merchantCustomerId, description, email, customerProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. ) ) ) [response] => ErrorE00003The element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'xml' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'merchantCustomerId, description, email, customerProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. [xpath_xml] => SimpleXMLElement Object ( [messages] => SimpleXMLElement Object ( [resultCode] => Error [message] => SimpleXMLElement Object ( [code] => E00003 [text] => The element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'xml' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'merchantCustomerId, description, email, customerProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. ) ) )

 

As you can see the requst is good, but the update fails even though no data is not modified(at least not modied directly by code). Please help. Thanks.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Updating Customer Profile

You can't just use the response directly.

Look at the request for updateCustomerProfile, and response of getCustomerProfile

http://www.authorize.net/support/CIM_XML_guide.pdf

Member
Posts: 2
Registered: ‎04-05-2013

Re: Updating Customer Profile

Thanks and I do apologize but I used the example in the CIM.markdown file located in the PHP SDK:

 

Retrieving a Customer Profile -----------------------------

To retrieve a customer profile call the getCustomerProfile method:

$response = $request->getCustomerProfile($customerProfileId);

 

Updating a Customer Profile ---------------------------

Call the updateCustomerProfile method with the customerProfileId and customerProfile parameters:

$response = $request->updateCustomerProfile($customerProfileId, $customerProfile);

 

I did change the retrieve command slighty (using $customerProfile instead of $response). I'm  not even sure what you mean by "You can't just use the response directly".  Granted I am a C# developer who is trying to grasp some of the PHP object constructs.

 

 I tried using an intermediate object to no avail:

 

   $response = $request->getCustomerProfile($customerProfileId);
   $customerProfile = $response;
   print_r($customerProfile);
   $response = $request->updateCustomerProfile($customerProfileId, $customerProfile);
   print_r($response);

 

 

Could you correct or provide a code snippet ? Thanks.

 

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Updating Customer Profile

[ Edited ]

Sorry, I'm a C# developer too.

But, getCustomerProfile give you

<?xml version="1.0" encoding="utf-8"?>
<getCustomerProfileResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<messages>
		<resultCode>Ok</resultCode>
		<message>
			<code>I00001</code>
			<text>Successful.</text>
		</message>
	</messages>
	<profile>
		<merchantCustomerId>custId123</merchantCustomerId>
		<description>some description</description>
		<email>mark@example.com</email>
		<customerProfileId>10000</customerProfileId>
		<paymentProfiles>
			<billTo>
				<firstName>John</firstName>
				<lastName>Doe</lastName>
				<company></company>
				<address>123 Main St.</address>
				<city>Bellevue</city>
				<state>WA</state>
				<zip>98004</zip>
				<country>USA</country>
				<phoneNumber>000-000-0000</phoneNumber>
				<faxNumber></faxNumber>
			</billTo>
			<customerPaymentProfileId>20000</customerPaymentProfileId>
			<payment>
				<creditCard>
					<cardNumber>XXXX1111</cardNumber>
					<expirationDate>XXXX</expirationDate>
				</creditCard>
			</payment>
		</paymentProfiles>
		<paymentProfiles>
			<customerPaymentProfileId>20001</customerPaymentProfileId>
			<payment>
				<bankAccount>
					<accountType>checking</accountType>
					<routingNumber>XXXX0000</routingNumber>
					<accountNumber>XXXX0000</accountNumber>
					<nameOnAccount>John Doe</nameOnAccount>
					<bankName>Bank of Washington</bankName>
				</bankAccount>
			</payment>
		</paymentProfiles>
		<shipToList>
			<firstName>John</firstName>
			<lastName>Doe</lastName>
			<company></company>
			<address>123 Main St.</address>
			<city>Bellevue</city>
			<state>WA</state>
			<zip>98004</zip>
			<country>USA</country>
			<phoneNumber>000-000-0000</phoneNumber>
			<faxNumber></faxNumber>
		</shipToList>
		<shipToList>
			<firstName>Jane</firstName>
			<lastName>Doe</lastName>
			<address>123 Main St.</address>
			<city>Bellevue</city>
			<state>WA</state>
			<zip>98004</zip>
			<country>USA</country>
			<phoneNumber>000-000-0000</phoneNumber>
		</shipToList>
	</profile>
</getCustomerProfileResponse>

 And the request for updateCustomerProfile is

<?xml version="1.0" encoding="utf-8"?>
<updateCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<merchantAuthentication>
		<name>YourUserLogin</name>
		<transactionKey>YourTranKey</transactionKey>
	</merchantAuthentication>
	<profile>
		<merchantCustomerId>custId123</merchantCustomerId>
		<description>some description</description>
		<email>newaddress@example.com</email>
		<customerProfileId>10000</customerProfileId>
	</profile>
</updateCustomerProfileRequest>

 Bascially, they are different type.