User activation (Combination of Alipay+ NFC page and MPP's self-built pages)
This guide describes how to implement the final user confirmation step of the silent activation process using a hybrid approach, that is, adopting the Alipay+ SDK's built-in NFC configuration page and using MPP's built-in Alipay+ NFC activation processing page and result page.
Before you begin
- Ensure that you have already implemented the activation preparation process.
- Understand that you will use the Alipay+ NFC configuration page, and prepare your own built NFC activation processing and result pages.
Workflow

The user activation consists of the following steps:
- The user opens the Alipay+ NFC page. (Step 1)
- The MPP app calls the isPaymentAvailable() API of the Alipay+ NFC SDK to determine if the payment function is available. If the silent activation process is finished, the SDK returns
11or21as the token status to the MPP app. (Steps 2-3) - The MPP app displays the Alipay+ NFC service activation page to the user. (Step 4)
- The user agrees to the terms and conditions and chooses to activate the NFC service. (Steps 5-6)
- The MPP app calls the isNfcPaySettingsCompleted() API of the SDK to determine if the NFC payment is enabled. (Step 7)
- If the SDK returns
Falsein the result of the isNfcPaySettingsCompleted() API, the MPP app opens the Alipay+ NFC configuration page by calling the ApplyCardActivity.setting() API for the user to turn on the NFC function and set the MPP app as the default NFC app. (Steps 8-13) - If the SDK returns
Truein the result of the isNfcPaySettingsCompleted() API, no further action is needed in this step. (Step 14)
- The MPP app displays its own built Alipay+ NFC processing page. (Step 15)
- The MPP app calls the isPaymentAvailable() API of the SDK repeatedly to determine if the payment function is available.
- If the returned token status is
11, the silent activation is still in progress. The MPP app waits for the silent activation to complete. (Steps 16-17) - If the returned token status is
0, the silent activation fails. The MPP app calls the activatePayment() API of the SDK with silentActivate set toFalseand doConfirm set toFalse. The activation process switches to manual activation. (Steps 18-20) - If the returned token status is
21, the silent activation succeeds. The MPP app calls the activatePayment() API of the SDK with silentActivate set toFalseand doConfirm set toTrue. (Steps 21-22)
- The SDK sends a request to the Ant server to activate the token on the server side. (Steps 23-28)
- The SDK activates the local token. ActivateStatusListener is triggered, causing the MPP app to display its own built Alipay+ NFC service activation result page. Then the MPP app displays the Alipay+ NFC payment page. (Steps 29-32)
Step 1: Open and verify the Alipay+ NFC page
1. The user opens the Alipay+ NFC page.
2. Call the isPaymentAvailable() API of the Alipay+ SDK to check if the payment function is available. If the SDK returns token status 11 or 21, proceed with the activation steps.
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.
Step 2: Display and activate NFC service
1. Display the Alipay+ NFC service activation page to the user.
- The user agrees to the terms and conditions and chooses to activate the NFC service.
2. Call the isNfcPaySettingCompleted() API to check NFC payment settings.
- If the SDK returns
False:
- Open the Alipay+ NFC configuration page using ApplyCardActivity.setting() API.
- The user enables the NFC function and sets your app as the default NFC app.
- SDK returns to your app's page.
- Call isPaymentAvailable() again to confirm payment availability.
Processing logic
When calling the isNfcPaySettingsCompleted API, take the following into consideration:
- Configure the request parameters properly:
- activity: The context of the current NFC settings page.
- apduServiceName: The customized APDU service name during the integration.
- Handle the result properly:
- The result is a boolean and indicates whether NFC payment is enabled.
True: NFC payment is enabled.False: NFC payment is disabled.
For more information about how to use the isNfcPaySettingsCompleted API on an Android device, see the isNfcPaySettingsCompleted API.
When calling the ApplyCardActivity.apply() API, take the following into consideration:
- Configure the request parameters properly:
- activity: The context of the current activation page.
- requestCode: The code that will be returned to
onActivityResult()to identify this card application request. - apduServiceName: The customized APDU service name during integration.
For more information about how to use the ApplyCardActivity.apply() API on an Android device, see the ApplyCardActivity.apply() API.
Step 3: Confirm activation status
1. If the SDK returns True for NFC settings:
- Display your own built Alipay+ NFC processing page.
2. Call the isPaymentAvailable() API repeatedly to monitor payment function availability.
- If token status is:
11: Wait for silent activation to complete.0: Silent activation fails, switch to manual activation with activatePayment(), setting silentActivate toFalse, and doConfirm toFalse.21: Silent activation succeeds. Confirm activation with activatePayment(), setting silentActivate toFalse, and doConfirm toTrue.
Processing logic
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 4: Complete the token activation process
- The SDK sends an
activeTokenrequest to you via the NFCRequestProxy SPI. Then you need to proxy the request to the Ant server. - The Ant server returns the server-side token activation result to the SDK.
- SDK activates the local token. The ActivateStatusListener is triggered, causing your app to display your built-in Alipay+ NFC service activation result page. Then your app displays the Alipay+ NFC payment page.
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. |