# Process ID

The Process ID module determines whether a submitted identity document is authentic. It analyzes the images captured by the [ID Scan](https://developer.incode.com/docs/android-id-scan) module against known parameters for the document type, runs a set of authenticity checks, and produces a validation result.

For an overview of this module and how it works, see [ID Validation](https://developer.incode.com/docs/id-validation-module).

How you use this module depends on your [integration pattern](https://developer.incode.com/docs/android-common-implementation-patterns#integration-patterns). In Patterns 1 and 2, you add the module to a `FlowConfig` in code as shown on this page. In Pattern 3, you define your modules and configuration in Dashboard as a Flow or Workflow and reference it by ID with `startFlow()` or `startWorkflow()` as shown on [Run Flows Configured in Dashboard](https://developer.incode.com/docs/android-run-flows-configured-online).

## Add Process ID

1. Add [ID Scan](https://developer.incode.com/docs/android-id-scan) before Process ID. Process ID validates the document captured by the ID Scan module. Process ID has no UI of its own beyond validation progress; the user-facing capture happens in the ID Scan step that runs before it. It runs as a v2 (Jetpack Compose) processing screen and has no separate legacy v1 UI.
2. Add the module with `addProcessId(processId)`:

   ```kotlin
   flowConfigBuilder.addProcessId(processId)
   ```
   ```java
   flowConfigBuilder.addProcessId(processId);
   ```

3) Add [ID Info](https://developer.incode.com/docs/android-id-info) after Process ID. The OCR data Process ID returns is what the ID Info step reads.

Process ID ships both a v1 (legacy View) and a v2 (Jetpack Compose) capture screen; the active one depends on your Incode configuration. Contact your Incode representative to enable v2.

### Example

The example below adds ID Scan and Process ID to the flow, and listens for the validation result through `onIdProcessed()`.

```kotlin
val idScan = IdScan.Builder().build()
val processId = ProcessId.Builder().build()

val flowConfig = FlowConfig.Builder()
    .addID(idScan)
    .addProcessId(processId)
    .build()

val onboardingListener = object : OnboardingListener() {
    override fun onIdProcessed(idProcessResult: IdProcessResult) {
        // ID validated. Process the result.
    }
}

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
```
```java
IdScan idScan = new IdScan.Builder().build();
ProcessId processId = new ProcessId.Builder().build();

FlowConfig flowConfig = new FlowConfig.Builder()
    .addID(idScan)
    .addProcessId(processId)
    .build();

IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
    @Override
    public void onIdProcessed(@NonNull IdProcessResult idProcessResult) {
        // ID validated. Process the result.
    }
};

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener);
```

## Configuration Options

Configure the module with `ProcessId.Builder`. The table below lists the most common option.

| Setting                     | Description                                                                                                                                                |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `setIdCategory(IdCategory)` | Sets which captured document this step validates, `IdCategory.FIRST` or `IdCategory.SECOND`, when the flow captures more than one ID. Defaults to `FIRST`. |

When a flow captures two IDs, use `setIdCategory(IdCategory.FIRST)` and `setIdCategory(IdCategory.SECOND)` on separate Process ID modules to validate each captured document.

`setEnableIdSummaryScreen(Boolean)` is deprecated as of SDK 5.42.0 and no longer applies to the new UI.

For the complete option set, see `ProcessId.Builder` in [API Reference](https://developer.incode.com/docs/android-api-reference).

## Result

Process ID delivers an `IdProcessResult` to the `onIdProcessed(IdProcessResult)` callback on the `OnboardingListener`. Key fields include:

- `ocrData`: The OCR data extracted from the processed ID (`IncodeWelcome.OCRData`); `null` when unavailable.
- Fields inherited from `BaseResult`:
  - `resultCode`: The `ResultCode` for this result.
  - `error`: When `resultCode` is `ERROR`, the `Throwable` that caused it; otherwise, `null`.
  - `deviceStats`: The `DeviceStats` snapshot of the device state when the result was produced.
  - `motionStatus`: Device motion assessment during capture. One of the following:
    - `UNCLEAR`: Motion could not be determined; the default.
    - `PASS`: Device motion was within acceptable limits.
    - `FAIL`: Excessive device motion was detected.

If validation cannot be completed, the error surfaces through `OnboardingListener.onError(Throwable)`.

For all fields, see `IdProcessResult` in [API Reference](https://developer.incode.com/docs/android-api-reference).
