Switched to using AuthnetXML.class.php for all api calls. When I add a payment profile to a customer profile, I'll get a response like this:
<createCustomerPaymentProfileResponse>
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<customerPaymentProfileId>8227492</customerPaymentProfileId>
</createCustomerPaymentProfileResponse>
but even though it's successful, I find that $xml->isError() always returns 1. Am I missing something?
Solved! Go to Solution.
09-03-2012 08:24 PM
I was able to verify this bug. It's kinda odd since all I did was change comparison operators from === to == and it works properly now. In this case === should work so I'm going to see if i can figure out why it doesn't out of curiousity.
If you go to github you can get the updated code or just edit your Authnet.class.php file like so:
public function isSuccessful()
{
return $this->response_xml->messages->resultCode === 'Ok';
}
public function isError()
{
return $this->response_xml->messages->resultCode !== 'Ok';
}
becomes
public function isSuccessful()
{
return $this->response_xml->messages->resultCode == 'Ok';
}
public function isError()
{
return $this->response_xml->messages->resultCode != 'Ok';
}
10-04-2012 06:07 PM
Does this happen with any other APIs calls? Or only this one?
09-03-2012 09:55 PM
Seems to happen with others as well. I haven't tried all, of course, but here's another example. If I run
$xml->createTransactionRequest($my_request_array);
per the example in authnetxml\examples\aim\createTransactionRequest_authCapture.php, I get the following odd result:
Results
| Response | Ok |
| code | I00001 |
| Successful? | no |
| Error? | yes |
| authCode | YRZ26K |
| transId | 2177473315 |
The php for the Successful? and Error? values is this:
<?php echo ($xml->isSuccessful()) ? 'yes' : 'no'; ?>
<?php echo ($xml->isError()) ? 'yes' : 'no'; ?>
And the raw $xml Input/Output shows this:
Class ParametersRequest XMLResponse XML
| API Login ID | --removed-- |
| Transaction Key | --removed-- |
| Authnet Server URL | https://apitest.authorize.net/xml/v1/request.api |
| XML: | <?xml version="1.0"?>
<createTransactionRequest>
<merchantAuthentication>
<name>--removed--</name>
<transactionKey>--removed--</transactionKey>
</merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>10</amount>
<payment>
<creditCard>
<cardNumber>370000000000002</cardNumber>
<expirationDate>012014</expirationDate>
</creditCard>
</payment>
</transactionRequest>
</createTransactionRequest>
|
| XML: | <?xml version="1.0" encoding="utf-8"?>
<createTransactionResponse>
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<transactionResponse>
<responseCode>1</responseCode>
<authCode>YRZ26K</authCode>
<avsResultCode>Y</avsResultCode>
<cvvResultCode/>
<cavvResultCode>2</cavvResultCode>
<transId>2177473315</transId>
<refTransID/>
<transHash>E1EEC3AF4D823851243E2810EBFF5E95</transHash>
<testRequest>0</testRequest>
<accountNumber>XXXX0002</accountNumber>
<accountType>AmericanExpress</accountType>
<messages>
<message>
<code>1</code>
<description>This transaction has been approved.</description>
</message>
</messages>
</transactionResponse>
</createTransactionResponse>
|
Weird, no?
I'm running under a sandbox/test account, of course. Would that matter?
10-04-2012 09:19 AM
So I need to know:
1. Am I doing something wrong?
2. Is there a problem with AuthnetXML?
3. Should I ignore the isError and isSuccessful values and just test for messages->resultCode == "OK" ?
4. Is AuthnetXML the official Authorize.Net recommended way to go, or should I go back to using the individual api classes?
Thanks
10-04-2012 09:58 AM
I was able to verify this bug. It's kinda odd since all I did was change comparison operators from === to == and it works properly now. In this case === should work so I'm going to see if i can figure out why it doesn't out of curiousity.
If you go to github you can get the updated code or just edit your Authnet.class.php file like so:
public function isSuccessful()
{
return $this->response_xml->messages->resultCode === 'Ok';
}
public function isError()
{
return $this->response_xml->messages->resultCode !== 'Ok';
}
becomes
public function isSuccessful()
{
return $this->response_xml->messages->resultCode == 'Ok';
}
public function isError()
{
return $this->response_xml->messages->resultCode != 'Ok';
}
10-04-2012 06:07 PM
Thank you!! I've corrected my copy of the file. Hey, I'd love to know why the === doesn't work, if you ever figure that out!
10-04-2012 06:15 PM