GTS Joe
GTS Joe

Reputation: 4192

Authorize.net: "createTransactionRequest" has invalid child element "clientId"

I am trying to make a test transaction using my Laravel 7 app and Authorize.net.

After submitting the sample data, I'm getting:

The element 'createTransactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'clientId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.

enter image description here

Anyone know what's causing this error or how to fix it?

Upvotes: 2

Views: 2802

Answers (2)

GTS Joe
GTS Joe

Reputation: 4192

Well, I'll answer my own question since it might help others. The problem is the error message in the Authorize.net response is really vague.

Kurt Friars' comment was helpful, since it pointed me in the right direction. As for Mansour Hamcherif's suggestion, the merchantAuthentication object was set in my app, it just didn't have the right values, so it wasn't that.

The solution for me was setting the proper values to setName() and setTransactionKey(). The previous developer who had worked on this project had left values and the credentials had expired. I did a Linux text search for "setTransactionKey", which lead me to the correct PHP file where I need to set:

$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName('EnterYourLoginNameHere');
$merchantAuthentication->setTransactionKey('EnterYourTransactionKey');

After that, I cleared all of my Laravel app's caches as well as my browser's caches, did a hard reload, tried a transaction again and it worked! I got:

This transaction has been approved., Transaction ID: **********.

Upvotes: 5

Mansour Hamcherif
Mansour Hamcherif

Reputation: 129

You may want to check the log for the raw request, it's likely the merchantAuthentication object has not been set, if you are using the PHP SDK I recommend checking the SimpleCodeConstants.php file and make sure your merchant credentials constants are set.

For example, if I set my merchant credentials to NULL, I get the same E00003 error as a result of sending the following raw request:

{"createTransactionRequest":{"merchantAuthentication":[],"clientId":"sdk-php-2.0.0-ALPHA", ...}

Upvotes: 0

Related Questions