JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 140
  • Score
    100M100P100Q76594F
  • License MIT

A library to parse transaction sms text

Package Exports

  • transaction-sms-parser
  • transaction-sms-parser/build/main/index.js
  • transaction-sms-parser/build/module/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (transaction-sms-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Transaction SMS Parser

A library to parse transaction sms text to extract relevant information from it. A naive implementation using mostly regular expressions.

How to use

The main method to use be used is:

getTransactionInfo(message: string): ITransactionInfo

It takes sms text as input and will give an object of ITransactionInfo type

interface ITransactionInfo {
  account: IAccountInfo;
  transactionAmount: string | null;
  transactionType: 'debit' | 'credit' | null;
  balance: IBalance | null;
}

interface IBalance {
  available: string | null;
  outstanding: string | null;
}

interface IAccountInfo {
  type: IAccountType | null;
  number: string | null;
  name: string | null;
}

enum IAccountType {
  CARD = 'CARD',
  WALLET = 'WALLET',
  ACCOUNT = 'ACCOUNT',
}

Example

import { getTransactionInfo } from 'transaction-sms-parser';

const sms =
  'INR 2000 debited from A/c no. XX3423 on 05-02-19 07:27:11 IST at ECS PAY. Avl Bal- INR 2343.23.';

const transactionInfo = getTransactionInfo(sms);
//output
{
    account: {
        type: 'ACCOUNT',
        number: '3423',
        name: null,
    },
    transactionAmount: '2000.00',
    transactionType: 'debit',
    balance: { available: '2343.23', outstanding: null },
}

API Documentation generated by typedoc is hosted on gh-pages

Testing

How to unit test ?

Tested with the SMS text from following banks/cards/wallets:

Banks:

  • Axis
  • ICICI
  • Kotak
  • HDFC
  • Standard Charted
  • IDFC
  • Niyo global

Credit Cards:

  • HSBC
  • Citi Bank
  • Sodexo
  • ICICI
  • Uni Card
  • Indusind Bank
  • Slice

Wallets

  • Paytm
  • Amazon pay
  • Lazypay
  • Simpl