cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving the subscription ID using the get Transaction Report API using the PHP Library

Hi everyone! 

 

I've got a site that's using the authorize.net ARB system. I'm trying to use the Transaction Reporting 'Get Unsettled Transactions List' function to detect when a payment has failed, and change the status of a user's subscription to cancelled. This will be done via the PHP library. 

 

I'm successfully retrieving the  failed payments using the library, but I'm not sure what function I need to use to retrieve the linked subscription ID from the transaction. 

 

My code is based on the sample code here:

 

https://github.com/AuthorizeNet/sample-code-php/blob/master/TransactionReporting/get-transaction-det...

 

Looking at the documentation (http://developer.authorize.net/api/reference/#transaction-reporting-get-transaction-list), I should be able to subscription ID from the subscription->id object. So I'm using the following code:

 

 if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) {
    if(null != $response->getTransactions()){
      foreach($response->getTransactions() as $key => $tx) {
        $data[$key]['transaction_id']  = $tx->getTransId();
        $data[$key]['subscription_id'] = $tx->getSubscription->getId();      }
    }else{
      echo "No unsettled transactions for the merchant." . "\n";
    }
  }else{
    $errorsAndAlerts = "ERROR :  Invalid response\n";
    $errorMessages = $response->getMessages()->getMessage();
    $err

But this isn't working, and I get a 500 error from the server. Does anyone know what the correct function to get the subscription ID is? Is there any documentation for the PHP library that lists all of the functions to retrieve the different variables? 

 

Thanks!

 

Greg

greg162
Member
1 REPLY 1

 

Hi greg162,

 

Your code is correct but it will generate an error if the transaction was not made by a subscription because there will be no subscription node.

 

Thanks,

Joy

Joy
Administrator Administrator
Administrator