I am using the transactionCaller.php script in Laravel. It is giving me an error "
$transRequestXmlStr=<<<XML <?xml version="1.0" encoding="UTF-8"?> <createTransactionRequest xmlns="http://AnetApi/xml/v1/schema/AnetApiSchema.xsd">However, when I receive the XML back it has the namespace without the HTTP:// so I get the error. It is not a warning in Laravel it is a 500 error.
12-31-2020 11:00 AM
Hello,
Authorize.Net uses a relative namespace path which the SDK's XML library complains about.
The solution is don't include the xmlns attribute in your construction of the SimpleXML element object and use SimpleXMLElement::addAttribute after the fact to add it.
Instead of this:
$element = new SimpleXMLElement('<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"/>');
Do this:
$element = new SimpleXMLElement('<createTransactionRequest/>'); $element->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
To avoid these errors when parsing the response, simply strip the xmlns attribute out of the response before parsing it with SimpleXML using the following:
$result = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $result);
($result in this example is the raw XML as returned by Authorize.Net.)
01-04-2021 02:59 AM - edited 01-04-2021 03:01 AM