Skip to main content

Cancel a Transaction

"Cancelling" a ToP transaction is actually two distinct SDK operations, depending on whether a result has already come back:

  • Abort an in-flight transaction — the user backs out, or you need to stop waiting for a card tap, before any result has arrived.
  • Void a completed purchase — the transaction already succeeded and you need to reverse it.
Corrected from the source document

The original source document described a single tapSDK.cancelTransaction(amount, cardType, transId, uniqueId, orderId) call. That method name doesn't exist in the working SDK — the real, production-verified call is cancelPurchase, documented below under Void a Completed Purchase, and it takes an appId parameter rather than cardType (see why below).

Abort an In-Flight Transaction​

tapSDK.abortTransaction();

Takes no parameters. Call this any time after startTransactionFlow if you need to stop the flow before a result is returned — for example, if your own UI has a cancel button while waiting for the card tap.

Void a Completed Purchase​

tapSDK.cancelPurchase(amount, appId, transId, uniqueId, orderId);
ParameterTypeNotes
amountStringNo decimal point — same format as Start a Transaction.
appIdStringThe EMV Application Identifier from the original transaction's result, e.g. "A0000000031010". See appId vs. cardType.
transIdStringThe transID from the original transaction's result.
uniqueIdStringSame uniqueId used to start the original transaction.
orderIdStringSame orderId used to start the original transaction.

Example:

tapSDK.cancelPurchase("1000", "A0000000031010", "134436", uniqueId, orderId);

appId vs. cardType​

The original source document's sample used a cardType parameter with example values like "VISA", "MASTERCARD", "MYDEBIT". The real SDK call takes appId — the EMV Application Identifier (e.g. "A0000000031010") — which is a different field from the transaction result, not just a rename:

Result fieldExample valueUse for cancelPurchase
appIdA0000000031010Yes — pass this straight through as appId.
cardLabelVISANo — this is a display label, not accepted by cancelPurchase.

Both fields come back on the original transaction's result — see Flow Overview for the full result field reference.