public function getReferringTransactionAttempts($refTransactionId, $transactionOperation = null) {
    $attempts = array();

    if ($refTransactionId !== null && isset($this->transactions) && is_array($this->transactions) && count($this->transactions) > 0) {
      foreach ($this->transactions as $transaction) {
        if ($refTransactionId === $transaction->getRefTransactionId() &&
            ($transactionOperation == null || $transactionOperation === $transaction->getOperation())) {
          $attempts[] = $transaction;
        }
      }

      // Sort the array by transaction date ascending
      if (count($attempts) > 1) {
        usort($attempts,
            function ($t1, $t2) {
              $date1 = $t1->getDate();
              $date2 = $t2->getDate();

              if ($date1 === null && $date2 !== null) {
                return -1;
              }
              if ($date1 !== null && $date2 === null) {
                return 1;
              }

              return ($date1 === $date2 ? 0 : ($date1 < $date2 ? -1 : 1));
            });
      }
    }

    return $attempts;
  }
public function getReferringTransactionAttempts($refTransactionId, $transactionOperation = null) {
    $attempts = array();

    if ($refTransactionId !== null && isset($this->transactions) && is_array($this->transactions) && count($this->transactions) > 0) {
      foreach ($this->transactions as $transaction) {
        if ($refTransactionId === $transaction->getRefTransactionId() &&
            ($transactionOperation == null || $transactionOperation === $transaction->getOperation())) {
          $attempts[] = $transaction;
        }
      }

      // Sort the array by transaction date ascending
      if (count($attempts) > 1) {
        usort($attempts,
            function ($t1, $t2) {
              $date1 = $t1->getDate();
              $date2 = $t2->getDate();

              if ($date1 === null && $date2 !== null) {
                return -1;
              }
              if ($date1 !== null && $date2 === null) {
                return 1;
              }

              return ($date1 === $date2 ? 0 : ($date1 < $date2 ? -1 : 1));
            });
      }
    }

    return $attempts;
  }
public function getReferringTransactionAttempts ( $ refTransactionId , $ transactionOperation = null ) { $ attempts = array ( ) ; if ( $ refTransactionId !== null && isset ( $ this -> transactions ) && is_array ( $ this -> transactions ) && count ( $ this -> transactions ) > 0 ) { foreach ( $ this -> transactions as $ transaction ) { if ( $ refTransactionId === $ transaction -> getRefTransactionId ( ) && ( $ transactionOperation == null || $ transactionOperation === $ transaction -> getOperation ( ) ) ) { $ attempts [ ] = $ transaction ; } } // Sort the array by transaction date ascending if ( count ( $ attempts ) > 1 ) { usort ( $ attempts , function ( $ t1 , $ t2 ) { $ date1 = $ t1 -> getDate ( ) ; $ date2 = $ t2 -> getDate ( ) ; if ( $ date1 === null && $ date2 !== null ) { return - 1 ; } if ( $ date1 !== null && $ date2 === null ) { return 1 ; } return ( $ date1 === $ date2 ? 0 : ( $ date1 < $ date2 ? - 1 : 1 ) ) ; } ) ; } } return $ attempts ; }
Get the transaction attempts referring to the provided transactionId with
the given operation.

@param
refTransactionId The transaction identifier of the referral
(initial) transaction
@param
transactionOperation The operation of the transactions to retrieve
(collection, refund...). If null, all operations are returned.

@return array TransactionAttempt A list with the transactions found (sorted
by date, older first) or
an empty list if not found
Get the transaction attempts referring to the provided transactionId with the given operation .