Create Bank Connection

Create Bank Connection

Let's now create a connection object. A connection represents a user's connection to a bank. So if they authenticate and login, through Dapi, to 2 banks there will be 2 connections.
Since you don't know yet which bank the user will choose, you will just display the connect page. The user has to then pick the bank and enter their credentials.

Dapi.presentConnect()
Dapi.presentConnect();

Implement DapiConnectCallback to handle a successful or a failed connection attempt.

Dapi.connectCallback = object : DapiConnectCallback {
    override fun onConnectionSuccessful(result: DapiConnectResult.Success) {
        val connection = result.connection
        //....
    }

    override fun onConnectionFailure(result: DapiConnectResult.Error) {
        
    }

    override fun onBankRequest(result: DapiConnectResult.BankRequest) {
        
    }

    override fun onDismissed() {
        
    }
}
Dapi.setConnectCallback(new DapiConnectCallback() {
    @Override
    public void onConnectionSuccessful(@NonNull DapiConnectResult.Success result) {
        
    }

    @Override
    public void onConnectionFailure(@NonNull DapiConnectResult.Error result) {

    }

    @Override
    public void onBankRequest(@NonNull DapiConnectResult.BankRequest result) {

    }

    @Override
    public void onDismissed() {

    }
});

DapiConnection

ParameterTypeDescription
clientUserIDStringThe clientUserID that the connection is associated with.
userIDStringThe identifier that is unique for user A on bank A. There are no 2 individuals having the same userID ever. It will be invalidated if user A changed their bank’s login credentials.
tokenIDStringThe tokenId is dispatched by the Connect Layer to the SDK. And used to map the accessToken.
bankIdStringThe ID of the bank
swiftCodeStringThe bank account's swift code.
countryStringThe bank account's country.
nameStringThe bank short name.
fullNameStringThe bank full name.
accountsListThe cached accounts. Gets updated by a successful getAccounts() call.
cardsListThe cached cards. Gets updated by a successful getCards() call.
fullLogoPngStringThe URL for the full logo of the bank.
halfLogoPngStringThe URL for the half logo of the bank.
miniLogoPngStringThe URL for the mini logo of the bank.
colorMapThe bank colors with keys: primaryColor, secondaryColor.

That's it. You can now try to run your app on the emulator and call the presentConnect function and see Dapi in action!

Create Sandbox User

You can create users for sandbox environment to test your integration with Dapi instead of connecting your real accounts

Navigate to Dashboard -> Apps -> Your App -> Sandbox -> Create a Sandbox User

Enter the following details and click Submit.

  • Sandbox Bank: select a bank from the dropdown list
  • Sandbox Username : username of your choice
  • Sandbox Password : password of your choice
1384

In order to add accounts to a sandbox user, click the NEW button on the Accounts column and provide the following information:

  • Acount Name: user's account name (You can see it on the Account Information dialog when you click an account from the Sandbox Users table.)
  • Account Number: user's account number (You can see it on the Account Information dialog)
  • IBAN: user's IBAN (You can see it on the Account Information dialog)
  • Account Type: choose a value from the dropdown
  • Balance: set a starting balance for the account
  • Currency: choose the currency for the account from the dropdown
1388

Get Cached Connections

When you authenticate and login through Dapi, a DapiConnection object is created and stored in the local cache containing information about your connection to the bank, so that you don't have to authenticate and login again every time you open the app.

Dapi.getConnections() returns the list of connections in cache.

Dapi.getConnections({ connections -> 
    if (connections.isNotEmpty()) {
        val connection = connections.first()
        val accounts = connection.accounts //cached accounts. gets updated by connection.getAccounts() call
        val cards = connection.cards //cached cards. gets updated by connection.getCards() call
        val clientUserID = connection.clientUserID
        val userID = connection.userID
        val bankId = connection.bankId
        val swiftCode = connection.swiftCode
        val country = connection.country
        val name = connection.name
        val fullName = connection.fullName
        val fullLogoPng = connection.fullLogoPng
        val halfLogoPng = connection.halfLogoPng
        val miniLogoPng = connection.miniLogoPng
        val accessCode = connection.accessCode
        val connectionID = connection.connectionID
        val tokenID = connection.tokenID
        val color = connection.color
    }
}, { error ->
    
})
Dapi.getConnections((connections) -> {
    DapiConnection connection = connections.get(0);
    List<DapiAccountsResponse.DapiAccount> accounts = connection.getAccounts(); //cached accounts. gets updated by connection.getAccounts(onSuccess, onFailure) call
    List<DapiCardsResponse.DapiCard> cards = connection.getCards(); //cached cards. gets updated by connection.getCards(onSuccess, onFailure) call
    String clientUserID = connection.getClientUserID();
    String userID = connection.getUserID();
    String bankId = connection.getBankId();
    String swiftCode = connection.getSwiftCode();
    String country = connection.getCountry();
    String name = connection.getName();
    String fullName = connection.getFullName();
    String fullLogoPng = connection.getFullLogoPng();
    String halfLogoPng = connection.getHalfLogoPng();
    String miniLogoPng = connection.getMiniLogoPng();
    String accessCode = connection.getAccessCode();
    String connectionID = connection.getConnectionID();
    String tokenID = connection.getTokenID();
    Map<String, String> color = connection.getColor();
    return null;
}, (error) -> {
    return null;
});

