npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

transaction-email-parser

v0.1.1

Published

used to parse transaction information from EMail messages.

Downloads

6

Readme

transaction-email-parser

Parse transaction mail information into json object, craft your account statement from history of emails. Use together with gmail API, have build-in gmail library for trying out and taking a quick look at the output

Installation

npm install transaction-email-parser

Prerequisites

Requires google credentials, link. Put credentials.json file to ./credentials/credentails.json

API

import MailParser from 'transaction-email-parser'

const mailParser = MailParser()
// or set custom token/credential path
const mailParser = MailParser({{TOKEN_PATH:'/custom/path/token.json', CREDENTIALS_PATH:'/custom/path/credentials.json}})

const params = { q: `k plus` }
const ids = await mailParser.listMailIds(params)
const transactions = []
for (const [i, id] of ids.entries()) {
	if (i>10) break
	const mail = await mailParser.readMail(id)
	try {
		transactions.push(mailParser.mailToTransaction(mail))
	} catch(e) {
		console.log(e.message)
	}
}

const csvText = mailParser.toCSV(transactions)
// or csv with selected headers
// const csvText = mailParser.toCSV(transactions,['provider','account','date'])
console.log(csvText)
// Example: mail 

// Dear Customer of mobile number 08-XXXX-1234
// Subject: Result of PromptPay Funds Transfer (Success)

// With reference to your request for funds transfer via K PLUS Service as follows:

//         Transaction Date: 11/07/2023  11:22:33
//         Transaction Number: 111111111111ABA22222
//         From Account: xxx-x-x4321-x
//         To PromptPay ID: xxx-xxx-1234
//         Received Name: MR. AAA BBBBB
//         Amount (THB): 3.00
//         Fee (THB): 0.00
//         Available Balance (THB): 2,333.00

// output: mailToTransaction(mail)
[
  {
    type: 'withdrawal',
    provider: 'Kasikorn',
    opposing_provider: 'Promptpay',
    account: 'xxx-x-x4321-x',
    opposing_account: 'xxx-xxx-1234',
    opposing_account_name: 'MR. AAA BBBBB',
    amount: -3,
    fee: -0,
    available_balance: 2333,
    transaction_id: '111111111111ABA22222',
    date: 2023-07-11T11:22:33.000Z,
    url: 'https://mail.google.com/mail/#inbox/555555abc55de555',
    id: '<22222EFG2222.ABC333333333@something-something>'
  },
]

For more example, take a look at ./test/example.js, gmail.test.js. Then try npm run example, npm run test

NOTE: id can be use to search on gmail webpage with rfc822msgid:{id}

Support Provider

We only support Thai Banks right now, if you want a new providers to be add, sent me an email sample or open a PR to add them

  • AIS
  • Kasikorn
  • KKP: Kiatnakin Phatra Bank
  • KTC: Krungthai Card
  • SCB: Siam Commercial Bank