alt

Important information

Please be advised that there will be a scheduled downtime across our API network on November 05 and November 07, 2024. For more information, visit our platform status portal.:
- Scheduled maintenance on November 5, 2024
- Scheduled maintenance on November 7, 2024

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"
}
ParameterTypeDescriptionDefault
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
amountfloatAmount in decimal values (for example, 50.00)
paymentReferencestringTransaction 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 parameterDescription
isSuccessThe cancellation call was executed successfully.
isPendingNever happens.
isErrorSomething 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.

ParameterTypeDescription
idstringID of this cancellation transaction
isSuccessbooleanIf the transaction was successful, the value is set to true.
isPendingbooleanNever happens for cancellation transaction.
isErrorbooleanIf an error occurs, this value is set to true.
messageobject
message.codestringA 9 digit code returned with every API call.
message.customerstringResponse message for your customer translated into the customer language.
message.merchantstringResponse message for you. This message appears always in English.
amountstringThe amount to be refunded on the specified account. The amount is in decimal form, for example,, EUR 1.22.
currencystring(3)ISO currency code.
returnUrlstringAlways empty, due to cancellation is not required to be redirected or confirmed payment.
paymentReferencestringThe description of the transaction.
datedateTimestamp of this transaction.
resourcesobject
resources.customerIdstringCustomer ID used for parent charge transaction.
resource.basketIdstringBasket ID used for parent charge transaction.
resource.metadataIdstringMetadata ID used for parent charge transaction.
resources.paymentIdstringID of the payment object.
resources.traceIdstringThe unique traceId of the transaction. Used for internal API purposes.
resources.typeIdstringID of the types resource which was used for parent charge transaction.
processingobject
processing.uniqueIdstringReference id of the cancellation transaction.
processing.shortIdstringUser-friendly reference ID of the cancellation transaction.
processing.ibanstringYour (merchant) IBAN in case of prepayment or invoice. In case of direct debit this value contains the customer IBAN.
processing.bicstringYour (merchant) BIC for prepayment or invoice. In the case of a direct debit, this value contains the customer BIC.
processing.identificationstringThis value returns the descriptor for invoice and prepayment.
processing.creatorIdstringThis value returns your creditor ID.

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

See also