Cancel an in-progress charge
stopTransaction aborts a charge that has not been authorized yet, while the SDK is waiting for the customer to tap the card.
:::danger Never cancel while the card is being read
Do not call stopTransaction while the SDK is reading the card β that is, from the moment it fires onReadingCardData(). Interrupting the dialogue with the chip leaves the transaction in an indeterminate state: the reader may have moved on without your app knowing. Wait for the outcome and, if the charge needs undoing, use a reversal.
:::
The safe window to cancel is between onPresentCardRequest() and onReadingCardData(). After the read, in USER_CONFIRMATION mode the way to not charge is to answer transactionConfirmation(sendTransactionAuthorization = false), not stopTransaction.
:::caution MIGO_PAY only
stopTransaction is only implemented on MIGO_PAY. On MIGO_LINK_* integrations the call does nothing and no callback fires: the charge continues at the reader. There, the customer cancels from the reader's own flow.
:::
:::info This is not a reversal To undo a charge that was already authorized, the method is different and so is the flow. See Reverse an authorized charge. :::
Abortingβ
import com.migo.sdkmigo.domain.usecasesparams.StopTransactionParams
migoSDK.stopTransaction(StopTransactionParams(mActivity = this))
The SDK responds with onTransactionCancelled() and always with onGeneralException(STATE_TRANSACTION_CANCELLED_BY_USER, β¦). That second callback is the confirmation of the cancellation, not a failure β handle it apart from the other exceptions:
override fun onGeneralException(exception: GeneralMigoException?, message: String?) {
when (exception) {
GeneralMigoException.STATE_TRANSACTION_CANCELLED_BY_USER -> {
// Expected cancellation, not an error
}
else -> showError("Error: $message")
}
}
Once aborted, the charge cannot be resumed: start a new one if payment is still required.
When you can no longer abortβ
stopTransaction stops applying the moment the processor authorizes. From onVoucherDataResponse with isTransactionApproved = true onward, the money has moved and the path is a reversal.
doTransaction()
β
ββ onPresentCardRequest β
stopTransaction is safe
ββ onReadingCardData β NEVER cancel
ββ onReturnCurrentTransactionInfo
β β³ to not charge: transactionConfirmation(false)
ββ authorized β³ to undo: reversal
Relatedβ
- Reverse an authorized charge β undo an already approved charge.
- Process a Terminal Payment β the charge step by step.