Skip to content

Testausserveri/testausbanking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testausbanking

Sync bank account transactions to MongoDB via the Enable Banking API.

Use case

Built for Testausserveri to display our association's bank account activity in real-time in the members' area:

Setup

  1. Install dependencies:

    npm install
  2. Create a config.json with your Enable Banking credentials:

    {
      "keyPath": "your-app-id.pem",
      "applicationId": "your-app-id",
      "redirectUrl": "https://your-redirect-url/auth_redirect",
      "psuIpAddress": "10.10.10.10",
      "psuUserAgent": "Some useful name",
      "mongoUri": "mongodb://localhost:27017",
      "mongoDbName": "testausbanking"
    }
  3. Place your Enable Banking private key (.pem file) in the project root.

Usage

Authenticate with a bank

Connect a bank account first:

npm run auth

This will:

  1. Let you choose a bank
  2. Open an authorization URL in your browser
  3. After authorizing, paste the redirect URL back
  4. Select which account to use

Fetch transactions

Once authenticated, fetch transactions:

npm start 

This will:

  1. Fetch account balance
  2. Fetch all transactions from the past year (with pagination)
  3. Upsert to MongoDB

Options

-v, --verbose  Enable verbose output
--auth         Run authentication flow
-h, --help     Display help

MongoDB

Alternatively you can set config parameters mongoUri and mongoDbName using environment variables:

  • MONGODB_URI
  • MONGODB_DB

Collections used:

  • bank_balance - Account balance snapshots
  • bank_transactions - Transaction history (upserted by entry_reference)

About

Sync bank account transactions to MongoDB via the Enable Banking API

Topics

Resources

Stars

Watchers

Forks