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) {
        
    }

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

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

    override fun onDismissed() {
        
    }
}
Dapi.setConnectListener(new OnDapiConnectListener() {
    @Override
    public void onConnectionSuccessful(@NonNull DapiConnection connection) {

    }

    @Override
    public void onConnectionFailure(@NonNull DapiError error, @NonNull String bankID) {

    }

    @Override
    public void onBankRequest(@NonNull String bankName, @NonNull String iban) {

    }

    @Override
    public void onDismissed() {

    }
});

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()

getAccountsMetaData

A method for obtaining bank account metadata

Parameters

Method does not receive any parameter.

Example

connection.getAccountsMetaData({ accountsMetaDataResponse ->
                    
}, { error ->
                    
})

Get Parameters

A method for obtaining the connection parameters

Parameters

Method does not receive any parameter.

Example

connection.getParameters({ parameters ->
    
}, { error ->
    
})

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 ->
    
})

What’s Next