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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@togtokh.dev/happypay

v0.1.2

Published

happypay api

Readme

@togtokh.dev/happypay

Худалдаа Хөгжлийн Банк (TDB) — HappyPay QR төлбөрийн Node.js/TypeScript library.

Суулгах

npm install @togtokh.dev/happypay

Орчин

| Нэр | URL | |---|---| | STAGING | https://qrservice.tdbmlabs.mn | | PROD | https://qrservice.tdb.mn |


Хэрэглэх

1. Нэвтрэх (LOGIN)

import HAPPYPAY from "@togtokh.dev/happypay";

const auth = await HAPPYPAY.auth.LOGIN({
  host: "STAGING",          // "STAGING" | "PROD"
  username: "your_username",
  password: "your_password",
  terminalId: "91200026",
  bankCode: "TDBMNUB",      // заавал биш, default: "TDBMNUB"
});

2. QR нэхэмжлэх үүсгэх (CREATE)

const invoice = await HAPPYPAY.invoice.CREATE({
  qrType: "dynamic",          // "dynamic" | "static"
  transactionType: 1,         // 1: Purchase, 2: Transfer, 3: Payment
  amount: 1000,
  curCode: "MNT",
  additional: {
    purposeTransaction: "Захиалгын төлбөр",
    callbackUrl: "https://yourdomain.mn/callback",
  },
});

// invoice.data.qrcode   — QR raw текст
// invoice.data.qrImage  — Base64 PNG зураг
// invoice.data.invoiceNo

Deeplink үүсгэх

import HAPPYPAY, { deeplink } from "@togtokh.dev/happypay";

const link = deeplink(invoice.data.qrcode);
// tdbwalletTest://qrcode?data=...

3. Нэхэмжлэх лавлах (GET)

const info = await HAPPYPAY.invoice.GET(invoiceNo);

// info.data.status — "new" | "paid" | "failed" | "cancelled" | "expired"
// info.data.amount
// info.data.paymentId

4. Нэхэмжлэхийн жагсаалт (LIST)

const list = await HAPPYPAY.invoice.LIST({
  terminalId: "91200026",   // заавал биш
  startDate: "2025-01-01",  // заавал биш
  endDate: "2025-12-31",    // заавал биш
});

5. Нэхэмжлэх цуцлах (CANCEL)

Төлөгдөөгүй нэхэмжлэхийг цуцлахад ашиглана.

const cancelled = await HAPPYPAY.invoice.CANCEL(invoiceNo);
// cancelled.data.status === "cancelled"

6. Буцаалтын гүйлгээ (REVERSE)

Төлөгдсөн нэхэмжлэхийн дүнг буцаахад ашиглана.

const reversed = await HAPPYPAY.payment.REVERSE({
  invoiceNo: 100000134,
  amount: 1000,
  terminalId: "91200026",  // заавал биш, default: config.terminalId
});

7. Callback (Webhook)

TDB-аас төлбөр амжилттай болсон үед таны callbackUrl-руу POST хүсэлт илгээнэ:

// POST {callbackUrl}
// Body:
{
  invoiceNo: 100000110,
  status: "paid",       // "paid" | "failed" | "cancelled"
  paymentId: 798555677
}

Бүрэн жишээ

import HAPPYPAY, { deeplink } from "@togtokh.dev/happypay";

async function main() {
  await HAPPYPAY.auth.LOGIN({
    host: "STAGING",
    username: "your_username",
    password: "your_password",
    terminalId: "91200026",
  });

  const invoice = await HAPPYPAY.invoice.CREATE({
    qrType: "dynamic",
    transactionType: 1,
    amount: 5000,
    curCode: "MNT",
    additional: {
      purposeTransaction: "Захиалга #1234",
      callbackUrl: "https://yourdomain.mn/webhook",
    },
  });

  if (invoice.success && invoice.data) {
    console.log("QR:", invoice.data.qrcode);
    console.log("Deeplink:", deeplink(invoice.data.qrcode));

    // Хэрэглэгч төлсний дараа төлөв шалгах
    const status = await HAPPYPAY.invoice.GET(invoice.data.invoiceNo!);
    console.log("Төлөв:", status.data?.status);
  }
}

main();

Холбоо барих