cancel
Showing results for 
Search instead for 
Did you mean: 

CIM Integration: Getting the initial TOKEN and/or initial Profile

We are attempting to use the CIM system.  The instructions tell us that we first need to aquire a token in order to create a blank profile.

 

I can't find any instructions or methods on aquiring that token that actually work.

 

I'm trying to use the downloaded example files for this process.   The exact system I'm using is the file located at  /php_cim/xml/profile_create.php, which was aquired by downloading the php_cim package from this site.

 

I've made all modifications required (ID's and servers changed to what is actually required),  but I still only get back a response that says:

 

"[E00045] The root node does not reference a valid XML namespace."

 

I've quadruple-checked the small amount of code that is provided in the download package to be sure I haven't missed a modification I needed to do, and I have not missed any of them.

 

The message returned from the authorizenet server when using that file also makes a reference (in the 'raw response') to an address that I'm thinking might be the reason for the error message.

The line says "xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"

 

The part of that line that I'm concerned with is 'AnetAPI'.   In the example code provided to me here,  I'm told that I have to change all references of 'AnetAPI' to the actxual server that I'm supposed to use for the transaction (which I have done).

I no longer have 'AnetApi' in any part of my code.  I even swept through all the code on the server and found no pages that have AnetApi on them at all.

 

The only way that the term 'AnetAPI' could be coming back in the raw response,  if my conclusion is correct,  is if it is being used at the 'other end' of the transaction.. at AuthorizeNet's servers.

 

There may be a perfectly good explanation as to why AN would have 'AnetApi' in their code,  and it may have nothing to do with this system not functioning,  but I can't see anything else that could be causing the error that is coming up.

 

When I sent a support request in,  explaining our situation and that we couldn't even get a TOKEN to be returned to us (due to not being able to find any instructions on how to get it),  the response we got back literally said, "Once you are able to obtain the one-time tokens, you can find examples of how to integrate the hosted payment form into your site in our developer forums".

 

There was no explanation on how to actually get the token, which was what my question was to begin with.

 

I've mentioned this before and have yet to get a reply to it.

 

Our site needs to be able to accept payments.  We want to use CIM for our customers security.  We've been at this for days now, and if we can't even get the first thing done (the token request),  we're just spinning our wheels here.

 

Here is the example code we downloaded that produces the error we are getting (unused code edited out to save room):

 

Page Name:  index.php

<form method=post action=profile_create.php>
<b>Create Customer Profile</b><br>
email <input type=text name=email value='example@example.com'><br>
<input type=submit name=submit value=submit>
</form>

 

Page Name: profile_create.php

<?php

include_once ("vars.php");
include_once ("util.php");

echo "create profile...<br><br>";

//build xml to post
$content =
	"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
	"<createCustomerProfileRequest xmlns=\"https://api.authorize.net/xml/v1/request.api\">" .
	MerchantAuthenticationBlock().
	"<profile>".
	"<merchantCustomerId>123_Our_Customer_ID</merchantCustomerId>". 
	"<description></description>".
	"<email>" . $_POST["email"] . "</email>".
	"</profile>".
	"</createCustomerProfileRequest>";

echo "Raw request: " . htmlspecialchars($content) . "<br><br>";
$response = send_xml_request($content);
echo "Raw response: " . htmlspecialchars($response) . "<br><br>";
$parsedresponse = parse_api_response($response);
if ("Ok" == $parsedresponse->messages->resultCode) {
	echo "customerProfileId <b>"
		. htmlspecialchars($parsedresponse->customerProfileId)
		. "</b> was successfully created.<br><br>";
}

echo "<br><a href=index.php?customerProfileId="
	. urlencode($parsedresponse->customerProfileId)
	. ">Continue</a><br>";
?>

 Page Name: vars.php

<?php
$g_loginname = "234_Our_ID";
$g_transactionkey = "345_Our_Key";
$g_apihost = "api.authorize.net";
$g_apipath = "/xml/v1/request.api";

?>

 

 Page Name:  util.php

<?php

include_once ("vars.php");

function send_xml_request($content)
{
	global $g_apihost, $g_apipath;
	return send_request_via_fsockopen($g_apihost,$g_apipath,$content);
}

