Algoan

Algoan

  • Documentation
  • Quick Start
  • API Reference

›Implement your resthook

Quick Start

  • Introduction
  • Initialize your chatflow
  • Set up your project
  • Set up your service
  • Implement your resthook

    • Application Service
    • Folder Service
    • Aggregation Service
    • Score Service
    • Signature Service

    Score integration

    • Getting Started
    • With a connector
    • Without a connector
    • Using Algoan Connect

    Analytics API Usage

    • Getting Started

Aggregation Service

Aggregation

The aggregation process consists in fetching all available Open Banking data specific to a User.

The flow can be divided into three parts:

  1. The Applicant connects his accounts through a webview.
  2. Algoan transmits the Request to your service
  3. Your service aggregates the applicant's accounts and sends it to Algoan

Code sections have been written in JavaScript and can be implemented with NodeJS. Of course, you are free to choose your favorite language.

It uses KoaJS library, a NodeJS HTTP framework, and superagent which is a HTTP client request library.

Connection to the bank

This process is handled by an external User Interface, two events are sent in order to start and finish the process.

The following example will describe the case of a redirection to the external provider.

Example

Subscribed event: bankreader_link_required

const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const Router = require('koa-router');
const request = require('superagent');
const app = new Koa();
const router = new Router();
// This URL is just an example, you can of course create your own one
const resthookUrl = '/v1/resthook/example';
const algoanBaseUrl = 'https://api.algoan.com/v1';

/**
 * Definition of your API
 */
async function postResthook(ctx) {
  const requestBody = ctx.request.body;
  const eventName = requestBody.subscription.eventName;
  const payload = requestBody.payload;

  if (eventName === 'bankreader_link_required') {
    const banksUserId = payload.banksUserId;

    // Get the redirection URL from the banking service
    const providerRedirectUrl = await request.get(...);

    // Algoan PATCH /banks-users request body
    const reqBody = {
      redirectUrl: providerRedirectUrl,
    }

    const url = `${BASE_URL}/banks-users/${banksUserId}`;
    const headers = { Authorization: `Bearer ${serviceAccountAccessToken}` };
    await request.patch(url)
      .set(headers)
      .send(reqBody);
  }
}

app.use(bodyParser());
router.post(resthookUrl, postResthook)
app.use(router.routes());
app.listen(3000);

The link will then be transmitted to the end user who will be redirected to the external provider UI.

Bank Accounts Aggregation

When the user has accepted to share his bank accounts and has finished the banking operation, an event is triggered by Algoan (bankreader_required). It informs the external service that bank accounts and transactions can now be sent to Algoan.

The external service can also optionally warn Algoan that bank accounts have been synchronized before having send all transactions.

More details are available in the Bankreader section.

Example

Subscribed event: bankreader_required

const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const Router = require('koa-router');
const request = require('superagent');
const app = new Koa();
const router = new Router();
// This URL is just an example, you can of course create your own one
const resthookUrl = '/v1/resthook/example';
const algoanBaseUrl = 'https://api.algoan.com/v1';

/**
 * Definition of your API
 */
async function postResthook(ctx) {
  const requestBody = ctx.request.body;
  const eventName = requestBody.subscription.eventName;
  const payload = requestBody.payload;

  if (eventName === 'bankreader_required') {
    const banksUserId = payload.banksUserId;

    // Get bank accounts from the provider
    const accounts = await request.get(...);

    // Post accounts to Algoan
    const url = `${BASE_URL}/banks-users/${banksUserId}`;
    const headers = { Authorization: `Bearer ${serviceAccountAccessToken}` };

    const algoanAccounts = await request.post(`${url}/accounts`)
      .set(headers)
      .send(accounts);

    // (OPT) Inform Algoan that bank accounts have been synchronized
    const reqBody = {
      status: 'ACCOUNTS_SYNCHRONIZED',
    }

    await request.patch(url)
      .set(headers)
      .send(reqBody);

    // Post transactions to Algoan
    for (const account of algoanAccounts) {
      await request.post(`${url}/accounts/${algoanAccounts.id}/transactions`)
        .set(headers)
        .send(accounts);
    }

    // Inform Algoan that bank accounts and transactions have been synchronized
    await request.patch(url)
      .set(headers)
      .send({
        status: 'FINISHED',
      });
  }
}

app.use(bodyParser());
router.post(resthookUrl, postResthook)
app.use(router.routes());
app.listen(3000);
← Folder ServiceScore Service →
  • Aggregation
    • Connection to the bank
    • Bank Accounts Aggregation
Products
About
Developers
Contact
Privacy policy
©Algoan 2021