Changelog

Error Handling

This guide will help you handle and troubleshoot errors that may occur while using Dapi Android SDK.

When using Dapi Android SDK, any errors that occur will be passed to you as a DapiError object. This object contains detailed information about the error.

ParameterTypeDescription
typeStringError type.
messageStringError message.
localizedMessageStringError localized message based on language configuration.
operationIDStringUnique ID generated by Dapi to identify a specific operation.
titleStringError title.
coolDownPeriodDapiBeneficiaryCoolDownPeriodBeneficiary cool down period information (unit, value)

Bank Account Linking

To receive error events from the Connect Layer, implement the DapiConnectCallback interface. The interface has four methods - onConnectionSuccessful, onConnectionFailure, onBankRequest, and onDismissed - which are called depending on the result of the connection attempt. In the onConnectionFailure method, you can access the error object by calling result.error and handle it accordingly.

Dapi.connectCallback = object : DapiConnectCallback {
	//Callback function to be invoked after a successful bank login attempt.
    override fun onConnectionSuccessful(result: DapiConnectResult.Success) { }

	//Callback function to be invoked after a failed bank login attempt.
    override fun onConnectionFailure(result: DapiConnectResult.Error) {
        val error = result.error
        //...
    }

	//Callback function to be invoked after the user requests a bank.
    override fun onBankRequest(result: DapiConnectResult.BankRequest) {}

	//Callback function to be invoked after the user manually exit Connect.
    override fun onDismissed() {}
}

Transfer

To receive error events from transfer attempts, implement the DapiTransferCallback interface. The interface has four methods - onTransferSuccess, onTransferFailure, willTransferAmount, and onUiDismissed - which are called depending on the result of the transfer attempt. In the onTransferFailure method, you can access the error object by calling result.error and handle it accordingly.

Dapi.transferCallback = object : DapiTransferCallback {
    //Callback function to be invoked after a successful initiation of money transfer. 
    override fun onTransferSuccess(result: DapiTransferResult.Success) {}
  
    //Callback function to be invoked after a failed money transfer attempt.
    override fun onTransferFailure(result: DapiTransferResult.Error) {
         val error = result.error
        //...
    }
    
	//Callback function to be invoked before making the transfer from Dapi transfer UI. When Send button is clicked either on the Amount screen or the Accounts screen.
    override fun willTransferAmount(result: DapiTransferResult.PreTransfer) {}

  	//Callback function to be invoked after transfer UI is dismissed.
    override fun onUiDismissed() {}
}

Beneficiary Cool Down

Some banks do not allow immediate transfers to a newly added beneficiary. Beneficiary Cooldown time shows how long the user needs to wait before they can make a transfer to a newly added beneficiary.

You can know the potential cooldown value ahead of time by using Get Account Metadata endpoint. The value varies bank to bank.

If you encounter a BENEFICIARY_COOL_DOWN_PERIOD error, you will receive an error object with error type set to BENEFICIARY_COOL_DOWN_PERIOD and the object will contain information about the beneficiary cooldown period coolDownPeriod, including the unit and value, which you can access to handle the error appropriately.

override fun onTransferFailure(result: DapiTransferResult.Error) {
  val coolDownPeriod = result.error.coolDownPeriod
  val unit = coolDownPeriod?.unit
  val value = coolDownPeriod?.value
}

If the user attempts to retry the request before the beneficiary cooldown period is complete, the error.type will still be BENEFICIARY_COOL_DOWN_PERIOD. However, in this case, the error.coolDownPeriod value will be null.

Other APIs

To call any other API, you will need to implement two lambda functions - one for handling success event and another for handling error event. In the onFailure callback, you can access the error object and handle the error accordingly. Here is an example of how to use the getAccounts API with these callbacks:

connection.getAccounts(
    onSuccess = { accounts ->  
        // handle successful response
    }, 
    onFailure = { error -> 
        // handle error
    }
)