function send_request_via_fsockopen($host,$path,$content)
{
	$posturl = "ssl://" . $host;
	$header = "Host: $host\r\n";
	$header .= "User-Agent: PHP Script\r\n";
	$header .= "Content-Type: text/xml\r\n";
	$header .= "Content-Length: ".strlen($content)."\r\n";
	$header .= "Connection: close\r\n\r\n";
	$fp = fsockopen($posturl, 443, $errno, $errstr, 30);
	if (!$fp)
	{
		$body = false;
	}
	else
	{
		error_reporting(E_ERROR);
		fputs($fp, "POST $path  HTTP/1.1\r\n");
		fputs($fp, $header.$content);
		fwrite($fp, $out);
		$response = "";
		while (!feof($fp))
		{
			$response = $response . fgets($fp, 128);
		}
		fclose($fp);
		error_reporting(E_ALL ^ E_NOTICE);
		
		$len = strlen($response);
		$bodypos = strpos($response, "\r\n\r\n");
		if ($bodypos <= 0)
		{
			$bodypos = strpos($response, "\n\n");
		}
		while ($bodypos < $len && $response[$bodypos] != '<')
		{
			$bodypos++;
		}
		$body = substr($response, $bodypos);
	}
	return $body;
}

//function to send xml request via curl
function send_request_via_curl($host,$path,$content)
{
	$posturl = "https://" . $host . $path;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $posturl);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	$response = curl_exec($ch);
	return $response;
}

function parse_api_response($content)
{
	$parsedresponse = simplexml_load_string($content, "SimpleXMLElement", LIBXML_NOWARNING);
	if ("Ok" != $parsedresponse->messages->resultCode) {
		echo "The operation failed with the following errors:<br>";
		foreach ($parsedresponse->messages->message as $msg) {
			echo "[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text) . "<br>";
		}
		echo "<br>";
	}
	return $parsedresponse;
}

function MerchantAuthenticationBlock() {
	global $g_loginname, $g_transactionkey;
	return
        "<merchantAuthentication>".
        "<name>" . $g_loginname . "</name>".
        "<transactionKey>" . $g_transactionkey . "</transactionKey>".
        "</merchantAuthentication>";
}

?>

 

 When we run the profile_create.php page (by clicking the button on index.php),  we get this returned:

 

  Raw request: <?xml version="1.0" encoding="utf-8"?><createCustomerProfileRequest xmlns="https://api.authorize.net/xml/v1/request.api"><merchantAuthentication><name>234_Our_ID</name><transactionKey>345_Our_Key</transactionKey></merchantAuthentication><profile><merchantCustomerId>123_Our_Customer_ID</merchantCustomerId><description></description><email>example@example.com</email></profile></createCustomerProfileRequest>

 Raw response: <?xml version="1.0" encoding="utf-8"?><ErrorResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Error</resultCode><message><code>E00045</code><text>The root node does not reference a valid XML namespace.</text></message></messages></ErrorResponse>

The operation failed with the following errors:
[E00045] The root node does not reference a valid XML namespace.

 

 From what I understand,  this page is supposed to create a new CIM profile for a customer,  not throw this error.

 

 Our account is live and in test mode.

 

 Any idea what I'm doing wrong?

 

Thanks,

JB

 

 

WHeisenberg
Regular Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

Holy crap I got it.

 

The line that indicates I'm supposed to use a specific server said this:

<createCustomerProfileRequest xmlns=\"https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd ?\">

 

When it was SUPPOSED to say this:

<createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">

 

Not only did the page tell me to change that line to my server address, it also didn't mention taking out the question mark.

 

Once I did both of those, I got this back:

 

resultCode: Ok

customerProfileID: 1935xxxx

customerProfileId 1935xxxx was successfully created.

 

WOOT!

 

So now on to the next problem and THANK YOU VERY MUCH for your help on this.

 

Truly, respectfully,

JB

View solution in original post

10 REPLIES 10

I think the schema(xmlns=) is either for production server https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd

or for test server https://apitest.authorize.net/xml/v1/schema/AnetApiSchema.xsd

RaynorC1emen7
Expert

