Reply
Member
Posts: 4
Registered: ‎10-16-2013

Re: ARB Subscription IDs Available Through Transaction Details API

looking for more info on ARBGetSubscriptionStatusRequest

 

only returns 

 

Response Code:
Response Reason Code: Ok
Response Text: I00001
Subscription Id: Successful. 

 

not matter what subscription ID I give it

 

and in the ui I can see the subscription ID status is canceld

 

any suggests how to trouble shoot?

 

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Subscription IDs Available Through Transaction Details API

Using a SDK?

or reading the xml?

Here the doc

http://developer.authorize.net/api/arb/

Member
Posts: 4
Registered: ‎10-16-2013

Re: ARB Subscription IDs Available Through Transaction Details API

[ Edited ]

I am using the XML approach.  I am using the example get subscription status code against my authorize account.  I am confident my authorization aspect is working as I can successfully create subscriptions.  I am now adding the ability to check the status in my application.

 

I should have done this sooner, simply echo'd out the response string...(I know what to do now, parse it differently)

 

Here is the $response I got back from the curl call when providing the ARBGetSubscriptionStatusRequest xml string.

 

HTTP/1.1 200 OK Date: Sun, 22 Jun 2014 17:04:01 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/xml; charset=utf-8 Content-Length: 461  OkI00001Successful.expiredexpired

 

The correct status of the supplied subscription Id is at the end of the returned response ...

 

The root of the issue I was/am facing is the format of what is returned is not as expected by the example PHP code I am using. This example code uses the parse_retrun function/method in authnetfunctions.php which looks like the following....

 

//function to parse Authorize.net response
function parse_return($content)
{
$refId = substring_between($content,'<refId>','</refId>');
$resultCode = substring_between($content,'<resultCode>','</resultCode>');
$code = substring_between($content,'<code>','</code>');
$text = substring_between($content,'<text>','</text>');
$subscriptionId = substring_between($content,'<subscriptionId>','</subscriptionId>');
return array ($refId, $resultCode, $code, $text, $subscriptionId);
}

 

It is  obvious what the example code expects back format wise is not what is being returned.

 

Here is the example get sub status code....

 

<?php

/****NOTE***
Please download the PHP SDK available at https://developer.authorize.net/downloads/ for more current code.
*/

/*
D I S C L A I M E R                                                                                        
WARNING: ANY USE BY YOU OF THE SAMPLE CODE PROVIDED IS AT YOUR OWN RISK.                                                                                 
Authorize.Net provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. 
Authorize.Net owns and retains all right, title and interest in and to the Automated Recurring Billing intellectual property.
*/

include ("data.php");
include ("authnetfunction.php");

//define variables to send

$subscriptionId = $_POST["subscriptionId"];


echo "get subscription status <br>";

//build xml to post
$content =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
        "<ARBGetSubscriptionStatusRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
        "<merchantAuthentication>".
        "<name>" . $loginname . "</name>".
        "<transactionKey>" . $transactionkey . "</transactionKey>".
        "</merchantAuthentication>" .
        "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
        "</ARBGetSubscriptionStatusRequest>";

//send the xml via curl
$response = send_request_via_curl($host,$path,$content);
//if curl is unavilable you can try using fsockopen
/*
$response = send_request_via_fsockopen($host,$path,$content);
*/


//if the connection and send worked $response holds the return from Authorize.net
if ($response)
{
  /*
 a number of xml functions exist to parse xml results, but they may or may not be avilable on your system
 please explore using SimpleXML in php 5 or xml parsing functions using the expat library
 in php 4
 parse_return is a function that shows how you can parse though the xml return if these other options are not avilable to you
 */
 list ($resultCode, $code, $text, $subscriptionId) =parse_return($response);

 
 echo " Response Code: $resultCode <br>";
 echo " Response Reason Code: $code<br>";
 echo " Response Text: $text<br>";
 echo " Subscription Id: $subscriptionId <br><br>";
 echo " Data has been written to data.log<br><br>";
 

/* write data to log file or database */
$fp = fopen('data.log', "a");
fwrite($fp, "$subscriptionId\r\n");
fwrite($fp, "$text\r\n");
fclose($fp);

 
}
else
{
 echo "Transaction Failed. <br>";
}
?>

 

 

 

 

 

 

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Subscription IDs Available Through Transaction Details API

HTTP/1.1 200 OK Date: Sun, 22 Jun 2014 17:04:01 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/xml; charset=utf-8 Content-Length: 461  OkI00001Successful.expiredexpired

 

That doesnt look like just the response.

what did you use the echo this?

 

You could change the parse_return to include the subscription status