Skip to content

Moneybounce/tink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tink integration for Moneybounce

Description

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

Installation

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 = ''

Usage

Import the Class and create instances:

import { TinkConnector, User } from "./tink";

//tink
const TinkObject = new TinkConnector();
const TinkUserObject = new User();

Before Tink-link

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),
   ),
 ),
 );

After Tink-link

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 userTokenParam

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

API Description

This is a schema outlining how the flow will work, and these are the steps to follow.

Capture d’écran 2022-04-27 à 17 03 19

TODO

  • Implements typing for accounts and transactions
  • Implements all the params for Transactions for the moment i implemented 5

Peace 🤘

Releases

No releases published

Packages

No packages published