Cancel Request

An overview of the Cancel Request message.

Overview

Please see below for information on configuring the Cancel Request, as well as the expected Cancel Response.

The Cancel Request is used to Cancel (void) a payment - either partially or fully - which occurred within the current business day (until 22:00 GMT+2) or to refund a successful payment - either partially or fully - which occurred prior to the current business day (i.e. after the clearance process has taken place1)

1 Note: the clearance process also takes place on weekends and holidays

txCancelRequest

txCancelRequest executes a typical transaction cancellation or refund. The operation depends on whether the Sale transaction to be cancelled/refunded was made on the same day (cancellation) or any day before that (refund). Please note the parameters below and how they apply to different cancellation/refund scenarios further down.

Field Type Length (chars) Description Example Required Card terminal support
msgLength String 4 A 4-digit number padded with leading zeros indicating message length minus 4 (including any separators). The request will be rejected if the correct message length is not provided. ‘0061’ Android Card TerminalsLinux Card Terminals
sessionId String 6 A unique number to control integrity of session sequence. ‘002690’ Android Card TerminalsLinux Card Terminals
msgType String 3 ‘200’ ‘200’ Android Card TerminalsLinux Card Terminals
msgCode String 2 ‘04’ ‘04’ Android Card TerminalsLinux Card Terminals
uniqueTxnId String 32 A unique transaction ID transmitted to the host for storage with the transaction. Note that this value will be provided in the MerchantTrns field provided in the sales export response. ‘12345678901234567890123456789012’ Android Card TerminalsLinux Card Terminals
amount String variable up to 13 Amount always including 2 decimal digits following the decimal point. A dot must always be used as a decimal point. If the amount is less than the transaction's full amount and the transaction date is today, then an error is returned as only a void is possible and therefore a full amount must be given. In all other cases, the amount can be partial to enable partial refunds. If no amount is supplied, it is assumed that the transaction amount is to be returned. ‘123.00’ Android Card TerminalsLinux Card Terminals
refNum String 6 The STAN number of the transaction to be cancelled. Note that if the STAN value is unknown the application may provide the value ‘000000’. In that case, after card presentment, the terminal will provide a list of the last 3 transactions made with the presented card, allowing the user to select the transaction to be canceled. ‘826987’ Android Card TerminalsLinux Card Terminals
sourceTerminalId String 8 Optional. The terminal ID of the source with which the transaction is associated. ‘12345678’ Android Card TerminalsLinux Card Terminals
txnDateFrom

(NOT YET SUPPORTED)
String 24 Optional. If supplied and no orderCode or refNum is given, then the returned transactions are within the txnDateFrom and txnDateTo bounds. If it is not supplied, then the last three transactions are returned as is the case with the current protocol. '2021-03-18T14:42:53.341Z' Android Card Terminals
txnDateTo

(NOT YET SUPPORTED)
String 24 Optional. If supplied and no orderCode or refNum is given, then the returned transactions are within the txnDateFrom and txnDateTo bounds. If it is not supplied, then the last three transactions are returned as is the case with the current protocol. If a txnDateFrom is supplied and no txnDateTo is given, then the application assumes that txnDateTo is today's date. If a txnDateTo is supplied without a txnDateFrom, then an error must be returned. '2021-03-20T14:42:53.341Z' Android Card Terminals
orderCode String 16 Optional. Can be provided instead of or together with a refNum number. If a txnDateFrom/txnDateTo is provided, then the returned transaction results are bound by these dates, otherwise the last three transactions are returned. '1069120310000201' Android Card Terminals
shortOrderCode String 10 Optional. Can be provided instead of or together with a refNum number. If a txnDateFrom/txnDateTo is provided, then the returned transaction results are bound by these dates, otherwise the last three transactions are returned. '1069120310' Android Card Terminals
protocol String 20 The protocol used (for internal use only) 'ecr_default' Android Card Terminals

The above information elements must be joined into one single string using ‘|’ as a separator. i.e.

0061|002690|200|04|12345678901234567890123456789012|123.00|826987

If the resulting string gets appropriately transmitted to the terminal, the terminal will respond with a txResponse message.

If only the amount is communicated during the refund and no order code is given:

If the order code is communicated during the refund and no amount is given, then it is assumed that the entire amount is to be refunded:

If the order code is communicated during the refund and an amount is given:

Notes

txCancelResponse

After executing a Cancel transaction the terminal responds with a txCancelResponse to indicate if the transaction has been approved or not.

A txCancelResponse for a successful cancel transaction looks as follows:

Linux Card Terminals:

0069|000050|210|04|00||MASTERCARD|537535******1339|856749|000000|16016684

Android Card Terminals:

