Token status
Each token status value indicates the current state of a user's card. The following APIs return a token status:
- isPaymentAvailable
- activatePayment (via callback)
- activatePaymentInSlientMode (via ActivateStatusListener)
isPaymentAvailable evaluates the following conditions in order and returns immediately when the first condition is met:
- Returns
-3if the white-box cryptography module failed to initialize. - Returns
-2if the SDK is not connected. - Returns
11if a credential replenishment is in progress. - Otherwise, returns the token status retrieved from the local query.
Checking whether a card can pay
Call isPaymentAvailable before displaying a tap-to-pay entry point, and handle the result as shown below.
void prepareForTap(String userId) {
ACTapManager manager = ACTapManager.getInstance(getApplication());
switch (manager.isPaymentAvailable()) {
case TokenStatus.TOKEN_STATUS_READY_TO_TAP:
// The card can pay. Nothing to do.
break;
case TokenStatus.TOKEN_STATUS_ACTIVATED_WITH_NO_CREDENTIALS:
manager.replenish(null);
break;
case TokenStatus.TOKEN_STATUS_LOCKED:
manager.unlock();
break;
case TokenStatus.TOKEN_NOT_CONNECTED:
manager.connect(userId, null);
break;
case TokenStatus.TOKEN_STATUS_NOT_EXIST:
case TokenStatus.TOKEN_STATUS_NOT_CONFIRMED:
// Start activation. For TOKEN_STATUS_NOT_CONFIRMED, call
// NFCActivateParams.setDoConfirm(true) first so the user confirms the card.
break;
case TokenStatus.TOKEN_WB_UNAVAILABLE:
// This device cannot support tap payment. Do not retry on it.
break;
case TokenStatus.TOKEN_STATUS_IN_PROGRESS:
case TokenStatus.TOKEN_STATUS_UNKNOWN:
// Wait and check again. Do not start a second activation or replenish.
break;
}
}Token status values
Code | Value | Description | Further action | Returned by |
|
| The white-box cryptography module required by this SDK is not available on this device. Evaluated first; all other states are hidden when this applies. | This device does not support tap-to-pay payment. Do not retry on this device. | isPaymentAvailable only |
|
| No user is connected, or the user has already disconnected. | Call connect with the user ID. | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| The token status could not be determined. Possible causes: an invalid input parameter (errorCode | Check the errorCode returned with this value to identify the cause. | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| No card exists for this user, or the card is not activated, is marked for deletion, or is in an unresolvable state. | Call activatePayment. If errorCode | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| The card is active but has no credentials available for payment. | Call replenish. | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| The card is active and has at least one valid credential. This is the only value that confirms a tap can succeed. | No action required. | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| The card is suspended by the server. | Call unlock. | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
|
| A replenishment or activation is already running. | Wait and check again. Do not start a second replenishment or activation. | isPaymentAvailable only |
|
| The card is active but the user has not yet confirmed it. | Call activatePayment with NFCActivateParams.setDoConfirm(true). | isPaymentAvailable, activatePayment, and activatePaymentInSlientMode |
deleteToken and token status
deleteToken does not return a token status. It calls isPaymentAvailable internally and proceeds only if the result is 1, 2, or 3. For any other value, it returns false with errorCode 10004.
APIs that return similar-looking values
The following APIs return integer values that resemble token status codes but represent different things. Do not use their return values as token status inputs.
- replenish callback: Returns
1for success and0for failure. The-2value is an exception and does indicateTOKEN_NOT_CONNECTED. - getAvailableCredentialsCounts: Returns the number of available credentials, or
-2when the SDK is not connected.