The integration was implemented using OOP (Factory Method).
The class handles the creation of users, connection of bank accounts, retrieval of transactions, accounts, and credentials, among other functionalities.
For more information please check Tink documentation (Transactions).
To use our Class you will need to copy the tink.ts
file or clonning this repository,
Before you begin make sure you have a .env
file and you have these properties filled in it:
CLIENT_ID = ''
CLIENT_SECRET = ''
BASE_URL = 'https://api.tink.com'
CLIENT_SCOPES = 'scope1:read, scope2:delete,...'
USERS_SCOPES = 'scope1:read, scope2:delete,...'
ACTOR_CLIENT_ID = ''
Import the Class and create instances:
import { TinkConnector, User } from "./tink";
//tink
const TinkObject = new TinkConnector();
const TinkUserObject = new User();
Generating a Client Access Token:
const clientToken = await TinkObject.ClientAccessToken();
Creating a user:
const user = await TinkObject.createUser(id)
Creating a delegate code:
const code = await TinkObject.DelegateCode(id, fullname)
Creating a Tink Link:
const options = {
"redirect_uri": "https://example.com/callback"
// You could add more if you want (Check Tink Link Documentation)
}
const options = await TinkObject.TinkObject.TinkLink(options)
All together :
const link = TinkObject.ClientAccessToken().then(() =>
TinkObject.createUser(id).then(() =>
TinkObject.DelegateCode(id, fullname).then(() =>
TinkObject.TinkLink(options),
),
),
);
This part can be execute a part from the first part if you have an active userAccessToken you dont need to call UserCode
and UserAccessToken
Retrieving Accounts :
const userCode = await TinkObject.UserCode(externalUserId);
await TinkUserObject.UserAccessToken(userCode);
const list_accounts = await TinkUserObject.Accounts()
Retrieving Transactions :
if you have an active userAccessToken you can pass the token in the userToken
Param
Here is the list of all the params you can use
// Without a userAccessToken
const userCode = await TinkObject.UserCode(externalUserId);
await TinkUserObject.UserAccessToken(userCode);
const list_transactions = await TinkUserObject.Transactions({
isBooked: true
});
// With a userAccessToken
const list_transactions = await TinkUserObject.Transactions({
isBooked: true,
userToken: req.body.userToken
});
This is a schema outlining how the flow will work, and these are the steps to follow.
- Implements typing for accounts and transactions
- Implements all the params for Transactions for the moment i implemented 5 && Generic Creation
Peace 🤘