# activatePayment

> Activates NFC payment for a transaction.

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

## Method signature

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

## Request parameters

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| params | [NFCActivateParams](#Kmgu8) | HCE configurations. | No |
| callback | [ACResultCallback](ac_result_callback)<Integer> | The HCE activation result. For the result codes, see [Result codes](#pF8p0). > **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](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

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