See also the Transaction response object.

You can void transactions that have a status of authorized, submitted for settlement, or - for PayPal - settlement pending. The only required information is the transaction ID. When the transaction is voided, we will perform an authorization reversal, if possible, to remove the pending charge from the customer's card.

C♯
Result<Transaction> result = gateway.Transaction.Void("the_transaction_id");

If the transaction is successfully voided, the result will return true. Otherwise, check for validation errors.

C♯
if (result.IsSuccess())
{
    // transaction successfully voided
}
else
{
    foreach (ValidationError error in result.Errors.DeepAll())
    {
        Console.WriteLine(error.Message);
    }
}

If the transaction can't be found, it will throw a NotFoundException.

Arguments
TransactionId required, string

The unique transaction identifier. You can only void transactions that have a Status of: