Reply
Contributor
Posts: 19
Registered: ‎07-11-2013

ARB Transaction has no subscription data attached

[ Edited ]

We have a membership that is 2 weeks (14 days) free, then ~$35/month afterwards.

 

So the ARB subscription is created with a start date 2 weeks into the future.

 

[refId] => 9419EF760A2922539392
[subscription] => Array (
  [name] => Membership with free trial
  [paymentSchedule] => Array (
    [interval] => Array (
      [length] => 1
      [unit] => months
    )
    [startDate] => 2019-04-05
    [totalOccurrences] => 9999
  )
  [amount] => 35.00
  [payment] => Array (
    [creditCard] => Array (
      [cardNumber] => 4111111111111111
      [expirationDate] => 12-2019
      [cardCode] => 123
    )
  )
  [order] => Array (
    [invoiceNumber] => 9419EF760A2922539392
    [description] => Membership with free trial
  )
  [billTo] => Array (
    [firstName] => Test
    [lastName] => Person
  )
)

When the Webhook is recieved and we poll for the transaction data, the response has NO `subscription` data with it like we would expect.

 

Here's a sample of the data we're getting about the transaction:

[transaction] => (
  [transId] => 61627073813
  [submitTimeUTC] => 2019-03-20T10:46:44.95Z
  [submitTimeLocal] => 2019-03-20T03:46:44.95
  [transactionType] => authCaptureTransaction
  [transactionStatus] => capturedPendingSettlement
  [responseCode] => 1
  [responseReasonCode] => 1
  [responseReasonDescription] => Approval
  [authCode] => 020636
  [AVSResponse] => Y
  [order] => (
    [invoiceNumber] => 800774C638E101805611
    [description] => Personal
    [discountAmount] => 0
    [taxIsAfterDiscount] =>
  )
  [authAmount] => 35
  [settleAmount] => 35
  [taxExempt] =>
  [payment] => (
    [creditCard] => (
      [cardNumber] => XXXX1111
      [expirationDate] => XXXX
      [cardType] => Visa
    )
  )
  [billTo] => (
    [firstName] => Test
    [lastName] => Person
    [address] => 123 Fake Street
    [city] => Some City
    [state] => TX
    [zip] => 55555
    [country] => US
  )
  [recurringBilling] =>
  [product] => Card Not Present
  [marketType] => eCommerce
)
[messages] => (
  [resultCode] => Ok
  [message] => (
    [0] => (
      [code] => I00001
      [text] => Successful.
    )
  )
)

In some cases `[recurringBilling] =>` will be `[recurringBilling] => 1` and in others its just empty.

 

But there's no indication of the subscription this transaction was for.

 

Here's a sample of what we would expect to be getting:

[transaction] =>  (
  [transId] => 40027109996
  [submitTimeUTC] => 2019-03-22T09:08:21.73Z
  [submitTimeLocal] => 2019-03-22T02:08:21.73
  [transactionType] => authCaptureTransaction
  [transactionStatus] => capturedPendingSettlement
  [responseCode] => 1
  [responseReasonCode] => 1
  [subscription] =>  (
    [id] => 5707378
    [payNum] => 1
  )
  [responseReasonDescription] => Approval
  [authCode] => XC8BL5
  [AVSResponse] => Y
  [cardCodeResponse] => P
  [order] =>  (
    [invoiceNumber] => 9415F30319B437831972
    [description] => Membership without free trial
    [discountAmount] => 0
    [taxIsAfterDiscount] =>
  )
  [authAmount] => 35
  [settleAmount] => 35
  [taxExempt] =>
  [payment] =>  (
    [creditCard] =>  (
      [cardNumber] => XXXX1111
      [expirationDate] => XXXX
      [cardType] => Visa
    )
  )
  [billTo] =>  (
    [firstName] => Test
    [lastName] => Person
  )
  [recurringBilling] =>
  [product] => Card Not Present
  [marketType] => eCommerce
)
[messages] =>  (
  [resultCode] => Ok
  [message] =>  (
    [0] =>  (
      [code] => I00001
      [text] => Successful.
    )
  )
)

Which does have some `subscription` data.

 

Can you please help me figure out why there's no `subscription` data in our transaction poll data?

All Star
Posts: 685
Registered: ‎11-05-2018

Re: ARB Transaction has no subscription data attached

@cartpauj

What you can do is set your subscription data in the line items in the API call. They will be in the response.

