Skip to main content
2 of 3
added 32 characters in body
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

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.

Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156