Manage the token
Alipay+ Tap to Pay allows users to temporarily suspend (lock) and later reactivate (unlock) their Tap to Pay service for security or personal reasons.
Suspending the Tap to Pay service
Workflow
The following figure illustrates the suspending Tap to Pay service workflow:

Suspending the Alipay+ Tap to Pay service consists of the following steps:
- The user requests to suspend the Tap to Pay service on the MPP app. (Step 1)
- The MPP app requests the SDK to lock the card token by calling the lock() API. (Step 2)
- The Alipay+ Tap to Pay SDK sends a request to update the token status on the Ant server. (Steps 3-5)
- The Ant server locks the token on the server side and returns the result to the SDK. (Steps 6-9)
- The SDK locks the token on the client side. (Step 10)
- The SDK returns the result of suspending the service to the MPP app via TokenStatusListener.onTokenLocked. The MPP app then displays the result to the user (Steps 11-12)
Step 1: Initiate the suspension request
The user can request to suspend the Tap to Pay service on your app as needed.
Step 2: Lock the token on the server side
Once the user chooses to suspend the Tap to Pay service, call the lock() API to request the SDK to suspend the Tap to Pay service.
The SDK sends an update token status request to you, and then you need to proxy the request to the Ant server.
The Ant server then locks the token on the server side and returns the result to the SDK.
Step 3: Lock the token on the client side
After receiving the result about the token status change on the server side, the SDK locks the token on the client side. Then the SDK notifies the suspending result to your app, which then displays the suspending result to the user.
For more information about how to use the lock() API on an Android device, see the lock API.
Reactivating the Tap to Pay service
Workflow
The following figure illustrates the reactivating Tap to Pay service flow:

Reactivating the Alipay+ Tap to Pay service consists of the following steps:
- The user requests to reactivate the Tap to Pay service on the MPP app. (Step 1)
- The MPP app requests the SDK to reactivate the Tap to Pay service by calling the unlock() API. (Step 2)
- The SDK verifies that the lifecycle and card states are currently
SUSPENDED. (Step 3) - The Alipay+ Tap to Pay SDK sends a request to update the token status on the Ant server through NFCRequestProxy. (Steps 4-6)
- The Ant server unlocks the token on the server side and returns the result to the SDK. (Steps 7-10)
- The SDK unlocks the token on the client side. (Step 11)
- The SDK returns the result of reactivating the service to the MPP app via TokenStatusListener.onTokenUnLocked. The MPP app then displays the result to the user (Steps 12-13)
Step 1: Initiating the reactivation request
The user can request to reactivate the Tap to Pay service on your app as needed.
Step 2: Unlock the token on the server side
Once the user chooses to reactivate the Tap to Pay service, call the unlock() API to request the SDK to reactivate the Tap to Pay service.
The SDK checks the lifecycle and card state. The card must be in the SUSPENDED state for the reactivation to proceed.
The SDK sends an update token status request to you, and then you need to proxy the request to the Ant server.
The Ant server then unlocks the token on the server side and returns the result to the SDK.
Step 3: Unlock the token on the client side
After receiving the result about the token status change on the server side, the SDK unlocks the token on the client side. Then the SDK notifies the reactivation result to your app, which then displays the reactivation result to the user.
For more information about how to use the unlock() API on an Android device, see the unlock API.