Reply
csi
Member
Posts: 5
Registered: ‎09-23-2011
Accepted Solution

ARB PHP SDK Code submitting transactions twice?

I'm using the ARB SDK to test the subscription cancel function. (I verified the subscription number is active using the Recurring Billing web interface in my test account prior to running the script.)

 

This code

require_once('AuthorizeNet.php');
define("AUTHORIZENET_API_LOGIN_ID", ""); 
define("AUTHORIZENET_TRANSACTION_KEY", "");

$subscription_id = 1215796;

// Create the subscription. 
$cancellation = new AuthorizeNetARB;
$cancel_response = $cancellation->cancelSubscription($subscription_id);

$response_resultCode = $cancel_response->xml->messages->resultCode;
$response_code = $cancel_response->xml->messages->message->code;
$response_string = $cancel_response->xml->messages->message->text;
$status = $cancel_response->xml->status;

echo "<br /><br />subscription_id = ". $subscription_id . "<br /><br />";		
print_r($cancel_response);
echo "<br /><br />response_resultCode = ". $response_resultCode;	
echo "<br /><br />response_code = ". $response_code;	
echo "<br /><br />response_string = ". $response_string;	
echo "<br /><br />status = ". $status;

 Results in the following output (from view page source):

 

<br /><br />subscription_id = 1215796<br /><br />AuthorizeNetARB_Response Object
(
    [xml] => SimpleXMLElement Object
        (
            [messages] => SimpleXMLElement Object
                (
                    [resultCode] => Ok
                    [message] => SimpleXMLElement Object
                        (
                            [code] => I00002
                            [text] => The subscription has already been canceled.
                        )

                )

        )

    [response] => <?xml version="1.0" encoding="utf-8"?><ARBCancelSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00002</code><text>The subscription has already been canceled.</text></message></messages></ARBCancelSubscriptionResponse>
    [xpath_xml] => SimpleXMLElement Object
        (
            [messages] => SimpleXMLElement Object
                (
                    [resultCode] => Ok
                    [message] => SimpleXMLElement Object
                        (
                            [code] => I00002
                            [text] => The subscription has already been canceled.
                        )

                )

        )

)
<br /><br />response_resultCode = Ok<br /><br />response_code = I00002<br /><br />response_string = The subscription has already been canceled.<br /><br />status = 

 According to the documentation, if successful, ARB should return an I00001 response code and the xml node <status> should be "canceled."  Code I00002 isn't documented in the ARB guide.  This makes me think my transaction is being submitted twice.  Am I correct, and while I can make my application work around this, is this a problem?


Accepted Solutions
Solution
Accepted by topic author csi
‎08-21-2015 01:58 AM
csi
Member
Posts: 5
Registered: ‎09-23-2011

Re: ARB PHP SDK Code submitting transactions twice?

As you suggested, combining a "get status" transaction and a "cancel" transaction in the same script seems to work as it should, and the cancel script print_r results in a successful cancellation of the subscription.  If I run the cancel script by itself, I get the result text I posted above.  I'm cutting and pasting the script from the ARB markdown file in the SDK, so I'm not sure what I could be doing wrong.

 

I can make what I need to do work, though.  Thanks for your help.

View solution in original post


All Replies
Posts: 1,609
Topics: 15
Kudos: 200
Solutions: 121
Registered: ‎06-23-2011

Re: ARB PHP SDK Code submitting transactions twice?

The first step is always to do a dummy check. Load the subscription status in the same script and print it out, so you can be sure it's actually active. If it's active and then the cancel says it's not, something could be wrong with the API (though I'm pretty sure I implemented cancellation without problems). If it's inactive and the control panel says it's active, then that tells you something else. Either way, you'll have narrowed the possibilities.

 

This is more likely to be user error than a problem with the PHP API, however.

Solution
Accepted by topic author csi
‎08-21-2015 01:58 AM
csi
Member
Posts: 5
Registered: ‎09-23-2011

Re: ARB PHP SDK Code submitting transactions twice?

As you suggested, combining a "get status" transaction and a "cancel" transaction in the same script seems to work as it should, and the cancel script print_r results in a successful cancellation of the subscription.  If I run the cancel script by itself, I get the result text I posted above.  I'm cutting and pasting the script from the ARB markdown file in the SDK, so I'm not sure what I could be doing wrong.

 

I can make what I need to do work, though.  Thanks for your help.