0177|000028|210|04|00|00|MASTERCARD|************9228|800760|| 16000281|2048160106000202|2048160106||||||||23aee237-1704-4502-a61b-93941e9ad682|2022-02-17T16:21:18.0546831+02:00|2

The table below summarises the contents of the response.

Field Length (chars) Description Example Card terminal support
msgLength 4 A 4-digit number padded with leading zeros indicating the character length of the message that follows (including separators). Before considering the msgLength value, please make sure that you've decoded the terminal response with UTF-8. '0073' Android Card TerminalsLinux Card Terminals
seqTxnId 6 A 6-digit number matching the value sent in seqTnxNum field of the preceding txReady message. '000050' Android Card TerminalsLinux Card Terminals
msgTypeResp 3 '210' '210' Android Card TerminalsLinux Card Terminals
msgCodeResp 2 '04' '04' Android Card TerminalsLinux Card Terminals
respCodeResp 2 Approval status. '00' indicates approval. All other values indicate failure codes. See failure code table at the end. '00' Android Card TerminalsLinux Card Terminals
respMessageResp variable
up to 60
Empty '' Android Card TerminalsLinux Card Terminals
cardTypeResp variable A string indicating the card type. 'MASTERCARD' Android Card TerminalsLinux Card Terminals
accNumberResp variable A string indicating the card number. Note that only the 6 first and the 4 last digits are provided. All the rest digits are masked with stars. '537535******1339' Android Card TerminalsLinux Card Terminals
refNumResp 6 A 6-digit number indicating the transaction's STAN number. '856749' Android Card TerminalsLinux Card Terminals
authCodeResp 6 '000000' '000000' Android Card TerminalsLinux Card Terminals
eftTidResp 12 A 12-character string indicating the terminal's TID number, padded with spaces if required. '16016684' Android Card TerminalsLinux Card Terminals
orderCode 16 A 16-digit numeric string representing the order code. '1062160242000098' Android Card Terminals
shortOrderCode 10 A 10-digit numeric string representing the short order code. '1062160242' Android Card Terminals
MerchantReceiptPAN Variable up to 19 This field contains the value of the PAN (and additional clipping) that should be printed in merchant receipt. If is empty, then apply the default clipping. '629914XXXXXXXXX6770' Linux Card Terminals
CardholderReceiptPAN Variable up to 19 This field contains the value of the PAN (and additional clipping) that should be printed in customer receipt. If is empty, then apply the default clipping. '629914XXXXXXXXX6770' Linux Card Terminals
CardholderReceiptText Variable up to 200 If is not empty then this value should be printed at the end of the customer receipt. 'qwerty123456' Linux Card Terminals
TransactionReceiptAcquirerZone Variable up to 200 If it is not empty then this value should be printed at the end of the customer receipt. 'qwerty123456' Linux Card Terminals
CardholderName Variable up to 50 Name of the cardholder. 'CARDHOLDER NAME' Linux Card Terminals
CardExpirationDate 4 Expiration date of the card (YYMM). '2212' Linux Card Terminals
CardholderName&ExpirationDateFlags 4 Each char may be 0 (false) or 1 (true) and indicates if the cardholder name and the expiration date should be printed on the merchant/cardholder receipts).

1st char: if 1 then the Cardholder Name should be printed in the merchant's receipt. If 0, then it should not.

2nd char: if 1 then the Cardholder Name should be printed in the cardholder's receipt. If 0, then it should not.

3rd char: if 1 then the Expiration Date should be printed in the merchant's receipt. If 0, then it should not.

4th char: if 1 then the Expiration Date should be printed in the cardholder's receipt. If 0, then it should not.
'1062160242' Linux Card Terminals
transactionId variable up to 50 The id of the transaction b3e2744a-71ec-4d51-a856-c2f70249bdd4 Android Card Terminals
transactionDate variable up to 50 The date of the transaction 2021-12-15T16:34:49.4495733+02:00 Android Card Terminals
transactionType variable up to 2 The type of the transaction. You can see all the possible transaction types in the Transaction Type Table 1 Android Card Terminals

It is expected that certain transactions will fail for various reasons. A txSaleResponse for a failed transaction looks as follows:

0177|000041|210|04|51|Declined|MASTERCARD|************9228||| 16000281|2048160107000202|2048160107||||||||560ccbc5-c6b1-4375-9639-5096b6eff70d|2022-02-17T16:32:37.4649383+02:00|2

The structure of the message is the same as in the case of an approved transaction.

Differences are limited to two specific fields.

Obviously authCodeResp contain zeros since there is no STAN code available, nor an authorisation code.

Failure reasons

See Failure reasons and ISO codes under txSaleResponse. These are the same for all transaction types (Sales, Cancellations and Pre-auths).

Get Support

If you would like to integrate with Viva, or if you have any queries about our products and solutions, please see our Contact & Support page to see how we can help!