Skip to content

Accounts SDK for Android

The Accounts SDK is a solution to ease the integration with the Alviere services.

Features

  • Account Management
  • Account Addresses Management
  • Account Dossiers Management

Requirements

  • Android Studio Chipmunk or above
  • Android 5.0 (API level 21) or above
  • Java 11+

Installation

Maven Central

1. Add Maven Central to project repositories

repositories {
    // ...
    mavenCentral()
}

2. Add SDK dependency to module's build.gradle file using the latest version.

dependencies {
    // ...
    implementation 'com.alviere.android:accounts:X.Y.Z'
}

Manual

1. Get the latest version of Accounts SDK provided by Alviere and add the files to your .m2 path location. Depending on your operation system, these are the default paths.

  • Windows: C:\Users\<User_Name>\.m2
  • Linux: /home/<User_Name>/.m2
  • Mac: /Users/<user_name>/.m2

2. Add a maven path to include the .m2 path location in project repositories. Add the new path before mavenCentral() to respect fetch order.

repositories {
    // ...
    maven { url "file:/path/to/repo/m2repository/" } // Or use mavenLocal() for default path.
    mavenCentral()
}

3. Add SDK dependency to module's build.gradle file using the version provided by Alviere.

dependencies {
    // ...
    implementation 'com.alviere.android:accounts:X.Y.Z'
}

Java Version Support

Make sure you have enabled Java 11 language feature support. To do so, guarantee that the following configurations are on the module's build.gradle file.

android {
    // ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }
}

Usage

On your android application class, setup Alviere Initialization.

class AndroidApplication : Application() {

  override fun onCreate() {
    super.onCreate()

    Alviere.init(this)
  }
}

Request camera runtime permission for document capture.

ActivityCompat.requestPermissions(..., arrayOf(Manifest.permission.CAMERA),...)

Account Management

This section outlines the integration with Alviere to manage accounts. To Start get the AccountsSdk service interface instance or use with Dependency Injection.

private val accountsService = AccountsSdk.service

Declare the callback