Posts: 333
Kudos: 59
Solutions: 36
Registered: ‎03-13-2017

Re: ARB Transaction has no subscription data attached

Hi @cartpauj 

 

You can use the transID you got from the webhook and call the API 

Get Transaction Details https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-transaction-detai...

 

in the response if its subscription transaction you will be able to see the below information also . 

 

<subscription>
<id>5486668</id>
<payNum>1</payNum>
</subscription>

 

 

Thanks
Anurag





Send feedback at developer_feedback@authorize.net
Contributor
Posts: 19
Registered: ‎07-11-2013

Re: ARB Transaction has no subscription data attached

@Anurag 

We are doing that:

 
  public function get_transaction_details($id) {
    return $this->send_request('getTransactionDetailsRequest', array('transId' => $id));
  }
 

But for no explainable reason, some of them return no subscription data, most do.

Contributor
Posts: 19
Registered: ‎07-11-2013

Re: ARB Transaction has no subscription data attached

Anyone have any ideas?

Contributor
Posts: 19
Registered: ‎07-11-2013

Re: ARB Transaction has no subscription data attached

Here's how we're querying the transaction data:

 

  /**
  * Fetch transaction details from the Auth.net API
  * @param int Transaction ID
  * @return object|null JSON decoded transaction object. NULL on API error.
  */
  public function get_transaction_details($id) {
    return $this->send_request('getTransactionDetailsRequest', array('transId' => $id));
  }

  /**
  * Send request to the Auth.net api
  * @param string $type API request type
  * @param array $args API request arguments
  * @return object|null JSON decoded transaction object. NULL on API error.
  */
  public function send_request($type, $args = array()) {
    $post_body = json_encode(
      array(
        $type => array(
          'merchantAuthentication' => array(
            'name' => $this->login_name,
            'transactionKey' => $this->transaction_key
          ),
          'transId' => $args['transId']
        )
      )
    );

    $api_response_body = wp_remote_retrieve_body(wp_remote_post($this->api_endpoint, array('body' => $post_body, 'headers' => array('content-type' => 'application/json'))));
    // Authorize.net is sending some garbage at the beginning of the response body that is not valid JSON
    // Reference: https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851
    $api_response_body = preg_replace('/^[^\{]*/', '', $api_response_body);
    $response_json = json_decode($api_response_body);

    if($response_json->messages->resultCode === 'Error') {
      foreach ($response_json->messages->message as $error) {
        Utils::error_log('Authorize API Error ' . $error->code . '-' . $error->text);
      }
      return null;
    }
    else {
      return $response_json;
    }
  }

We use the following endpoint also: 

https://api.authorize.net/xml/v1/request.api
Highlighted
Member
Posts: 1
Registered: ‎05-30-2019

Re: ARB Transaction has no subscription data attached


@cartpauj wrote:

Here's how we're querying the transaction data:

 

  /**
  * Fetch transaction details from the Auth.net API
  * @param int Transaction ID
  * @return object|null JSON decoded transaction object. NULL on API error.
  */
  public function get_transaction_details($id) {
    return $this->send_request('getTransactionDetailsRequest', array('transId' => $id));
  }

  /**
  * Send request to the Auth.net api
  * @param string $type API request type
  * @param array $args API request arguments
  * @return object|null JSON decoded transaction object. NULL on API error.
  */
  public function send_request($type, $args = array()) {
    $post_body = json_encode(
      array(
        $type => array(
          'merchantAuthentication' => array(
            'name' => $this->login_name,
            'transactionKey' => $this->transaction_key
          ),
          'transId' => $args['transId']
        )
      )
    );

    $api_response_body = wp_remote_retrieve_body(wp_remote_post($this->api_endpoint, array('body' => $post_body, 'headers' => array('content-type' => 'application/json'))));
    // Authorize.net is sending some garbage at the beginning of the response body that is not valid JSON
    // Reference: https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851
    $api_response_body = preg_replace('/^[^\{]*/', '', $api_response_body);
    $response_json = json_decode($api_response_body);

    if($response_json->messages->resultCode === 'Error') {
      foreach ($response_json->messages->message as $error) {
        Utils::error_log('Authorize API Error ' . $error->code . '-' . $error->text);
      }
      return null;
    }
    else {
      return $response_json;
    }
  }

We use the following endpoint also: 

https://api.authorize.net/xml/v1/request.api


Nice compilation here! Thnx for sharing.