I tried those as well, and the amount of errors generated was astounding.

 

Here's a taste of what happens when I use those servers:

 

Raw request: <?xml version="1.0" encoding="utf-8"?><createCustomerProfileRequest xmlns="https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd"><merchantAuthentication><name>123_MY_ID</name><transactionKey>123_MY_KEY</transactionKey></merchantAuthentication><profile><merchantCustomerId>1123_MY_CUST_ID</merchantCustomerId><description></description><email>my2@example.com</email></profile></createCustomerProfileRequest>

Raw response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>The page cannot be displayed</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana } H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color: red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> <h1>The page cannot be displayed</h1> The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. <hr> <p>Please try the following:</p> <ul> <li>Contact the Web site administrator if you believe that this request should be allowed.</li> <li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. </li> </ul> <h2>HTTP Error 405 - The HTTP verb used to access this page is not allowed.<br>Internet Information Services (IIS)</h2> <hr> <p>Technical Information (for support personnel)</p> <ul> <li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>405</b>.</li> <li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr), and search for topics titled <b>Setting Application Mappings</b>, <b>Securing Your Site with Web Site Permissions</b>, and <b>About Custom Error Messages</b>.</li> </ul> </TD></TR></TABLE></BODY></HTML>


Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 11: parser error : Opening and ending tag mismatch: META line 3 and HEAD in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 11: parser error : AttValue: " or ' expected in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 11: parser error : attributes construct error in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 11: parser error : Couldn't find end of Start Tag TABLE line 11 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 21: parser error : Opening and ending tag mismatch: br line 21 and h2 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: d to access this page is not allowed.<br>Internet Information Services (IIS)</h2 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 30: parser error : Opening and ending tag mismatch: hr line 22 and TD in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </TD></TR></TABLE></BODY></HTML> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 30: parser error : Opening and ending tag mismatch: h2 line 21 and TR in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </TD></TR></TABLE></BODY></HTML> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 30: parser error : Opening and ending tag mismatch: hr line 15 and TABLE in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </TD></TR></TABLE></BODY></HTML> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 30: parser error : Opening and ending tag mismatch: TD line 11 and BODY in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </TD></TR></TABLE></BODY></HTML> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 30: parser error : Opening and ending tag mismatch: TR line 11 and HTML in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: </TD></TR></TABLE></BODY></HTML> in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 31: parser error : Premature end of data in tag BODY line 11 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 31: parser error : Premature end of data in tag HEAD line 2 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 31: parser error : Premature end of data in tag HTML line 2 in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: in \php_cim\XML\util.php on line 86

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in \php_cim\XML\util.php on line 86

The operation failed with the following errors:

Warning: Invalid argument supplied for foreach() in \php_cim\XML\util.php on line 89

 

-----------

That's the mess I get...

 

Oddly enough,  none of the errors reported seem to have anything at all to do with code 'on my site', and is all coming from whatever is being passed with the response data.

 

The line that seems to be getting the most attention in the errors is line 86 of the utils.php file.

 

Line 86 is this:

$parsedresponse = simplexml_load_string($content, "SimpleXMLElement", LIBXML_NOWARNING);

 

I followed the instructions listed in the response.. went to MS and looked up the 405 error.  All it told me was that the inbound information is using an HTTP verb that is not allowed.

 

