Create Bank Connection

How to create a bank connection that is used for future API calls

Sandbox Environment Access

Our Sandbox environment allows you to simulate users and financial institutions with the full Dapi API workflow.
For more details check Get Started with Sandbox.


Create Bank Connection

Dapi Bank Connection is a tokenized access to one bank account. The Bank Connection parameters have to be used during all API calls.

A Bank Connection represents a user's connection to one bank. If the same user connects 2 banks on your application, there will be also 2 separate Bank Connection objects.

Bank Connection Using Connect Layer

All Bank Connections need to be established through Dapi's Connect Layer. Connect Layer is already embedded in the SDK and allows the users to choose the desired bank and provide their credentials.

Use DAPIConnectVC to display the connection flow:

let connectVC = DAPIConnectVC()
connectVC.delegate = self
present(connectVC, animated: true, completion: nil)

Use DAPIConnectDelegate to handle a successful or a failed adding bank connection attempt.

extension ViewController: DAPIConnectDelegate {
    ///Tells the delegate that user successfully authenticated
    func dapiConnect(_ dapiConnect: DAPIConnectVC,
                     didSuccessfullyConnectTo bankID: String?,
                     bankConnection: DAPIBankConnection) {
        print(connection)
    }
    ///Tells the delegate that bank connection failed with error message
    func dapiConnect(_ dapiConnect: DAPIConnectVC,
                     didFailConnectingWith error: String) {
        print(error)
    }
    ///Tells the delegate that user closed `dapiConnect` ViewController
    func dapiConnectUserDidCancel(_ dapiConnect: DAPIConnectVC) {
        print("User Did Cancel ")
    }
}

Bank Connection Using Connection Parameters

This approach can only be used if you are storing the connection parameters on your database.

Make sure that you have all of the required parameters in order to create a successful bank connection.

var parameters = [
  "userID": "U6Kx3/if3Ko7FDg9ypVoZmzzEWFMzrsVjVA/PNYoyiPF8HGl0CvaSpgnsnVep49H8D2pDEROAc3L24P+s6ZfrQ==",
  "tokenID": "f6335219-7466-44ef-8031-22e9739315cd",
  "connectionID": "a6479d32-d062-41f6-abea-0f374ed7d677",
  "clientUserID": "JohnDoe",
  "userSecret": "FhZ3gk9wSATykhqoawXaQg7/EdTltIThbQcmLVFV8rr6fwWbvYkTyW4an9d/6zLS+dFRzxuE2GGfxix9ZztWY+KVZXmQ11tRQgfQUTbrFr7WQdoWQnPjWFCDO7SoYZ4udsJAGcmLyxX7B/3maKGv3TDqLo+x9pK+3wKQQGnopO8UtP/t0Rocj1hJU98s5p5SaGr/BfsQwltjGvmfyFYFOyY1C7Q9dkm2VcYfKgqXnF4qFuLf2tU4X0h5uzjKBkJWMA707ARvcV2FUCbOQEw48AzD5fK9x2+prKQ3V8qHMLqWcMKGEPIfB5irQBRKZBR0b4btJGjgJ2WbF+jZPzLktbjthfayL8e5mTUWRvHfVkL86GRjZM2NHXbUI1D13jUZgI4UC9fHcQht/A6t36gjVZb7oY//GKwBDoPkkcsXNoIjlnpgO4Wr7NXM5XPveVbzHjmNjhs94p7bqSXbaQgoZSSS2ipJc3r9ezmT4s95SauXbKisFFhWJp42glio52eI68V7KWUE62P17TePytjlzZUTZa9g7vcN30ogQEYP3nbQmGmrlQ4fHjJzjuG2rHd3LAuQK/k5xaSd43xNFWXkn8mrCGFWXdAKedyxdyuUW9YnkNnUaYnJUq+smEU47PkxPAn5SNCfLqIP+X9eEpTcYj/O2vK7IhLnnFnT9cLSOP0=",
  "bankId": "DAPIBANK_AE_ENBD",
  "name": "ENBD" ] as [String: Any]

Dapi.shared.createBankConnection(parameters: parameters) { results in
    switch results {
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error.dapiMetaData)
        print(error.dapiErrorMessage)
    }
}

Get Cached Connections

When the user authenticates and logs in through Dapi, a DAPIBankConnection object is automatically created and stored in the local cache. DAPIBankConnection contains information about one bank connection.

When using a cached DAPIBankConnection, the user does not need to authenticate through the Connect Layer flow again.

Every DAPIBankConnection is associated with app_key, run_environment and client_ID

let connections = Dapi.shared.bankConnections
let connection = connections.first(where: {$0.bankInfo.bankFullName == "Royal Bank of Canada" })

Delete bank Connections

To delete or delink the bank connection you can use delink API, it will revoke the token and delete the bank connection from the SDK local cache.

let connections = Dapi.shared.bankConnections
let connection = connections.first(where: {$0.bankInfo.bankFullName == "Royal Bank of Canada" })

Dapi.shared.delink(bankConnection: connection) { results in
    switch results {
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error.dapiMetaData)
        print(error.dapiErrorMessage)
    }
}

👍

All set!

That's it. You can use Bank Connection to allow user make payment initiation and data integration


Account Metadata

A method for obtaining information about the user's bank. Useful for knowing special capabilities or restrictions for the specific financial institution.

Parameters

ParameterDescription
bankConnectionA connection to the bank that will be used to call APIs upon. The connection will include details about the bank. Check How To Create Bank Connection

Response
Check the Meta Data Response

Example

let connection = ... // selectedConnection or use Dapi.shared.connections to get cashed accounts

Dapi.shared.accountMetadata(bankConnection: connection) { results in
    switch results {
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error.dapiErrorMessage)
        print(error.dapiMetaData)
    }
}

What’s Next