I'm new to working with XML, and I'm using the SDK to check the status of an ARB subscription, using the following code: (I am using my test account credentials in the right places below)
require_once('AuthorizeNet.php');
define("AUTHORIZENET_API_LOGIN_ID", "");
define("AUTHORIZENET_TRANSACTION_KEY", "");
$subscription_id = xxxxxxx;
$status_request = new AuthorizeNetARB;
$status_response = $status_request->getSubscriptionStatus($subscription_id);
$status = $status_response->status;
var_dump($status_response);
echo "status = ". $status;
I've just included the var_dump($status_response) to verfiy that I'm getting something. The transaction is working since $status_response gets set properly, but $status is not getting set.
I'm sure I'm missing something incredibly obvious here, in getting a value assigned to $status. I would like to be able to set variables to the values in the XML nodes in the response, but can't seem to get it to work.
Also, the November 2011 revision of the Merchant Web Services API ARB XML Guide no longer includes the documentation of the "getSubscriptionStatus" API that was included in the copy of the guide I downloaded in June. Is Authorize.net planning to discontinue this? Or was this an oversight in the new revision?
Thanks in advance for your help.
Solved! Go to Solution.
11-14-2011 04:51 PM
11-16-2011 04:12 AM
According to the documentation:
<ARBGetSubscriptionStatusResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <refId>Sample</refId> <messages> <resultCode>Ok</resultCode> <message> <code>I00001</code> <text>Successful</text> </message> </messages> <Status>active</Status> </ARBGetSubscriptionStatusResponse>
Could it perhaps be that you're using status instead of Status? PHP is case-sensitive, I believe. If changing that doesn't work, post the results of print_r($status_response) in a code box (fourth option from the left when posting in Rich Text mode). This should make it more clear what the structure is coming out as.
11-15-2011 12:03 AM
Thanks for the reply and for the codebox tip. Here's the code I'm using again, in codebox for clarity:
require_once('AuthorizeNet.php'); define("AUTHORIZENET_API_LOGIN_ID", ""); define("AUTHORIZENET_TRANSACTION_KEY", ""); $subscription_id = xxxxxxx; $status_request = new AuthorizeNetARB; $status_response = $status_request->getSubscriptionStatus($subscription_id); $status = $status_response->Status; print_r($status_response); echo "</br>status = ". $status;
The output of the print_r($status_response); is this (from view source):
AuthorizeNetARB_Response Object ( [xml] => SimpleXMLElement Object ( [@attributes] => Array ( [note] => Status with a capital 'S' is obsolete. ) [messages] => SimpleXMLElement Object ( [resultCode] => Ok [message] => SimpleXMLElement Object ( [code] => I00001 [text] => Successful. ) ) [status] => active [Status] => active ) [response] => <?xml version="1.0" encoding="utf-8"?><ARBGetSubscriptionStatusResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" note="Status with a capital 'S' is obsolete." xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><status>active</status><Status>active</Status></ARBGetSubscriptionStatusResponse> [xpath_xml] => SimpleXMLElement Object ( [messages] => SimpleXMLElement Object ( [resultCode] => Ok [message] => SimpleXMLElement Object ( [code] => I00001 [text] => Successful. ) ) [status] => active [Status] => active ) ) </br>status =
The response includes a status node in both cases, and I've tried my code with both cases. $status is still not being assigned a value.
11-15-2011 07:04 AM
Try this:
$status = $status_response->xml->status;
11-16-2011 04:12 AM
Thanks for your help. I knew I was missing something obvious. Just didn't realize it was going to be THAT obvious.
I'm having another problem though. It appears that all of my transactions are submitting twice, because now createsubscription and cancelsubscription transactions are coming back from the testing server with reponses that indicate it's an attempt to duplicate a subscription and saying that the subscription has already been cancelled. I'm going to start a new thread for that.
Thanks again.
11-16-2011 09:44 AM