Alipay+ DocsAlipay+ Docs

User activation (MPP's self-built pages)

This guide describes how to implement the final user confirmation step of the silent activation process using your own built-in NFC service activation pages.

Before you begin

  • Ensure that you have already implemented the activation preparation process.
  • Prepare your own built-in NFC service activation pages.

Workflow

image.png

The user activation consists of the following steps:

  1. The user opens the Alipay+ NFC page. (Step 1)
  2. 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 11 or 21 as the token status to the MPP app. (Steps 2-3)
  3. The MPP app displays the Alipay+ NFC service activation page to the user. And the user agrees to the terms and conditions and chooses to activate the NFC service. (Steps 4-6)
  4. The MPP app calls the isNfcPaySettingsCompleted() API of the SDK to determine if the NFC payment is enabled. (Step 7)
    • If the SDK returns False in the result of the isNfcPaySettingsCompleted() API, the MPP app displays its own built-in Alipay+ NFC configuration page for the user to turn on the NFC function and set the MPP app as the default NFC app. (Step 8-11)
    • If the SDK returns True in the result of the isNfcPaySettingsCompleted() API, no further step is needed in this step. (Step 12)
  1. The MPP app displays its own built-in Alipay+ NFC processing page. (Step 13)
  2. 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 14-15)
    • If the returned token status is 0, the silent activation fails. The MPP app calls the activatePayment() API of the SDK with silentActivate set to False and doConfirm set to False. The activation process switches to manual activation. (Steps 16-18)
    • If the returned token status is 21, the silent activation succeeds. The MPP app calls the activatePayment() API of the SDK with silentActivate set to False and doConfirm set to True. (Steps 19-20)
  1. The SDK sends a request to the Ant server to activate the token on the server side. (Steps 21-26)
  2. 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 27-30)

Step 1: Open the Alipay+ NFC service

  1. The user opens the Alipay+ NFC page on the MPP app.
  2. Call the isPaymentAvailable() API of the Alipay+ SDK to check if the payment function is available, where the SDK returns 11 or 21 as the token status.

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: Activate NFC service

  1. Display the Alipay+ NFC service activation page, where the user agrees to the terms and conditions and chooses to activate the NFC service.
  2. Call the isNfcPaySettingsCompleted() API of the SDK to check if NFC payment is enabled. If False, your app presents your own NFC configuration page for the user to enable the NFC function and set your app as the default NFC app, then rechecks NFC payment setting completion.

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.

Step 3: Confirm activation status

  1. If the SDK returns True for NFC settings, your app displays your built-in 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 to False, and doConfirm to False.
    • 21: Silent activation succeeds. Confirm activation with activatePayment(), setting silentActivate to False, and doConfirm to True.

Processing logic

When using the activatePayment() API, take the following into consideration:

  • Configure the parameters properly:
    • params: This parameter is used to configure the 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

  1. The SDK sends an activeToken request to you via the NFCRequestProxy SPI. Then you need to proxy the request to the Ant server.
  2. The Ant server returns the server-side token activation result to the SDK.
  3. 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.