Voiding Transactions

You can void transactions that have a status of authorized or submitted_for_settlement. All you need is the transaction ID. When the transaction is voided Braintree will do an authorization reversal if possible so that the customer won’t have a pending charge on their card.

Result<Transaction> result = gateway.transaction().voidTransaction("the_transaction_id");

Checking the Result

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

if (result.isSuccess()) {
    // transaction successfully voided
} else {
    for (ValidationError error : result.getErrors().getAllDeepValidationErrors()) {
        System.out.println(error.getMessage());
    }
}

Validations