Alipay+ DocsAlipay+ Docs

activatePayment

Call the activatePayment API to activate the Host Card Emulation (HCE) payment function.

Method signature

copy
void activatePayment(NFCActivateParams params, @Nullable ACResultCallback<Integer> callback);

Request parameters

Item

Type

Description

Required

params

NFCActivateParams

HCE configurations.

No

callback

ACResultCallback<Integer>

The HCE activation result. For the result codes, see Result codes.

Note: The callback returns two values: result, which indicates the token status, and errorCode, which is an SDK result code string.

No

NFCActivateParams

Item

Type

Description

Default value

Required

silentActivate

Boolean

Whether to process silent activation.

Only used when isNeedConfirmActivate is set to true when initializing the SDK through the init API.

false

No

replenishOnce

Boolean

Whether to automatically trigger a replenishment after successful card activation.

true

No

doConfirm

Boolean

Whether the secondary confirmation is being processed.

false

No

applyDebitToken

Boolean

Whether to apply for a debit token during activation.

false

No

Result codes

The following table lists only the result values this API returns.

Code

SDK constant

HCE status

-2

TOKEN_NOT_CONNECTED

SDK is not connected.

-1

TOKEN_STATUS_UNKNOWN

Token status is unknown.

0

TOKEN_STATUS_NOT_EXIST

Failed to activate HCE.

1

TOKEN_STATUS_ACTIVATED_WITH_NO_CREDENTIALS

HCE is activated successfully but Credentials are not obtained.

Call the replenish API to obtain Credentials.

2

TOKEN_STATUS_READY_TO_TAP

HCE is activated successfully and Credentials are obtained successfully.

3

TOKEN_STATUS_LOCKED

Cannot execute activation as the token is locked.

21

TOKEN_STATUS_NOT_CONFIRMED

Token status is not confirmed.

Note: An activation already in progress is reported as result 0 with errorCode 10010 (ACTIVATION_IN_PROGRESS). For the complete list of status codes and which APIs can return each value, see Token status.

Validation gates

The following conditions cause activatePayment to return immediately without making any network call.

Condition

Result

errorCode

The SDK is not connected.

-2

10006 (NOT_CONNECT)

silentActivate or doConfirm is set while isNeedConfirmActivate is false.

-1

10011 (INPUT_PARAMS)

No DeviceFingerPrintService is registered.

-1

10011 (INPUT_PARAMS)

The device fingerprint is empty or not exactly 64 characters.

-1

10011 (INPUT_PARAMS)

Response parameters

N/A

Sample

copy
ACTapManager manager = ACTapManager.getInstance(this.getApplication());
manager.activatePayment(params, (result, errorCode, errorMsg) ->
                        log("Activation Result: " + result + "    errorCode: " + errorCode + "  errorMsg: " + errorMsg)
                       );