Reply
Member
Posts: 1
Registered: ‎12-22-2013

CIM updateCustomerProfileRequest Form Using PHP Throws Error

Background Info:
 
1. We have successfully been able to create the XML post code and form/button to enable the user to create a new profile at Auth.net. We are passing the shipping data. We are NOT passing the billing or the credit card information. We expect the user to add their credit card information on the Auth.net screen. The client does not want to have anything to do with storing or transmitting credit card data. 
 
Goal: They want everything stored at Auth.net so they can use it from there once they are ready to do billing for their products.
 
2. We are storing the ProfileId in our database.
 
3. We are storing the merchantCustomerId in our database (this value is generated by our database)
 
4. Since the customer record should already be in Auth.net, I’m assuming I only need a form and a button with hidden fields for the merchantCustomerId and customerProfileId. When the user clicks the button it should open the Auth.net page to their profile so they can edit it. On a  side note, I experimented with getting another token and passing that too, but it didn’t seem to resolve the problem — I still got the same error.  Below is the form that I created for the purpose of allowing the customer to click the button to edit their profile.
 
<form method="post" action="https://test.authorize.net/profile/manage" id="updateAuthorizeNetPage" style="display:none;">
<input type="hidden" name="merchantCustomerId" value="<?php echo $merchantCustomerId; ?>"/>
<input type="hidden" name="customerProfileId" value="<?php echo $ProfileId; ?>"/>
</form>
<input name="Payment" type="button" value="Edit Payment Method" onclick= "document.getElementById(\'updateAuthorizeNetPage\').submit();">
 
You can see from the enclosed screen shot that I have all the prerequisite data&colon;
merchantCustomerId: 1234
ProfileId: 23129722
 
 
When I click the Edit Payment Method button I get an error back from the Auth.net test server. See enclosed screen shot:
 
 
5. In an attempt to identify what could possible be wrong with the POST to Auth.net I create the following XML call to try to get a response code. The response code comes back empty as you can see from the first screen shot “Update Response Code”. I should be getting at least something back as per the response codes listed in the CIM_SOAP_guide.pdf file on page 95. I know the profile exists because I can use the sample SDK PHP file and delete the profile successfully. Then create a new profile with our working code. Below is the XML code that I used:
 
include_once ("auth_cim/vars.php");
include_once ("auth_cim/util.php");
 
//build xml to post
$content =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<updateCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
MerchantAuthenticationBlock().
"<profile>" .
"<merchantCustomerId>" . $merchantCustomerId . "</merchantCustomerId>" .
"<customerProfileId>" . $ProfileId . "</customerProfileId>".
"</profile>".
"</updateCustomerProfileRequest>";
 
$response = send_xml_request($content);
$parsedresponse = parse_api_response($response);
if ("Ok" == $parsedresponse->messages->resultCode) 
{
// UpdateCustomerProfileResult
$UpdateResponse = htmlspecialchars($parsedresponse->UpdateCustomerProfileResult);
 
// For testing only. Comment out in live version
echo '<br>Update Response Code: ' . $UpdateResponse;
}
 
 
6. Given the information provided here, what is the correct Form and/or XML code that we need to create a button to enable the user to edit their profile at the Auth.net web site, then return back to our web site?
 
Thank You
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: CIM updateCustomerProfileRequest Form Using PHP Throws Error

[ Edited ]

4)xml document. chapter 4  or page 103.  basically everything for hosted form required a token.

5)not sure, maybe it error, couldn't you output the whole response xml?