Voiding a transaction

Transaction voiding is performed to cancel an authorization of funds on a credit card, and it is not applicable to other payment methods.

During the payment authorization, balance on the card is authorized for a certain amount, which means that customer cannot spend it elsewhere during the duration of authorization.

If you decide that you do not wish to actually charge the card, after the authorization has been made, you void the transaction, which causes the reserved funds to be released to the customer so that he can spend them elsewhere.

Void

To void a transaction, just provide a transaction UID an call an appropriate API method.

Transaction txn = gateway.transaction().voidTransaction("txn_5uErTAjnRBTKpL");

Result

To check if the transaction has been voided, make sure that the Transaction.status returned is VOIDED.

if (txn.getStatus() == Transaction.Status.VOIDED) {
    // Success
}

Errors

If you attempt to void a transaction which cannot be voided (i.e. which does not have an AUTHORIZED status) Library will raise an Exception.