Cancel or refund a transaction

There are a number of ways to cancel or refund a transaction, depending on it's state: