teller_connect_flutter
A Flutter plugin for integrating the Teller Connect SDK, allowing seamless connection to financial institutions and access to financial data.
Table of Contents
Supported Platforms
- ✅ Android
- ⏳ iOS (coming soon)
Installation
In the pubspec.yaml
of your flutter project, add the following dependency:
dependencies:
...
teller_connect_flutter: ^0.9.4
Usage
In your library add the following import:
import 'package:teller_connect_flutter/teller_connect_flutter.dart';
Initialize
Call the initialize
method in main
to initialize the SDK.
void main() {
TellerConnectFlutter.initialize();
runApp(MyApp());
}
Later in the app, you can call the methods on TellerConnectFlutter.instance
to interact with the SDK.
Features
Start Teller Connect
To initiate the Teller Connect flow, use the startTellerConnect
method:
TellerConnectFlutter.instance.startTellerConnect(
appId: 'your_app_id',
saveToken: (token) async {
// Save the token securely
},
getToken: () async {
// Retrieve the saved token
},
...
);
Parameters:
Property | Default Value | Description and Available Values |
---|---|---|
appId (Required) |
- | Your Teller application ID. Retrieve it from the teller console. |
saveToken (Required) |
- | A callback function to persist the access token according to your choice. This is implicitly called when a RegisterSuccessEvent is received in the event stream. |
getToken (Required) |
- | A callback function to retrieve the saved access token. This is called during API calls for accounts, transactions, etc. An incorrect return value from this method will result in failed responses from other API methods. |
environment (Optional) |
TellerEnvironment.development |
The Teller environment to use. Options: TellerEnvironment.sandbox : It never communicates with a real institution, it is used to create sandbox enrollments, accounts and tokens Suitable for testing, TellerEnvironment.development : Uses the actual account credentials to establish connection. The same as production but is not billed and has a hard limit of 100 enrollments, TellerEnvironment.production : Suitable for release buils. Requires billing details to be setup in teller console. |
selectAccount (Optional) |
TellerSelectAccount.disabled |
Account selection mode. Options: TellerSelectAccount.disabled : Automatically connect all the supported financial accounts associated with this user's account at the institution, TellerSelectAccount.single : The user will see a list of supported financial accounts and will select only one to share with your application, TellerSelectAccount.multiple : The user will see a list of supported financial accounts and will select one or more to share with your application. |
products (Optional) |
All products | List of Teller products to enable. This controls which APIs are made accessible to the token for this enrollment. Options: TellerProduct.accounts : Account details like name, account number, routing number etc., TellerProduct.identity : Accounts owner's details and billing address etc. Doesn't involve balance, TellerProduct.transactions : Accounts' transactions, TellerProduct.balance : Accounts' balances along with other details. |
debug (Optional) |
false |
Enable debug mode. Logs more information. |
enrollmentId (Optional) |
- | An id of a previously created enrollment. Use to initialize Teller Connect in update mode to repair a disconnected or expired enrollment without requiring user to provide credentials again. |
userId (Optional) |
- | The User ID of the Teller user you want to add more enrollments to. Provide it to add more bank integrations to the same user. |
nonce (Optional) |
- | A nonce for additional security. Your application must choose an arbitrary string to allow for the cryptographic signing of the enrollment object received upon successful registration. This prevents token reuse attacks. The value must be randomly generated on the server and unique to the current session. If generated client-side, an attacker could reuse the nonce together with the enrollment object from another session to impersonate the victim. |
connectToken (Optional) |
- | A connect token is returned in a Teller API response when user interaction is required to complete the transaction, e.g. when multi-factor authentication is required to complete a payment. When initialized with a connectToken Teller Connect will guide the user through completing the transaction. Used when startTellerConnect is called for payment APIs. |
institution (Optional) |
- | Pre-select an institution. When set to a valid institution id Teller Connect will skip its institution picker and load the first step for the corresponding institution. Use this to build your own picker experience. |
Event Stream
TellerConnectFlutter provides an event stream that you can listen to for updates on the Teller Connect process. You can access this stream using TellerConnectFlutter.instance.onTellerEvent
.
Listening to Events
TellerConnectFlutter.instance.onTellerEvent.listen((event) {
// Handle different event types
switch (event) {
case InitEvent _: return print('TellerConnect initialized');
case final RegisterSuccessEvent r:
print(
'''TellerConnect registered successfully:
token: ${r.accessToken},
userId: ${r.userId},
institution: ${r.institutionName},
enrollmentId: ${r.enrollmentId}''',
);
case final FailureEvent f:
return print(
'''TellerConnect failed:
${f.message},
code: ${f.code},
type: ${f.type}''',
);
case ExitEvent _: return print('TellerConnect exited');
// ... handle other event types
default:
return print('TellerConnect event: $event');
}
});
Event Types
The stream returns the following event types, all of which are a subclass of TellerEventModel
:
Event | Description | Parameters |
---|---|---|
InitEvent |
The SDK has been initialized. | - |
RegisterSuccessEvent |
The Teller Connect registration was successful. | Parameters:
|
PaymentSuccessEvent |
The payment was successful. | Parameters:
|
PayeeSuccessEvent |
The payee was successfully added. | Parameters:
|
FailureEvent |
The registration failed. | Parameters:
|
ExitEvent |
The user exited the Teller Connect flow. | - |
Event |
A generic event type. | Parameters:
|
Data Access
After a successful enrollment, you can access financial data. The SDK provides methods to get connected accounts and transactions.
Note: Transactions and details will only be returned for accounts that were selected during the Teller Connect enrollment process.
final teller = TellerConnectFlutter.instance;
// Get connected accounts
List<AccountModel> accounts = await teller.getConnectedAccounts(enrollmentId);
// Get account details
AccountModel account = await teller.getAccount(accountId: accountId, enrollmentId: enrollmentId);
// Remove all connected accounts
bool isRemoved = await teller.removeAccounts(enrollmentId);
// Remove a connected account
bool isRemoved = await teller.removeAccount(accountId: accountId, enrollmentId: enrollmentId);
// Get transactions for an account
List<TransactionModel> transactions = await teller.getAccountTransactions(
accountId: accountId,
enrollmentId: enrollmentId,
count: 10,
fromId: 'LAST_TRANSACTION_ID',
);
// or await teller.getAccountTransactions(accountId) for all transactions. It is a good idea to load all transactions for the first call and then use the `count` and `fromId` parameters to load more transactions in future.
// Get transaction details
TransactionModel transaction = await teller.getTransaction(accountId, transactionId);
Example
import 'package:flutter/material.dart';
import 'package:teller_connect_flutter/teller_connect_flutter.dart';
void main() {
// 1. Initialize the SDK
TellerConnectFlutter.initialize();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late StreamSubscription<TellerEventModel> _subscription;
@override
void initState() {
super.initState();
// 2. Listen to Teller Connect events
_subscription = TellerConnectFlutter.onTellerEvent.listen(_handleTellerEvent);
}
void _handleTellerEvent(TellerEventModel event) {
if (event is InitEvent) {
print('Teller Connect initialized');
} else if (event is RegisterSuccessEvent) {
print('Registration successful: ${event.accessToken}');
// Handle successful registration
} else if (event is FailureEvent) {
print('Error: ${event.message}');
// Handle failure
}
}
void _startTellerConnect() {
TellerConnectFlutter.instance.startTellerConnect(
appId: 'your_app_id',
saveToken: (String token, String enrollmentId) async {
// Save the token to your server. Called internally upon succesful teller connection.
},
getToken: (String enrollmentId) async {
// Get the token from your server
// return "token";
}
environment: TellerEnvironment.development,
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Teller Connect Example')),
body: Center(
child: ElevatedButton(
onPressed: _startTellerConnect, // 3. Start Teller Connect
child: Text('Start Teller Connect'),
),
),
),
);
}
@override
void dispose() {
_subscription.cancel();
super.dispose();
}
}
Additional Information
For more details about Teller Connect, visit the official Teller documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.