These callbacks are the main communication back channel to your application.
For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val getAccountSdkCallback = object : GetAccountSdkCallback {
 override fun onSuccess(account: AccountDetailsModel) { /* handle success */ }

 override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val updateAccountSdkCallback = object : UpdateAccountSdkCallback {
 override fun onSuccess(account: AccountDetailsModel) { /* handle success */ }

 override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

onSuccess

This callback method is called when an account request was successfully executed. Use this to manage accounts and store the accounts with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Get Account

To obtain an account, use the Accounts SDK service method accountsService.getAccount. Pass the session_token, the account_uuid and the GetAccountSdkCallback.

accountsService.getAccount(
    sessionToken = session_token,
    accountUuid = account_uuid,
    clientCallback = getAccountSdkCallback
)

The result of this action will return the specific AccountDetailsModel on onSuccess(account: AccountDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update Account

To update an account, use the Accounts SDK service method accountsService.updateAccount. Pass the session_token, the account_uuid, the AccountUpdateRequest model and the UpdateAccountSdkCallback.

val model = AccountUpdateRequest(...)
accountsService.updateAccount(
    sessionToken = session_token,
    accountUuid = account_uuid,
    data = model,
    clientCallback = updateAccountSdkCallback
)

The result of this action will return the updated AccountDetailsModel on onSuccess(account: AccountDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Account Addresses Management

This section outlines the integration with Alviere to manage account addresses. To Start get the AccountsSdk service interface instance or use with Dependency Injection.

private val accountsService = AccountsSdk.service

Declare the callback

These callbacks are the main communication back channel to your application.
For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val createAddressSdkCallback = object : CreateAddressSdkCallback {
 override fun onSuccess(address: AddressDetailsModel) { /* handle success */ }

 override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val listAddressesSdkCallback = object : ListAddressesSdkCallback {
 override fun onSuccess(addresses: List<AddressDetailsModel>) { /* handle success */ }

 override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val updateAddressSdkCallback = object : UpdateAddressSdkCallback {
 override fun onSuccess(address: AddressDetailsModel) { /* handle success */ }

 override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val deleteAddressSdkCallback = object : DeleteAddressSdkCallback {
  fun onSuccess() { /* handle success */ }
}

onSuccess

This callback method is called when an account address request was successfully executed. Use this to manage account addresses with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Create Address

To add an account address, use the Accounts SDK service method accountsService.createAddress. Pass the session_token, the account_uuid, the AddressRequest model and the CreateAddressSdkCallback.

val model = AddressRequest(...)
accountsService.createAddress(
    sessionToken = session_token,
    accountUuid = account_uuid,
    data = model,
    clientCallback = createAddressSdkCallback
)

The result of this action will return the newly created AddressDetailsModel on onSuccess(address: AddressDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

List Addresses

To get a list of addresses from an account, use the Accounts SDK service method accountsService.listAddresses. Pass the session_token, the account_uuid and the listAddressesSdkCallback.

accountsService.listAddresses(
    sessionToken = session_token,
    accountUuid = account_uuid,
    clientCallback = listAddressesSdkCallback
)

The result of this action will return the account's addresses List<AddressDetailsModel> on onSuccess(addresses: List<AddressDetailsModel>) and any errors will be returned ononEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update Address

To update an account address, use the Accounts SDK service method accountsService.updateAddress. Pass the session_token, the account_uuid, the address_uuid, the AddressUpdateRequest model and the UpdateAddressSdkCallback.

val model = AddressUpdateRequest(...)
accountsService.updateAddress(
    sessionToken = session_token,
    accountUuid = account_uuid,
    addressUuid = address_uuid,
    data = model,
    clientCallback = updateAddressSdkCallback
)

The result of this action will return the updated AddressDetailsModel on onSuccess(address: AddressDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Delete Address

To delete an account address, use the Accounts SDK service method accountsService.deleteAddress. Pass the session_token, the account_uuid, the address_uuid and the DeleteAddressSdkCallback.

accountsService.deleteAddress(
    sessionToken = session_token,
    accountUuid = account_uuid,
    addressUuid = address_uuid,
    clientCallback = deleteAddressSdkCallback
)

The result of this action will return on onSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Account Dossiers Management

This section outlines the integration with Alviere to manage dossiers of documents. To start, get the AccountsSdk service interface instance or use with Dependency Injection.

private val accountsService = AccountsSdk.service

Declare the callback

These callbacks is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val dossierByIntentSdkCallback = object : DossierByIntentSdkCallback {
  override fun onCreateSuccess(dossier: DossierDetailsModel) { /* handle success */ }

  override fun onUpdateSuccess(dossier: DossierDetailsModel) { /* handle success */ }

  override fun onReplaceSuccess(dossier: DossierDetailsModel) { /* handle success */ }

  override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val documentCaptureSdkCallback = object : DocumentCaptureSdkCallback {
  override fun onSuccess(documents: List<DocumentCaptureDetailsModel>) { /* handle success */ }

  override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val listDossiersSdkCallback = object : ListDossiersSdkCallback {
  override fun onSuccess(dossiers: List<DossierDetailsModel>) { /* handle success */ }

  override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val getDossierSdkCallback = object : GetDossierSdkCallback {
  override fun onSuccess(dossier: DossierFileDetailsModel) { /* handle success */ }

  override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

private val deleteDossierSdkCallback = object : DeleteDossierSdkCallback {
  override fun onSuccess() { /* handle success */ }

  override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}

onSuccess

This callback method is called when a dossier request was successfully executed. Use this to manage dossiers of an account with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Dossier UI Callback

The Create, Update or Replace a Dossier of Documents, a Capture Mode through Activity or through the navigation controller. To get started, set the Accounts SDK event listener.

AccountsSdk.setEventListener(dossierByIntentSdkCallback)

Create Dossier

Activity

To start using this feature on an activity, create an Intent using accountsService.createDossierByIntent, pass the parent_activity, the session_token, the external_id, the account_uuid, the primary_dossier, and an array of files to be capture using DocumentTypeModel with a selection of different document types.

val intent = accountsService.createDossierByIntent(
  parentActivity = parent_activity,
  sessionToken = session_token,
  externalId = external_id,
  accountUuid = account_uuid,
  primary = primary_dossier,
  filesToCapture = arrayOf(
    DocumentTypeModel.ID_DOCUMENT_FRONT,
    DocumentTypeModel.ID_DOCUMENT_BACK,
    DocumentTypeModel.DRIVER_LICENSE_FRONT,
    DocumentTypeModel.DRIVER_LICENSE_BACK,
    DocumentTypeModel.MC_DOCUMENT_FRONT,
    DocumentTypeModel.MC_DOCUMENT_BACK,
    DocumentTypeModel.INE_FRONT,
    DocumentTypeModel.INE_BACK,
    DocumentTypeModel.SELFIE,
    DocumentTypeModel.PASSPORT,
    DocumentTypeModel.PROOF_OF_ADDRESS,
    DocumentTypeModel.PROOF_OF_FUNDS
  )
)
startActivity(intent)

To start using this feature on a navigation controller, add the destination AccountsActivity to your navigation graph and connect it. An action will be generated that will have to have the arguments embedded, as follows.

<fragment
    android:id="@+id/accounts_dossiers_fragment_create"
    android:name="com.example.app.CreateDossierFragment">
    <action
        android:id="@+id/action_accounts_dossiers_fragment_create_to_accounts_activity"
        app:destination="@id/accounts_activity" />
</fragment>

<activity
    android:id="@+id/accounts_activity"
    android:name="com.alviere.android.accounts.activity.view.AccountsActivity">
    <argument
        android:name="accounts_extra_feature"
        app:argType="com.alviere.android.accounts.AccountsSdk$Features" />
    <argument
        android:name="accounts_extra_session_token"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_external_id"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_dossier_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_primary"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_document_capture_only"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_files_to_capture"
        app:argType="com.alviere.android.accounts.sdk.model.common.DocumentTypeModel[]" />
</activity>

A class is created for each destination where an action originates. The name of this class is the name of the originating destination, appended with the word "Directions". For example, if the originating destination is a fragment that is named CreateDossierFragment, the generated class would be called CreateDossierFragmentDirections. This class has a method for each action defined in the originating destination, such as actionAccountsDossiersFragmentCreateToAccountsActivity() that returns a NavDirections object. This returned NavDirections object can then be passed directly to navigate(), as shown in the following example:

view.findNavController().navigate(
  CreateDossierFragmentDirections.actionAccountsDossiersFragmentCreateToAccountsActivity(
    accountsExtraFeature = AccountsSdk.Features.CREATE_DOSSIER,
    accountsExtraSessionToken = session_token,
    accountsExtraExternalId = external_id,
    accountsExtraUuid = account_uuid,
    accountsExtraPrimary = true,
    accountsExtraFilesToCapture = arrayOf(
      DocumentTypeModel.ID_DOCUMENT_FRONT,
      DocumentTypeModel.ID_DOCUMENT_BACK,
      DocumentTypeModel.DRIVER_LICENSE_FRONT,
      DocumentTypeModel.DRIVER_LICENSE_BACK,
      DocumentTypeModel.MC_DOCUMENT_FRONT,
      DocumentTypeModel.MC_DOCUMENT_BACK,
      DocumentTypeModel.INE_FRONT,
      DocumentTypeModel.INE_BACK,
      DocumentTypeModel.SELFIE,
      DocumentTypeModel.PASSPORT,
      DocumentTypeModel.PROOF_OF_ADDRESS,
      DocumentTypeModel.PROOF_OF_FUNDS
    )
  )
)

The result of this actions will return the specific DossierDetailsModel on onCreateSuccess(dossier: DossierDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update Dossier

Activity

To start using this feature on an activity, create an Intent using __accountsService.updateDossierByIntent, pass the parent_activity, the session_token, the account_uuid, the dossier_uuid and an array of files to be capture using DocumentTypeModel with a selection of different document types. The external_id is optional.

val intent = accountsService.updateDossierByIntent(
  parentActivity = parent_activity,
  sessionToken = session_token,
  externalId = external_id,
  accountUuid = account_uuid,
  dossierUuid = dossier_uuid,
  filesToCapture = arrayOf(
    DocumentTypeModel.ID_DOCUMENT_FRONT,
    DocumentTypeModel.ID_DOCUMENT_BACK,
    DocumentTypeModel.DRIVER_LICENSE_FRONT,
    DocumentTypeModel.DRIVER_LICENSE_BACK,
    DocumentTypeModel.MC_DOCUMENT_FRONT,
    DocumentTypeModel.MC_DOCUMENT_BACK,
    DocumentTypeModel.INE_FRONT,
    DocumentTypeModel.INE_BACK,
    DocumentTypeModel.SELFIE,
    DocumentTypeModel.PASSPORT,
    DocumentTypeModel.PROOF_OF_ADDRESS,
    DocumentTypeModel.PROOF_OF_FUNDS
  )
)
startActivity(intent)

To start using this feature on a navigation controller, add the destination AccountsActivity to your navigation graph and connect it. An action will be generated that will have to have the arguments embedded, as follows.

<fragment
android:id="@+id/accounts_dossiers_fragment_update"
android:name="com.example.app.UpdateDossierFragment">
<action
    android:id="@+id/action_accounts_dossiers_fragment_update_to_accounts_activity"
    app:destination="@id/accounts_activity" />
</fragment>

<activity
    android:id="@+id/accounts_activity"
    android:name="com.alviere.android.accounts.activity.view.AccountsActivity">
    <argument
        android:name="accounts_extra_feature"
        app:argType="com.alviere.android.accounts.AccountsSdk$Features" />
    <argument
        android:name="accounts_extra_session_token"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_external_id"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_dossier_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_primary"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_document_capture_only"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_files_to_capture"
        app:argType="com.alviere.android.accounts.sdk.model.common.DocumentTypeModel[]" />
</activity>

A class is created for each destination where an action originates. The name of this class is the name of the originating destination, appended with the word "Directions". For example, if the originating destination is a fragment that is named UpdateDossierFragment, the generated class would be called UpdateDossierFragmentDirections. This class has a method for each action defined in the originating destination, such as actionAccountsDossiersFragmentUpdateToAccountsActivity() that returns a NavDirections object. This returned NavDirections object can then be passed directly to navigate(), as shown in the following example:

view.findNavController().navigate(
  UpdateDossierFragmentDirections.actionAccountsDossiersFragmentUpdateToAccountsActivity(
    accountsExtraFeature = AccountsSdk.Features.UPDATE_DOSSIER,
    accountsExtraSessionToken = session_token,
    accountsExtraUuid = account_uuid,
    accountsExtraDossierUuid = dossier_uuid,
    accountsExtraFilesToCapture = arrayOf(
      DocumentTypeModel.ID_DOCUMENT_FRONT,
      DocumentTypeModel.ID_DOCUMENT_BACK,
      DocumentTypeModel.DRIVER_LICENSE_FRONT,
      DocumentTypeModel.DRIVER_LICENSE_BACK,
      DocumentTypeModel.MC_DOCUMENT_FRONT,
      DocumentTypeModel.MC_DOCUMENT_BACK,
      DocumentTypeModel.INE_FRONT,
      DocumentTypeModel.INE_BACK,
      DocumentTypeModel.SELFIE,
      DocumentTypeModel.PASSPORT,
      DocumentTypeModel.PROOF_OF_ADDRESS,
      DocumentTypeModel.PROOF_OF_FUNDS
    )
  )
)

The result of this actions will return the specific DossierDetailsModel on onUpdateSuccess(dossier: DossierDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Replace Dossier

Activity

To start using this feature on an activity, create an Intent using accountsService.replaceDossierByIntent, pass the parent_activity, the session_token, the account_uuid, the dossier_uuid and an array of files to be capture using DocumentTypeModel with a selection of different document types.

val intent = accountsService.replaceDossierByIntent(
  parentActivity = parent_activity,
  sessionToken = session_token,
  accountUuid = account_uuid,
  dossierUuid = dossier_uuid,
  filesToCapture = arrayOf(
    DocumentTypeModel.ID_DOCUMENT_FRONT,
    DocumentTypeModel.ID_DOCUMENT_BACK,
    DocumentTypeModel.DRIVER_LICENSE_FRONT,
    DocumentTypeModel.DRIVER_LICENSE_BACK,
    DocumentTypeModel.MC_DOCUMENT_FRONT,
    DocumentTypeModel.MC_DOCUMENT_BACK,
    DocumentTypeModel.INE_FRONT,
    DocumentTypeModel.INE_BACK,
    DocumentTypeModel.SELFIE,
    DocumentTypeModel.PASSPORT,
    DocumentTypeModel.PROOF_OF_ADDRESS,
    DocumentTypeModel.PROOF_OF_FUNDS
  )
)
startActivity(intent)

To start using this feature on a navigation controller, add the destination AccountsActivity to your navigation graph and connect it. An action will be generated that will have to have the arguments embedded, as follows.

<fragment
android:id="@+id/accounts_dossiers_fragment_replace"
android:name="com.example.app.ReplaceDossierFragment">
<action
    android:id="@+id/action_accounts_dossiers_fragment_replace_to_accounts_activity"
    app:destination="@id/accounts_activity" />
</fragment>

<activity
    android:id="@+id/accounts_activity"
    android:name="com.alviere.android.accounts.activity.view.AccountsActivity">
    <argument
        android:name="accounts_extra_feature"
        app:argType="com.alviere.android.accounts.AccountsSdk$Features" />
    <argument
        android:name="accounts_extra_session_token"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_external_id"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_dossier_uuid"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
    <argument
        android:name="accounts_extra_primary"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_document_capture_only"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_files_to_capture"
        app:argType="com.alviere.android.accounts.sdk.model.common.DocumentTypeModel[]" />
</activity>

A class is created for each destination where an action originates. The name of this class is the name of the originating destination, appended with the word "Directions". For example, if the originating destination is a fragment that is named ReplaceDossierFragment, the generated class would be called ReplaceDossierFragmentDirections. This class has a method for each action defined in the originating destination, such as actionAccountsDossiersFragmentReplaceToAccountsActivity() that returns a NavDirections object. This returned NavDirections object can then be passed directly to navigate(), as shown in the following example:

view.findNavController().navigate(
  ReplaceDossierFragmentDirections.actionAccountsDossiersFragmentReplaceToAccountsActivity(
    accountsExtraFeature = AccountsSdk.Features.REPLACE_DOSSIER,
    accountsExtraSessionToken = session_token,
    accountsExtraUuid = account_uuid,
    accountsExtraDossierUuid = dossier_uuid,
    accountsExtraFilesToCapture = arrayOf(
      DocumentTypeModel.ID_DOCUMENT_FRONT,
      DocumentTypeModel.ID_DOCUMENT_BACK,
      DocumentTypeModel.DRIVER_LICENSE_FRONT,
      DocumentTypeModel.DRIVER_LICENSE_BACK,
      DocumentTypeModel.MC_DOCUMENT_FRONT,
      DocumentTypeModel.MC_DOCUMENT_BACK,
      DocumentTypeModel.INE_FRONT,
      DocumentTypeModel.INE_BACK,
      DocumentTypeModel.SELFIE,
      DocumentTypeModel.PASSPORT,
      DocumentTypeModel.PROOF_OF_ADDRESS,
      DocumentTypeModel.PROOF_OF_FUNDS
    )
  )
)

The result of this actions will return the specific DossierDetailsModel on onReplaceSuccess(dossier: DossierDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Document Capture Only

Document Capture Only, a Capture Mode through Activity or through the navigation controller. To get started, set the Accounts SDK event listener.

AccountsSdk.setEventListener(documentCaptureSdkCallback)

Activity

To start using this feature on an activity, create an Intent using accountsService.documentCaptureByIntent, pass the parent_activity and an array of files to be capture using DocumentTypeModel with a selection of different document types.

val intent = accountsService.documentCaptureByIntent(
  parentActivity = parent_activity,
  filesToCapture = arrayOf(
    DocumentTypeModel.ID_DOCUMENT_FRONT,
    DocumentTypeModel.ID_DOCUMENT_BACK,
    DocumentTypeModel.DRIVER_LICENSE_FRONT,
    DocumentTypeModel.DRIVER_LICENSE_BACK,
    DocumentTypeModel.MC_DOCUMENT_FRONT,
    DocumentTypeModel.MC_DOCUMENT_BACK,
    DocumentTypeModel.INE_FRONT,
    DocumentTypeModel.INE_BACK,
    DocumentTypeModel.SELFIE,
    DocumentTypeModel.PASSPORT,
    DocumentTypeModel.PROOF_OF_ADDRESS,
    DocumentTypeModel.PROOF_OF_FUNDS
  )
)
startActivity(intent)

To start using this feature on a navigation controller, add the destination AccountsActivity to your navigation graph and connect it. An action will be generated that will have to have the arguments embedded, as follows.

<fragment
    android:id="@+id/accounts_document_capture"
    android:name="com.example.app.DocumentCaptureFragment">
    <action
        android:id="@+id/action_accounts_document_capture_to_accounts_activity"
        app:destination="@id/accounts_activity" />
</fragment>

<activity
    android:id="@+id/accounts_activity"
    android:name="com.alviere.android.accounts.activity.view.AccountsActivity">
    <argument
        android:name="accounts_extra_feature"
        app:argType="com.alviere.android.accounts.AccountsSdk$Features" />
    <argument
        android:name="accounts_extra_document_capture_only"
        app:argType="boolean"
        android:defaultValue="false" />
    <argument
        android:name="accounts_extra_files_to_capture"
        app:argType="com.alviere.android.accounts.sdk.model.common.DocumentTypeModel[]" />
</activity>

A class is created for each destination where an action originates. The name of this class is the name of the originating destination, appended with the word "Directions". For example, if the originating destination is a fragment that is named DocumentCaptureFragment, the generated class would be called DocumentCaptureFragmentDirections. This class has a method for each action defined in the originating destination, such as actionAccountsDocumentCaptureToAccountsActivity() that returns a NavDirections object. This returned NavDirections object can then be passed directly to navigate(), as shown in the following example:

view.findNavController().navigate(
  DocumentCaptureFragmentDirections.actionAccountsDocumentCaptureToAccountsActivity(
    accountsExtraFeature = AccountsSdk.Features.DOCUMENT_CAPTURE,
    accountsExtraDocumentCaptureOnly = true,
    accountsExtraFilesToCapture = arrayOf(
      DocumentTypeModel.ID_DOCUMENT_FRONT,
      DocumentTypeModel.ID_DOCUMENT_BACK,
      DocumentTypeModel.DRIVER_LICENSE_FRONT,
      DocumentTypeModel.DRIVER_LICENSE_BACK,
      DocumentTypeModel.MC_DOCUMENT_FRONT,
      DocumentTypeModel.MC_DOCUMENT_BACK,
      DocumentTypeModel.INE_FRONT,
      DocumentTypeModel.INE_BACK,
      DocumentTypeModel.SELFIE,
      DocumentTypeModel.PASSPORT,
      DocumentTypeModel.PROOF_OF_ADDRESS,
      DocumentTypeModel.PROOF_OF_FUNDS
    )
  )
)

The result of this actions will return the specific List<DocumentCaptureDetailsModel> on onSuccess(documents: List<DocumentCaptureDetailsModel>) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

List Dossiers

To obtain an user account dossiers of documents, use the Accounts SDK service method accountsService.listDossiers. Pass the session_token, the account_uuid and the ListDossiersSdkCallback.

accountsService.listDossiers(
    sessionToken = session_token,
    accountUuid = account_uuid,
    clientCallback = accountDocumentCallback
)

The result of this action will return the specific List<DossierDetailsModel> on onSuccess(dossiers: List<DossierDetailsModel>) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Get Dossier

To obtain an user account dossier of documents, use the Accounts SDK service method accountsService.getDossier. Pass the session_token, the account_uuid, the dossier_uuid and the GetDossierSdkCallback.

accountsService.getDossier(
    sessionToken = session_token,
    accountUuid = account_uuid,
    dossierUuid = dossier_uuid,
    clientCallback = getDossierSdkCallback
)

The result of this action will return the specific DossierFileDetailsModel on onSuccess(dossier: DossierFileDetailsModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Delete Dossier

To delete an user account dossier of documents, use the Accounts SDK service method accountsService.deleteDossier. Pass the session_token, the account_uuid, the dossier_uuid and the DeleteDossierSdkCallback.

accountsService.deleteDossier(
    sessionToken = session_token,
    accountUuid = account_uuid,
    documentId = dossier_uuid,
    clientCallback = deleteDossierSdkCallback
)

The result of this action will return on onSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Alternative Usage

Optionally for every SDK callback entry function without UI, there is an alternative suspend function with the same name without callback to run inside a kotlin coroutine. Internal code will run with withContext(Dispatchers.IO) and will return an object of type Response<T>.

val response = ...
when (response) {
  is Response.Success -> { response.data }
  is Response.Error -> { response.metadata }
}

Fraud Prevention Service

The Accounts SDK has a built-in fraud prevention service. To fully enable the service you need to setup by calling FraudDetection.initFraudDetection(application)

class AppApplication : Application() {

  override fun onCreate() {
    // ...
    FraudDetection.initFraudDetection(this)
    // ...
  }
}

If you already have an account created and want to activate the service on the next app run you just need to set the accountUuid on the service as the user id. For example, you can do this on calling FraudDetection.setFraudUserId(account_uuid) method, as shown below.

private suspend fun xpto(): Response<_> {
  return try {
    when (val resource = alviereRepo.createUser(...)) {
      is Resource.Success -> {
        // ...
        FraudDetection.setFraudUserId(result.account.accountUuid)
      }
      is Resource.Error -> Response.Error(...)
    }
  } catch (e: Throwable) {
    // ...
  }
}

Customization

To start using AccountsCustomize create the custom object and set it by AccountsSdk.setCustomize. This will override only the values that you want to customize.

First we have customization objects by features, as follows:

Class Attribute Description
AccountsCustomize documentsCustomize Documents capture customization

Then we have all the view components for each of these features. As follows:

Class Attribute Description
ToolbarCustomize backgroundColorRes Background color resource
showBackButton Back button visibility
showCloseButton Close button visibility
Class Attribute Description
LoadingCustomize backgroundColorRes Background color resource
loadingBarColorRes Loading bar color resource
loadingTitleRes Loading title text resource
loadingTitleColorRes Loading title color resource
loadingTitleTextSizeRes Loading title text size resource
loadingMessageRes Loading message text resource
loadingMessageColorRes Loading message color resource
loadingMessageTextSizeRes Loading message text size resource
loadingBarColor Loading bar color
loadingTitle Loading title text
loadingTitleColor Loading title color
loadingTitleTextSize Loading title text size
loadingMessage Loading message text
loadingMessageColor Loading message color
loadingMessageTextSize Loading message text size
Class Attribute Description
TryAgainCustomize toolbarCustomize Toolbar customization
backgroundColorRes Background color resources
errorIcon Error drawable
errorMessageRes Error message resources
errorMessageColorRes Error message color resources
errorMessageTextSizeRes Error message text size resources
buttonBackgroundRes Button background drawable
buttonTextRes Button text resources
buttonTextColorRes Button text color resources
buttonMarginStartRes Button margin start resources
buttonMarginEndRes Button margin end resources
buttonMarginBottomRes Button margin bottom resources
buttonMarginTopRes Button margin top resources
buttonTextSizeRes Button text size resources
backgroundColor Background color
errorMessage Error message
errorMessageColor Error message color
errorMessageTextSize Error message text size
buttonText Button text
buttonTextColor Button text color
buttonTextSize Button text size
buttonMarginStart Button margin start
buttonMarginEnd Button margin end
buttonMarginBottom Button margin bottom
buttonMarginTop Button margin top
Class Attribute Description
AlviereTextViewCustomize textColorRes text color resource
textSizeRes Text size resource
textColor Text color
textSize Text size
Class Attribute Description
AlviereButtonCustomize textRes Button text resource
textColorRes Button text color resource
textSize Button text size resource
backgroundDrawable Button background drawable
marginStartRes Button margin start resource
marginEndRes Button margin end resource
marginBottomRes Button margin bottom resource
marginTopRes Button margin top resource
height Button height resource
text Button text
textColor Button text color
textSize Button text size
marginStart Button margin start dimension
marginEnd Button margin end dimension
marginBottom Button margin bottom dimension
marginTop Button margin top dimension
height Button height dimension
Class Attribute Description
AlviereTextInputEditTextCustomize textColorRes Input text color resource
textSizeRes Input text size resource
textColor Input text color
textSize Input text size
Class Attribute Description
AlviereEditTextCustomize textColorRes Edit text color resource
textSizeRes Edit text size resource
textColor Edit text color
textSize Edit text size

View Resources

In addition to all Accounts SDK functionalities, the Alviere SDKs also provides the ability to customize view resources.

Custom view components can be configured in two ways. The easiest (and recommended) method is by overriding colors.xml, strings.xml and dimens.xml resources, setting the key and value according to the following table. Alternatively, you can create customization object.

Override resources

To start using the customization by resources just override the keys that you want to customize.

Themes

The Accounts SDK for Android allows you to customize the main UI Theme used by activities. To do so, you will need to override the theme key that you want to change on your themes.xml file from values and values-night folder. Some UI elements use specific colors that need to be override apart in values and values-night.

<style name="AccountsSdkTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
    <item name="colorPrimary">@color/alviere_sdk_accounts_color_primary</item>
    <item name="colorPrimaryVariant">@color/alviere_sdk_accounts_color_primary_variant</item>
    <item name="colorOnPrimary">@color/alviere_sdk_accounts_color_on_primary</item>
    <item name="colorSecondary">@color/alviere_sdk_accounts_color_secondary</item>
    <item name="colorSecondaryVariant">@color/alviere_sdk_accounts_color_secondary_variant</item>
    <item name="colorOnSecondary">@color/alviere_sdk_accounts_color_on_secondary</item>
    <item name="android:statusBarColor">@color/alviere_sdk_accounts_color_status_bar</item>
    <item name="android:navigationBarColor">@color/alviere_sdk_accounts_color_navigation_bar</item>
    <item name="android:windowBackground">@color/alviere_sdk_accounts_color_background</item>
    <item name="android:fontFamily">@string/alviere_sdk_accounts_font</item>
    <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="AccountsSdkTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AccountsSdkDocumentsCaptureTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:navigationBarColor">@color/alviere_black</item>
    <item name="android:fontFamily">@string/alviere_sdk_accounts_font</item>
</style>

<style name="AccountsSdkFacialCaptureTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:navigationBarColor">@color/alviere_black</item>
    <item name="android:fontFamily">@string/alviere_sdk_accounts_font</item>
</style>

Fonts

The Accounts SDK for Android allows you to customize the UI font. To do so, you will need to override the font key that you want to change on your strings.xml file. The next section details a list of the current available keys.

Key AccountsCustomize Support
alviere_sdk_accounts_font No

Colors

The Accounts SDK for Android allows you to customize the UI colors. To do so, you will need to override the color key that you want to change on your colors.xml file from values and values-night folders. The next section details a list of the current available keys.

Key AccountsCustomize Support
alviere_sdk_accounts_color_primary No
alviere_sdk_accounts_color_primary_variant No
alviere_sdk_accounts_color_on_primary No
alviere_sdk_accounts_color_secondary No
alviere_sdk_accounts_color_secondary_variant No
alviere_sdk_accounts_color_on_secondary No
alviere_sdk_accounts_color_status_bar No
alviere_sdk_accounts_color_navigation_bar No
alviere_sdk_accounts_color_background No
Key AccountsCustomize Support
alviere_sdk_accounts_capture_surround_overlay_color No
alviere_sdk_accounts_capture_oval_error_color No
alviere_sdk_accounts_capture_oval_success_color No
alviere_sdk_accounts_capture_success_color No
alviere_sdk_accounts_manual_capture_title_color Yes (manualCaptureTitleTv)
alviere_sdk_accounts_manual_capture_option_color Yes (manualCaptureOptionsTv)
Key AccountsCustomize Support
alviere_sdk_accounts_loading_background Yes
alviere_sdk_accounts_loading_bar Yes
alviere_sdk_accounts_loading_title Yes
alviere_sdk_accounts_loading_message Yes
Key AccountsCustomize Support
alviere_sdk_accounts_try_again_background Yes
alviere_sdk_accounts_try_again_error_message_text_color Yes
alviere_sdk_accounts_try_again_button_background Yes
alviere_sdk_accounts_try_again_button_background_pressed Yes
alviere_sdk_accounts_try_again_button_text Yes
Key AccountsCustomize Support
alviere_sdk_accounts_toolbar_background Yes
alviere_sdk_accounts_toolbar_title_text_color No
alviere_sdk_accounts_toolbar_buttons_color No

Text and Localization

The Accounts SDK for Android allows you to customize the UI text. To do so, you will need to override the string key that you want to change on your strings.xml file. The next section details a list of the current available keys. Currently, the SDK only supports english.

Key English Value AccountsCustomize Support
alviere_sdk_accounts_documents_title_id_document_front Card Front Yes
alviere_sdk_accounts_documents_title_id_document_back Card Back Yes
alviere_sdk_accounts_documents_title_driver_license_front Driver License Front Yes
alviere_sdk_accounts_documents_title_driver_license_back Driver License Back Yes
alviere_sdk_accounts_documents_title_mc_document_front Matrícula Consular Front Yes
alviere_sdk_accounts_documents_title_mc_document_back Matrícula Consular Back Yes
alviere_sdk_accounts_documents_title_ine_document_front INE Front Yes
alviere_sdk_accounts_documents_title_ine_document_back INE Back Yes
alviere_sdk_accounts_documents_title_passport Passport Yes
alviere_sdk_accounts_documents_title_proof_of_address Proof of address Yes
alviere_sdk_accounts_documents_title_proof_of_funds Proof of funds Yes
alviere_sdk_accounts_documents_title_selfie Selfie Yes
alviere_sdk_accounts_documents_message_id_document_front Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_id_document_back Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_driver_license_front Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_driver_license_back Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_mc_document_front Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_mc_document_back Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_ine_document_front Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_ine_document_back Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_passport Place ID on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_proof_of_address Place document on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_proof_of_funds Place document on a flat surface. Please no fingers, hands or reflections. Yes
alviere_sdk_accounts_documents_message_selfie Smile to automatically grab your picture. Yes
alviere_sdk_accounts_documents_message_selfie_manual Take a picture Yes
alviere_sdk_accounts_documents_step Step %1$d of %2$d Yes
alviere_sdk_accounts_documents_is_photo_ok Accept photo? Yes
alviere_sdk_accounts_documents_accept_photo Accept Yes
alviere_sdk_accounts_documents_retake Cancel Yes
alviere_sdk_accounts_documents_success Success Yes
Key English Value AccountsCustomize Support
alviere_sdk_accounts_facialcapture_hint_no_face No face detected No
alviere_sdk_accounts_facialcapture_hint_multiple_faces Multiple faces detected No
alviere_sdk_accounts_facialcapture_hint_face_center Center Face In The Oval No
alviere_sdk_accounts_facialcapture_hint_get_farther Get farther No
alviere_sdk_accounts_facialcapture_hint_get_closer Get closer No
alviere_sdk_accounts_facialcapture_hint_smile Smile No
alviere_sdk_accounts_facialcapture_hint_stop_smiling Stop smiling No
alviere_sdk_accounts_facialcapture_hint_press_capture_button Press button when ready No
alviere_sdk_accounts_facialcapture_hint_hold_still Hold Still No
Key English Value AccountsCustomize Support
alviere_sdk_accounts_misnap_hint_too_dim Too dim No
alviere_sdk_accounts_misnap_hint_too_bright Too bright No
alviere_sdk_accounts_misnap_hint_hold_steady Hold Still No
alviere_sdk_accounts_misnap_hint_too_far Too far No
alviere_sdk_accounts_misnap_hint_too_close Too close No
alviere_sdk_accounts_misnap_hint_angle_too_large Angle too large No
alviere_sdk_accounts_misnap_hint_angle_rotation Reduce rotation No
alviere_sdk_accounts_misnap_hint_glare Reduce glare No
alviere_sdk_accounts_misnap_hint_busy_background Busy background No
alviere_sdk_accounts_misnap_hint_low_contrast Low contrast No
alviere_sdk_accounts_misnap_hint_wrong_document Center the document No
Key English Value AccountsCustomize Support
alviere_sdk_accounts_loading_title Yes
alviere_sdk_accounts_loading_message Uploading Yes
Key English Value AccountsCustomize Support
alviere_sdk_accounts_try_again_error_message An error has occurred No
alviere_sdk_accounts_try_again_error_button_text Try again No

Dimensions

The Accounts SDK for Android allows you to customize the UI dimensions. To do so, you will need to override the dimension key that you want to change on your dimens.xml file. The next section details a list of the current available keys.

Key AccountsCustomize Support
alviere_sdk_accounts_documents_title_max_size Yes
alviere_sdk_accounts_capture_overlay_bar_padding No
alviere_sdk_accounts_capture_text_padding No
alviere_sdk_accounts_manual_capture_title_size Yes (manualCaptureTitleTv)
alviere_sdk_accounts_manual_capture_option_size Yes (manualCaptureOptionsTv)
Key AccountsCustomize Support
alviere_sdk_accounts_loading_title_text_size Yes
alviere_sdk_accounts_loading_message_text_size Yes
Key AccountsCustomize Support
alviere_sdk_accounts_try_again_button_margin_start Yes
alviere_sdk_accounts_try_again_button_margin_end Yes
alviere_sdk_accounts_try_again_button_margin_bottom Yes
alviere_sdk_accounts_try_again_button_margin_top Yes
alviere_sdk_accounts_try_again_button_corner_radius No
alviere_sdk_accounts_try_again_button_text_size Yes
alviere_sdk_accounts_try_again_message_text_size Yes