alt

Important information

The API reference is now available here.
The deprecated API reference is available here.

Unzer

Cancel a charge (refund)

Learn how to refund payments to your customers.

Overview

Canceling a charge transfers the money back from you (the merchant) to the customer. This is alternatively called refund. You can only perform the cancel transaction on an existing charge. This transaction is possible for all payment methods.

Refund on payment
It is NOT possible to do a refund on the payment resource itself.

Example

Refund is triggered by calling payments/{codeororderid}/charges/{txncode}/cancels endpoint. You can call the cancellation charge with an amount. In this case, only this part of the charge amount is transferred back. If you do not specify an amount, the entire charge is canceled. You can also provide transaction’s description during refund.

{
  "amount" : "50.00",
  "paymentReference" : "Test cancel transaction"
}
Parameter Type Description Default
codeOrOrderId

(required)
Path Parameter — The related payment identity. This can be the paymentCode or Id. null
txnCode

(required)
Path Parameter — The related transaction identity (E.g: s-chg-1) null
amount float Amount in decimal values (for example, 50.00)
paymentReference string Transaction description
{
    "id": "s-cnl-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "50.0000",
    "currency": "EUR",
    "paymentReference": "Test cancel transaction",
    "date": "2018-09-24 22:06:41",
    "resources": {
        "customerId": "s-cst-e769ddae5686",
        "paymentId": "s-pay-6986",
        "basketId": "",
        "metadataId": "",
        "traceId": "bf4ce634575d479eaaac4e6ad436d95d",
        "typeId": "s-crd-qfisvuhm3jog"
    },
    "processing": {
        "uniqueId": "31HA07BC81AB33BC5F44A2659D5E80FC",
        "shortId": "4017.5320.1722"
    }
}

In the previous example, the cancel ID is returned with the value s-cnl-1. The parameters isSuccess, isPending, isError indicate the result of the transaction. Only one of these three can be true.

Status parameter Description
isSuccess The cancellation call was executed successfully.
isPending Never happens.
isError Something went wrong. message.merchant contains more information about the problem.

If there is an error, an error code is displayed in the details with a message for you and the customer.

Parameter Type Description
id string ID of this cancellation transaction
isSuccess boolean If the transaction was successful, the value is set to true.
isPending boolean Never happens for cancellation transaction.
isError boolean If an error occurs, this value is set to true.
message object
message.code string A 9 digit code returned with every API call.
message.customer string Response message for your customer translated into the customer language.
message.merchant string Response message for you. This message appears always in English.
amount string The amount to be refunded on the specified account. The amount is in decimal form, for example,, EUR 1.22.
currency string(3) ISO currency code.
returnUrl string Always empty, due to cancellation is not required to be redirected or confirmed payment.
paymentReference string The description of the transaction.
date date Timestamp of this transaction.
resources object
resources.customerId string Customer ID used for parent charge transaction.
resource.basketId string Basket ID used for parent charge transaction.
resource.metadataId string Metadata ID used for parent charge transaction.
resources.paymentId string ID of the payment object.
resources.traceId string The unique traceId of the transaction. Used for internal API purposes.
resources.typeId string ID of the types resource which was used for parent charge transaction.
processing object
processing.uniqueId string Reference id of the cancellation transaction.
processing.shortId string User-friendly reference ID of the cancellation transaction.
processing.iban string Your (merchant) IBAN in case of prepayment or invoice. In case of direct debit this value contains the customer IBAN.
processing.bic string Your (merchant) BIC for prepayment or invoice. In the case of a direct debit, this value contains the customer BIC.
processing.identification string This value returns the descriptor for invoice and prepayment.
processing.creatorId string This value returns your creditor ID.

For a full description of the cancel call, see API reference guide.

See also