Alipay+ DocsAlipay+ Docs

Manual activation (Combination of Alipay+ NFC page and MPP's self-built pages)

In the manual activation process, you can only adopt the SDK's built-in Alipay+ NFC configuration page and use its built-in Alipay+ NFC activation processing page and result page. The following content shows how the manual activation process works.

Workflow

1753690012728-5a64cc90-59ac-4e47-a0c5-a22e47d260b5_副本.png

The manual activation of the Mastercard token consists of the following steps:

  1. The user opens the Alipay+ NFC payment page. Next, the MPP app calls the isPaymentAvailable() API to determine if the payment function is available. The SDK returns a value of 0, indicating that the card does not exist. (Steps 1-3)
  2. The MPP app displays the Alipay+ NFC service activation page to the user, and the user agrees to the terms and then activates the NFC service. (Steps 4-6)
  3. The MPP app calls the isNfcPaySettingsCompleted() API to determine if the NFC settings are completed. (Step 7)
    • If the returned result is False, the MPP app opens the Alipay+ NFC configuration page by calling the ApplyCardActivity.setting() API for the user to turn on NFC and set the MPP app as the default NFC app. (Steps 8-13)
    • If the returned result is True, no further action is needed in this step. (Step 14)
  1. The MPP app displays the Alipay+ NFC processing page to the user and calls the activatePayment API with silentActivate set to False and doConfirm set to False. (Steps 15-16)
  2. The SDK calls the getDeviceFingerPrint() API to obtain device fingerprints from the MPP app. (Steps 17-18)
  3. 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 19-42)
  4. 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 43-61)
  5. After receiving the acknowledgment, the SDK queries whether Mastercard has completed updating the NFC token's status repeatedly from the Ant server. The SDK activates the token after receiving the Notify Token Updated (NTU) result. (Steps 62-68)
  6. The SDK obtains credentials from Mastercard and stores the credentials locally. (Steps 69-77)
  7. After the replenishment process, the SDK displays the Alipay+ NFC activation result page and then switches to the Alipay+ NFC payment page. (Steps 78-79)
  8. The callback of the activatePayment API is returned to the MPP app. (Step 80)

Step 1: Start the activation process

  1. When a user opens the NFC page, check the card token status using the isPaymentAvailable() API. If the result is 0, indicating the card doesn't exist, display your built-in Alipay+ NFC service activation page.
  2. The user agrees to the terms and chooses to activate the NFC service. Call the isNfcPaySettingCompleted() API to verify the completion of NFC settings.
  3. If the result of the isNfcPaySettingCompleted() API is False, your app opens the configuration page by calling ApplyCardActivity.setting() API.
  4. The user enables the NFC function and sets your app as the default NFC application.
  5. Then call the isNfcPaySettingCompleted() API again to verify NFC settings completion. If the result is True, your app displays your built-in activation processing page and calls the activatePayment API with silentActivate set to False and doConfirm set to False to initiate the activation process.
  6. The following steps are processes by the SDK. You only need to proxy the request from the SDK.

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 calling the ApplyCardActivity.setting() 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 integration.

For more information on how to use the ApplyCardActivity.setting() API on an Android device, see ApplyCardActivity.setting() API

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 sub-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.

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 2: Obtain and activate the token

2.1 Obtain the device fingerprints

After starting the activation process, the Alipay+ NFC SDK calls the DeviceFingerPrintService SPI to obtain the unique identifiers and characteristics of the device from your app.

Processing logic

The DeviceFingerPrintService SPI is used to enable the SDK to request device fingerprints from you.

Note: The returned fingerprint from you must use SHA-256 encryption. If this SPI is not implemented, or if the returned fingerprint is not in 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 getPublicKeyrequest to you. Then you need to proxy this request to Mastercard to obtain the public key.

Note: All requests from the NFC SDK to Alipay+ and Mastercard are routed through the NFCRequestProxy SPI. For more information about how NFCRequestProxy works, see Proxy SDK requests.

Then Mastercard returns the certificate to the SDK.

2.3 Apply for and obtain an NFC token

  1. After the device fingerprints and the public key are ready, the Alipay+ NFC SDK sends an applyNfcToken request 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.
  2. Mastercard will send a pending status back to the SDK and your app. When the NFC token is approved, a notification will be sent to the Ant server.
  3. Then the SDK sends a queryToken request to you. Then you need to proxy this request to the Ant server to query the token application result. If the Ant server receives the approval of the token application from Mastercard, it returns an approval status to you and the SDK. This query will be made repeatedly until the approval status is returned.
  4. After the token application is successful, the Alipay+ NFC SDK sends a provision request to you. Then you need to proxy this request to the Ant server to officially assign the token. Then the Ant server requests a token from Mastercard and returns the token to you and the SDK.
  5. When receiving the token returned from the Ant server, the SDK securely stores the token locally. Then the SDK sends a notifyProvisionResult request to you. Then you need to proxy this request to notify the provision result to the Ant server and Mastercard.
  6. Mastercard then updates the token's status on its server. Mastercard will notify the Ant server when the online token's status is updated.
  7. After notifying the Ant server, the SDK sends a queryNTUResult request to check if the token status on the Mastercard server has been updated. This request will be made repeatedly until the NTU result is returned.

2.4 Activate the token

After receiving the NTU result, the Alipay+ NFC SDK activates the local token.

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.

Step 3: Display the result

After the replenishment process, the ActivateCardListener is triggered and causes your app to display your built-in Alipay+ NFC activation result page to the user.

And then the callback of the activatePayment API returns.

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.