Try to inject Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory
into your constructor:
protected $transactions;
public function __constructor(
\Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory $transactions,
......
)
{
$this->transactions = $transactions;
}
In your method:
$transactions = $this->transactions->create()->addOrderIdFilter($orderId);
$transactions->getItems();
If Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory
doesn't work, try to use \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory
. I'm not test yet both of them.