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

@babuperumana/upipg

v1.0.2

Published

Drop-in UPI payment gateway and automated verification with interactive buttons support for WhatsApp bots (my-md-baileys, my-md-btns, Baileys)

Readme

@babuperumana/upipg — Drop-in UPI Payment Gateway for Node.js & WhatsApp Bots

@babuperumana/upipg is a powerful, drop-in automated UPI payment confirmation library for Node.js, tailored specifically for WhatsApp bots using my-md-baileys and my-md-btns (as well as standard Baileys / whatsapp-web.js). It uses BharatPe's merchant API with session credentials to verify payments in real-time without webhooks.


🌟 Features

  • Interactive Payment Buttons (my-md-btns Integration) — Built-in helper to automatically send clickable UPI app buttons, copy exact amount buttons, and order status buttons!
  • Direct Image Buffer Output — Generates styled PNG QR code cards directly as a Node.js Buffer.
  • Micro-Amount Collision Avoidance — Automatically assigns unique fractional increments (e.g., ₹500.00₹500.03) so multiple customers can pay simultaneously without ambiguity.
  • Non-Blocking Background Verification — Polls BharatPe transaction servers every few seconds in the background.
  • Event-Driven Architecture — Built on Node.js EventEmitter. Simply listen for success, expired, or credentials_expired events.
  • No Webhooks Needed — Works on local PCs, VPS, AWS, Heroku, or Raspberry Pi without public IP addresses, domain names, or SSL certificates.

🚀 Quick Start

1. Installation

npm install @babuperumana/upipg my-md-baileys my-md-btns

2. Basic Initialization

const { UpiPG } = require('@babuperumana/upipg');

const pg = new UpiPG({
  upiId: "yourname@yesbankltd",
  merchantName: "My Digital Store",
  merchantId: "12345678",
  apiToken: "<token from BharatPe DevTools>",
  apiCookie: "<Cookie header from BharatPe DevTools>",
  pollInterval: 5000, // 5 seconds
  timeout: 300        // 5 minutes
});

// Listen for successful payment confirmation
pg.on('success', (session) => {
  console.log(`✅ Payment confirmed! UTR: ${session.utr} | Payer: ${session.payerName}`);
});

💬 Interactive WhatsApp Bot Example (my-md-baileys + my-md-btns)

const makeWASocket, { useMultiFileAuthState } = require('my-md-baileys');
const { UpiPG, sendInteractivePaymentRequest } = require('@babuperumana/upipg');

async function startBot() {
  const { state, saveCreds } = await useMultiFileAuthState('auth_info');
  const sock = makeWASocket({ auth: state });
  sock.ev.on('creds.update', saveCreds);

  const pg = new UpiPG({
    upiId: "yourupi@bank",
    merchantName: "My Digital Store",
    merchantId: "12345678",
    apiToken: "...",
    apiCookie: "..."
  });

  // Automatically trigger next step when customer pays
  pg.on('success', async (session) => {
    const customerJid = session.metadata.jid;
    await sock.sendMessage(customerJid, {
      text: `✅ *Payment Verified!*\nOrder ID: \`${session.orderId}\`\nUTR: \`${session.utr}\`\n\n🎉 Activating your service now...`
    });
    // Trigger fulfillment here
  });

  sock.ev.on('messages.upsert', async ({ messages }) => {
    const msg = messages[0];
    if (!msg.message || msg.key.fromMe) return;

    const sender = msg.key.remoteJid;
    const text = (msg.message.conversation || '').toLowerCase();

    if (text === 'buy product') {
      // 1. Create session (assigns micro-amount like ₹500.03)
      const session = await pg.createPayment({
        amount: 500,
        metadata: { jid: sender }
      });

      // 2. Send Interactive QR Card + Buttons (Copy Amount, Open App, Check Status)
      await sendInteractivePaymentRequest(
        sock,
        sender,
        session,
        "yourupi@bank",
        "My Digital Store",
        { quoted: msg }
      );
    }
  });
}

startBot();

🛠️ Publishing Updates to NPM

npm run build
npm publish --access public

License

MIT