Dismiss Connect

Closes the presented Connect UI

Parameters

Method does not receive any parameter.

Example

Dapi.dismissConnect()
Dapi.dismissConnect();

getAccountsMetaData

A method for obtaining bank account metadata

Parameters

Method does not receive any parameter.

Example

connection.getAccountsMetaData({ accountsMetaDataResponse ->
                    
}, { error ->
                    
})
connection.getAccountsMetaData((metadata) -> {
    //Success..
    return Unit.INSTANCE;
}, (error) -> {
    //Error..
    return Unit.INSTANCE;
});

Get Parameters

A method for obtaining the connection parameters

Parameters

Method does not receive any parameter.

Example

connection.getParameters({ parameters ->
    
}, { error ->
    
})
connection.getParameters((params) -> {
    //Success..
    return Unit.INSTANCE;
}, (error) -> {
    //Error..
    return Unit.INSTANCE;
});

Response

{
   "bankId":"DAPIBANK_AE_ADCB",
   "clientUserID":"clientID",
   "color":{
      "primaryColor":"#BD0000",
      "secondaryColor":"#2A2B38"
   },
   "fullLogoPng":"https:\/\/cdn.dapi.com\/banks-full-logo\/ADCB.png",
   "fullName":"Abu Dhabi Commercial Bank Sandbox",
   "halfLogoPng":"https:\/\/cdn.dapi.com\/banks-horizontal-logo\/ADCB.png",
   "miniLogoPng":"https:\/\/cdn.dapi.com\/banks-mini-logo\/ADCB.png",
   "name":"ADCB Sandbox",
   "tokenID":"23302e94-e463-450a-8794-52c6a19cd271",
   "userID":"7x4orrsRTbIDXLcW2rgHbv1wVSsOOxHdRPg3v0SuSjH57LfPp5\/rFayQDnvnWnVg8C8XqaGaenWhN1gjMg6dzw==",
   "userSecret":"rAaanOaptNFQ2ealZAZpcH3C8YgBIbiczDmOLZR0Y2M3a3wq4AlDtbRlqtEQtmLNarMh7\/J1xVr3xwaaTNATPU4r8IE4zSY6Xm+GOML8v+ArTAYIsHEEIaqdsLgblUTUhKlGYOUuDdWHAatc6aMGsdhC+AcpeS\/JkSc8KaqX6BgusOuD0rPVL46mdKiRvO7Vu7t8J0KU4KDc8nYQt2IYGiz778S1aYjQoHVCCSLeyoQuzPAdkaOpSweNiCihSzFNI5\/OR8YyQezcpHTdgj5gCD1cXg7\/zl9XWBD\/KCRV8ldDHt3rzMpJjXZUieDQ7nS92hWxHjruoVL10U6o3nyc6NubfePFjXy4voHda\/G227SE2yQ4NLBzWy3KdHNRtGjMNBHX9A93x0IrCJamOS5y+A3lTL1xONnqhw9QsWd+\/t8bN\/3hX2R18NiLT\/wKy017CRC7nFoCwwsmitTXYRf9ZyZVe9UexDlX4vGnWdsJc3xzHw87IJH4\/s+32YVWX+73yVfUYyfcETFuZ6tGDY7YZkgBxAnEDFP97o1F0E6SPS\/zq7GS3t+7bXVuyA291F1pvqccFjCoLGkXdYhXnrDpdGtw1+tYecKAa5CpFS+q54KuSHlHi4BFzVN9C5jtKt4xEAv7Z1a1mSzOLXlzPCdX+rmWF9mJDKrN0\/Ydb5pQPgg="
}

Create Connection

Add a new connection based on connection parameters.

Parameters

ParameterDescription
jsonConnectionParametersDapiConnection's parameters, can be obtained using connection.getParameters()

Example

DapiConnection.create(parameters, { connection ->
    
}, { error ->
    
})
DapiConnection.create(params, (connection) -> {
    //Success..
    return Unit.INSTANCE;
}, (error) -> {
    //Error..
    return Unit.INSTANCE;
});

Delink Connection

Method is used to disconnect a user in your application from Dapi by invalidating their access token.

Parameters

Method does not receive any parameter.

Example

connection.delete(onSuccess = { response ->
   
}, onFailure = { error ->
    
})
connection.delete((response) -> {
    //Success..
    return Unit.INSTANCE;
}, (error) -> {
    //Error..
    return Unit.INSTANCE;
});