# eKYB (Electronic Know Your Business)

The eKYB module collects and verifies a business entity's identity data, such as business name, address, and tax ID. The fields that are collected and how the checks are evaluated depend on your Incode Flow or Workflow configuration.

{/* What if they don't have a Flow or Workflow? */}

For an overview of this module and how it works, see [eKYB (electronic Know Your Business)](https://developer.incode.com/docs/ekyb).

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 eKYB

Add the module with `addEKYB(ekybModule)`.

```kotlin
flowConfigBuilder.addEKYB(ekybModule)
```
```java
flowConfigBuilder.addEKYB(ekybModule);
```

### Example

The example below builds an `EKYB` module showing all three fields, adds it to the flow, and listens for the result through `onEKYBChecksCompleted()`.

```kotlin
val ekybModule = EKYB.Builder()
    .setShowBusinessName(true)
    .setShowAddress(true)
    .setShowTaxId(true)
    .build()

val flowConfig = FlowConfig.Builder()
    .addEKYB(ekybModule)
    .build()

val onboardingListener = object : OnboardingListener() {
    override fun onEKYBChecksCompleted(ekybResult: EKYBResult) {
        // eKYB checks completed. Inspect ekybResult for the per-check results.
    }
}

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
```
```java
EKYB ekybModule = new EKYB.Builder()
    .setShowBusinessName(true)
    .setShowAddress(true)
    .setShowTaxId(true)
    .build();

FlowConfig flowConfig = new FlowConfig.Builder()
    .addEKYB(ekybModule)
    .build();

IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
    @Override
    public void onEKYBChecksCompleted(EKYBResult ekybResult) {
        // eKYB checks completed. Inspect ekybResult for the per-check results.
    }
};

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

## Configuration Options

Configure the module with `EKYB.Builder`. These options control which form fields the module shows.

| Setting                        | Description                                                |
| ------------------------------ | ---------------------------------------------------------- |
| `setShowBusinessName(Boolean)` | Shows or hides the Business Name field. Default is `true`. |
| `setShowAddress(Boolean)`      | Shows or hides the address fields. Default is `true`.      |
| `setShowTaxId(Boolean)`        | Shows or hides the Tax ID field. Default is `true`.        |

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

## Result

eKYB delivers an `EKYBResult` to the `onEKYBChecksCompleted(EKYBResult)` callback on the `OnboardingListener`. Key fields include:

- `resultTests`: The list of individual eKYB check results; empty when none. Each entry (`EKYBResultCheck`) contains the following:
  - `key`: The identifier of the check performed.
  - `status`: The outcome of the check; `null` when unavailable.
  - `subLabel`: A secondary label describing the check; `null` when unavailable.
  - `message`: A human-readable message for the check; `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.

Errors surface via `OnboardingListener.onError(Throwable)`.

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