How to Delete Payment transaction details by id Magento 2?

Once you place an order using an online payment gateway, Gateway details will be stored in the database table sales_payment_transaction.

The table contains the transaction id, payment id, additional_information and many more columns to save the payment data.

If you want to delete a specified transaction record from the table, you can easily remove the given record by the transaction id with the use of the Transaction Repository Interface.

Use deleteByTransactionId() method with argument as transaction_id.

You can see in the function, We are loading the Object and passing that object to the delete method.

Use the given code snippet to delete the transaction record in Magento 2.