GithubHelp home page GithubHelp logo

saurabhgupta050890 / transaction-sms-parser Goto Github PK

View Code? Open in Web Editor NEW
24.0 1.0 8.0 994 KB

Library to parse transactional SMS texts. Give structured information about transaction from the SMS notifications received when transacting from banks, cards, wallets etc.

License: MIT License

TypeScript 85.60% JavaScript 14.40%
typescript sms parser finance banking hacktoberfest transactional

transaction-sms-parser's Introduction

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;
  balance: IBalance | null;
  transaction: ITransaction;
}

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',
}

interface ITransaction {
  type: TTransactionType | null;
  amount: string | null;
  referenceNo: string | null;
  merchant: string | null;
}

type TTransactionType = "debit" | "credit" | null;

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,
    },
    balance: { available: '2343.23', outstanding: null },
    transaction: {
      type: 'debit',
      amount: '2343.23',
      referenceNo: null,
      merchant: null,
    }
}

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
  • SBM Bank
  • Federal Bank

Credit Cards:

  • HSBC
  • Citi Bank
  • Sodexo
  • ICICI
  • Uni Card
  • Indusind Bank
  • Slice
  • One card
  • HDFC
  • IDFC

Wallets

  • Paytm
  • Amazon pay
  • Lazypay
  • Simpl
  • Paytm postpaid

transaction-sms-parser's People

Contributors

dependabot[bot] avatar roastedmonk avatar saurabhgupta050890 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

transaction-sms-parser's Issues

amazon pay balance is not extracted

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Balance is not extracted from amazon pay transaction messages

Sample text: Payment of Rs 81.00 using Amazon Pay balance is successful at Amazon.in. Updated Balance: 125.00. For help/stmt: https://www.amazon.in/cstxn

Output:
{ account: { type: IAccountType.WALLET, name: 'amazon_pay', }, transactionAmount: '81.00', transactionType: 'debit', balance: '', }

Expected Output:
{ account: { type: IAccountType.WALLET, name: 'amazon_pay', }, transactionAmount: '81.00', transactionType: 'debit', balance: '125.00', }

Parser for SBI

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

Dear SBI User, your A/c X0000-debited by Rs219.0 on 28May23 transfer to Flipkart Ref No 00000000000. If not done by u, fwd this SMS to 9223008333/Call 1800111109 or 09449112211 to block UPI -SBI

Add support for this kind of sms.

Incorrect Available balance and transaction type in case the message from paytm payments bank

  • I'm submitting a ...

    • bug report
  • Summary
    Incase of paytm payments bank message
    Rs.1770.38 sent to amazonupi@apl from PPBL a/c 91XX0633. UPI Ref:303418985561. Balance:https://m.paytm.me/UpiDebBal. Query:http://m.p-y.tm/care

Response
image

Hello, Saurabh I've been looking for something like this for a while, so I truly appreciate all the work you've put into organising the codebase. Thanks a ton ❤️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.