I have no clue what that means and the MS site doesn't go any further about it.   What could the inbound reply from AuthorizeNet be doing to cause a 405 error when using that particular xml/schema server when it's not doing the same thing when using the original server (which fails to work, but doesn't throw the 405)?

Does something special have to be set at the server end to allow this 'HTML verb' thing?  If so,  what is it?

 

Confused :(

JB

 

Feel dumb now..

 

I found out what HTTP verb was (POST, GET,.. etc)

 

Still,   I don't know what the respose is trying to use that isn't set up on my server.

 

I would assume that since the response is supposed to be sending me information to parse,  it is using POST (could be wrong).

 

 

Looking thru my old test code, the xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd" is correct.

Ok, so I wont worry about that.

 

I did a search in these forums for the term "The root node does not reference a valid XML namespace" and the only thing I came up with (other than my own posts) was a single post with the same issue.

 

The response provided from AuthNet was basically saying "That error shouldn't effect using the system, just ignore it".

 

If you look at the response I'm getting when that error happens,  there is nothing else provided to me but the error.   If I'm requesting a token, or anything else for that matter, and all I get back is that error.. it doesn't matter if I just 'ignore it' or not,  I'm not getting the data I'm requesting.

 

Something else must be wrong.  If the xml/schema results are tossing me those huge errors (above) because the server isn't recognizing the inboud HTTP request type, I have no control over that at my end.   My server is set up to accept whatever gets thrown at it.. so it's either malformed incoming code in the request header,  or a request type that the server doesn't naturally accept.

 

WIthout knowing what request type is inbound,  I can't even begin to try to fix it.   Any ideas what that 'HTTP verb" is that my server seems to be rejecting?

 

Thanks for your help.   SERIOUSLY considering not continuing this process for CIM and just using SIM.. at least we got that working :)

 

 

I altered the response page code so that it would, at least, tell me what the actual response code that was coming back from AuthNet is.

 

I added:

 

echo "resultCode: " . htmlspecialchars($parsedresponse->messages->resultCode) . "<br><br>";

 

This worked as intended.

 

The page now shows resultCode: Error 

 

So 'Error' is the resultCode coming back.

 

To take it a step further,  I thought..  If what has been said is that the error code can be 'ignored' because the SDK should be working anyway,  maybe the reason the customer profile ID isn't showing up on the screen is because it was saying "If there is an error, show the error, otherwise show the customer profile ID".

 

So,  I added this:

echo "customerProfileID: " . htmlspecialchars($parsedresponse->customerProfileId) . "<br><br>";

 

When I ran the page again,  the customerProfileID output was blank.. so it is not being passed back (and probably not being created at all)

 

If my code going 'to' AuthNet is correct for this request,  and all I get back is an error about a namespace (and no customerProfileID),  I can't see how anything I'm doing at my end is causing it.

 

Is there some separate setting in the actual merchant login/admin area of AuthorizeNet that has to be changed specifically for CIM?

If so,  we've never been told that.

 

Our account is live and set for test mode.   If we try to use the SIM payment process,  it works for testing and even says 'Account is in Test Mode' at the top of the payment screen.

 

What am I missing?

 

JB

 

 

I'm grabbing at straws at this point.

 

I'm not sure if this means anything,  but in the raw response that comes back from AuthorizeNet it has this:

 

http://www.w3.org/2001/XMLSchema-instance

 

Upon researching that particular address (since the part with the AnetAPI has been ruled out as a problem),  I came across this:

 

This schema should never be used as such:  the XML Schema Recommendation forbids the declaration of attributes in this namespace

 

Maybe the part of the results that has the AnetAPI line is taking care of whatever that problem might be.. but the error about an invalid namespace has to come from somewhere.. and the only part of any code that even references a namespace is coming from AuthorizeNet back to my page.

 

If I'm not the one providing the incorrect namespace (or any namespace at all for that matter), then the only remaining possibility is that it's coming from AuthorizeNet.

 

Sigh..

 

<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><merchantAuthentication><name>1234567890</name><transactionKey>1234567890123456</transactionKey></merchantAuthentication><profile><merchantCustomerId>1123_MY_CUST_ID</merchantCustomerId><description></description><email>my2@example.com</email></profile></createCustomerProfileRequest>

It work for me (C#).

 

It return the "The root node does not reference a valid XML namespace." error only when I change the xmlns to https://api.authorize.net/xml/v1/request.api

Holy crap I got it.

 

The line that indicates I'm supposed to use a specific server said this:

<createCustomerProfileRequest xmlns=\"https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd ?\">

 

When it was SUPPOSED to say this:

<createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">

 

Not only did the page tell me to change that line to my server address, it also didn't mention taking out the question mark.

 

Once I did both of those, I got this back:

 

resultCode: Ok

customerProfileID: 1935xxxx

customerProfileId 1935xxxx was successfully created.

 

WOOT!

 

So now on to the next problem and THANK YOU VERY MUCH for your help on this.

 

Truly, respectfully,

JB