Cancel an authorization

Cancel the reserved amount for a payment.


Canceling an authorization releases the reserved money for the customer’s payment method. This is also called reversal. You can only perform the cancel transaction on an existing authorization. This transaction is possible for selected payment methods only. Please check Payment methods page for details.

icon info
Total amount
If you cancel an authorization, the total amount of the payment is reduced by the amount reversed.


Reversal is triggered by calling payments/{codeororderid}/authorize/cancels endpoint. You can cancel the authorization with an amount. In this case, only the specified authorization amount is released. If you do not specify an amount, the entire authorization is canceled.


// full cancel on Authorization
$unzer         = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$authorization = $unzer->fetchAuthorization('s-pay-1');
$cancellation  = $authorization->cancel();
// part cancel on Authorization
$unzer         = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$authorization = $unzer->fetchAuthorization('s-pay-1');
$cancellation  = $authorization->cancel(50.0);

Arguments to Authorize::cancel

Parameter Type Description
amount float The amount to reduce the authorization by. The method will perform a full cancel of the authorization (and payment) if the amount is not set.

Transaction Results

The transaction response is stored in the transaction object. It contains a paymentId (for example, s-pay-1) the transactionId and other properties of the response. The transaction object provides getter functions to access those properties. For example, cancel.getPaymentId().

The parameters isSuccess, isPending, isError indicate the result of the transaction. Only one of these three can be true.

If a transaction fails, the payment API will return an error resource instead of a transaction. In the SDK this is handled as an UnzerApiException. Make sure to catch that case properly.

You can find an example for the transaction response on the Cancel an authorization (reversal) page.

try {
    $unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
    $authorization= $unzer->fetchAuthorization($paymentId, $chargeId);
    $cancellation  = $authorization->cancel(100.0);

    if ($cancelation->isSuccess) {
        // Handle successful Cancelation
} catch (UnzerApiException $e) {
    // Transaction failed. API returned error resource.
    // Handle failed Cancelation
} catch (RuntimeException $e) {
    $merchantMessage = $e->getMessage();

See also