Silent activation preparation
To improve user experience, you should initiate the activation preparation process before the user accesses the Alipay+ NFC activation page. This process includes SDK initialization, security information gathering, card token application and activation, as well as NFC payment credential replenishment.
This guide describes how to process the preparation phase of silent activation.
Workflow

The silent activation preparation consists of the following steps:
- When the user logs in to the MPP app, the app starts the silent activation process. (Step 1)
- The MPP app registers the plugins, including DeviceFingerPrintService, NFCRequestProxy, and LoggerProxy. (Step 2)
- The MPP app sets up the listeners, including ActivateStatusListener and TransactionListener. (Step 3)
- The MPP app calls the init() and connect() API to initiate the SDK. (Steps 4-5)
- The MPP app calls the isPaymentAvailable() API to determine if the payment function is available, and the SDK returns
0as the result, which means the card does not exist. (Steps 6-7) - Then the MPP app calls the activatePayment() API with the silentActivate parameter set to
Trueand the replenishOnce parameter set toTrue. (Step 8) - The SDK calls the getDeviceFingerPrint() API to obtain device fingerprints from the MPP app. (Steps 9-10)
- The SDK obtains the public key from Mastercard and then applies for an NFC token from Mastercard. Then, the SDK starts to query the status of the NFC token application from the Ant server. The query will repeat until an approval status is returned. (Steps 11-34)
- The SDK obtains the NFC token from Mastercard and securely stores the NFC token locally. Then the SDK notifies Mastercard of the NFC token's obtaining result. Mastercard then returns an acknowledgment to the SDK via the proxy route to confirm that the notification has been received. After updating the NFC token's status, Mastercard notifies the Ant server of the token's status update. (Steps 35-53)
- After receiving the acknowledgment, the SDK queries whether Mastercard has completed updating the NFC token's status repeatedly from the Ant server. The SDK sets the token into silent status after receiving the Notify Token Updated (NTU) result. (Steps 54-60)
- The SDK obtains credentials from Mastercard and stores the credentials locally. (Steps 61-69)
- ActivateStatusListener is triggered, and the preset logics are executed. (Step 70)
- The callback of the activatePayment request returns to the MPP app. (Step 71)
Step 1: Start the silent activation process
Take the following steps to start the silent activation process:
1.1 Initialize the SDK and register components
When the user logs in, prepare the SDK for use:
- Register plugins: Call the registerPlugin() API to register your implementations of DeviceFingerPrintService, NFCRequestProxy, and LoggerProxy.
- Set up listeners: Set up the ActivateStatusListener and TransactionListener.
- Initialize and connect: Initialize the SDK. For details, see Initiate SDK.
1.2 Check token status
Call the isPaymentAvailable() API to determine if the payment function is available. The returned result parameter indicates the status of the token. For detailed information, see Token status.
1.3 Start the silent activation
If the result shows that the card does not exist, call the activatePayment() API with the silentActivate and replenishOnce parameters set to true.
Processing logic
When calling the isPaymentAvailable() API, take the following into consideration:
- Handle the response parameter properly:
- result: the token status code. For the code and corresponding token status, see Token status.
For more information about how to use the isPaymentAvailable() API on an Android device, see the isPaymentAvailable API.
When using the activatePayment() API, take the following into consideration:
- Configure the parameters properly:
- params: This parameter is used to configure Host Card Emulation (HCE) payment function. And it contains the following parameters:
- silentActivate: whether to process silent activation.
- replenishOnce: whether to automatically trigger a replenishment after successful card activation.
- doConfirm: whether the secondary confirmation is being processed.
- callback: the HCE activation result. The result codes are listed below:
0: failed to activate HCE.1: HCE is activated successfully, but credentials are not obtained.2: HCE is activated successfully, and credentials are obtained successfully.
For more information about how to use the activatePayment() API on an Android device, see the activatePayment API.
Step 2: Obtain and activate the token
2.1 Obtain the device fingerprints
After starting the activation process, the Alipay+ NFC SDK calls the getDeviceFingerPrint() API to your app to obtain the unique identifiers and characteristics of the device.
Processing logic
The DeviceFingerPrintService SPI is used to enable the SDK to request device fingerprints from you.
Note: The returned fingerprint from you must be in SHA-256 encryption. If this SPI is not implemented, or if the returned fingerprint does not use SHA-256 encryption, the SDK will return a
PARAMS_ERROR.
For more information about how to use the DeviceFingerPrintService SPI on an Android device, see the DeviceFingerPrintService SPI.
2.2 Obtain the public key
After gathering the device fingerprints, the Alipay+ NFC SDK sends a getPublicKey request to you. Then you need to proxy this request to the Ant server and Mastercard to obtain the public key.
Note: All requests from the Alipay+ NFC SDK to Alipay+'s backend are routed through the NFCRequestProxy SPI.
For more information about how the NFCRequestProxy SPI works, see Proxy SDK requests.
Then, Mastercard will return the certificate to the SDK through you.
2.3 Apply for and obtain an NFC token
- After the device fingerprints and the public key are ready, the Alipay+ NFC SDK sends an
applyNfcTokenrequest to you. Then you need to proxy this request to the Ant server, and then the Ant server applies for an NFC token from Mastercard. - Mastercard will send a pending status back to the SDK and you. When the NFC token is approved, a notification will be sent to the Ant server.
- Then the SDK sends a
queryTokenrequest to you. Then you need to proxy this request to the Ant server to query the token application result. This query will be made repeatedly until the approval status is returned from the Ant server. - After the token application is successful, the Alipay+ NFC SDK sends a
provisionrequest to you. Then you need to proxy this request to the Ant server and Mastercard to officially assign the token. - When receiving the token returned from the Ant server, you should return the token to the SDK. The SDK will store the token securely for further payments. Then the SDK sends a
notifyProvisionResultrequest to you. Then you need to proxy this request to notify the provision result to the Ant server and Mastercard. - Mastercard will notify the Ant server when the token status is updated.
- After notifying the Ant server, the SDK sends a
queryNTUResultrequest to check if the token status on the Ant server has been updated. This request will be made repeatedly until the NTU result is returned.
2.4 Set the token to silent status
After receiving the NTU result, the Alipay+ NFC SDK sets the local token into silent status.
2.5 Replenish NFC payment credentials
The Alipay+ NFC SDK sends a request to the Ant server to replenish the NFC payment credentials. For more details, see Auto-replenish.
Token status
Code | Token status |
-2 | Disconnected. |
-1 | Query failed. |
0 | The card does not exist. |
1 | The card exists, but there are no credentials. Call the replenish API to replenish credentials. |
2 | Payment is allowed. |
3 | The card is locked. Call the unlock API to unlock. |
4 | The card is locked locally. Call the localUnlock API to unlock. |
11 | The card is in activation. |
21 | The card is activated successfully but requires secondary confirmation. |