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 🙏

© 2025 – Pkg Stats / Ryan Hefner

upi-intents

v0.1.0

Published

A framework-agnostic JS/TS library for generating UPI app-specific deep links with robust fallbacks for Android and iOS

Downloads

17

Readme

🔗 UPI Intents

CI Coverage Bundle Size TypeScript License

Framework-agnostic TypeScript library for UPI deep-linking across Android and iOS platforms with robust fallbacks and NPCI compliance.

✨ Features

  • 🎯 Universal UPI Links - Generate payment and mandate links that work across all UPI apps
  • 📱 Platform Optimized - Android Intent URLs and iOS scheme URLs with proper fallbacks
  • NPCI Compliant - Full compliance with NPCI's UPI deep-linking specification
  • 🔧 Framework Agnostic - Works with vanilla JS, React, Vue, Angular, and any web framework
  • 📊 QR Code Support - Generate QR codes for desktop/fallback scenarios
  • 🎨 UI Components - Ready-to-use button components with official app branding
  • 📦 Tree Shakeable - ESM modules with TypeScript declarations
  • 🧪 100% Tested - Comprehensive test suite with 46 passing tests

🚀 Quick Start

Installation

npm install upi-intents
# or
yarn add upi-intents
# or
bun add upi-intents

Basic Usage

import { createPaymentUri, buildAppLink, detectPlatform } from 'upi-intents';

// Create a UPI payment link
const upiUri = createPaymentUri(
  'merchant@paytm',     // Payee VPA
  'Demo Merchant',      // Payee name
  '99.50',              // Amount
  'Payment for goods'   // Transaction note
);

// Generate app-specific links
const platform = detectPlatform(); // 'android' | 'ios'
const gpayLink = buildAppLink({
  appId: 'gpay',
  upiUri,
  platform
});

// Open Google Pay
window.location.href = gpayLink.url;

📖 API Reference

Core Functions

createPaymentUri(pa, pn, am?, tn?)

Creates a standard UPI payment URI.

const uri = createPaymentUri(
  'merchant@paytm',     // pa: Payee address (required)
  'Demo Merchant',      // pn: Payee name (required)  
  '100.00',             // am: Amount (optional)
  'Payment note'        // tn: Transaction note (optional)
);
// Returns: "upi://pay?pa=merchant@paytm&pn=Demo%20Merchant&am=100.00&cu=INR&tn=Payment%20note"

createMandateUri(pa, pn, am?, tn?, tr?)

Creates a UPI mandate/subscription URI.

const uri = createMandateUri(
  'merchant@paytm',
  'Demo Merchant', 
  '50.00',
  'Monthly subscription',
  'MANDATE-123'
);

buildAppLink(options)

Generates platform-specific deep links for UPI apps.

const link = buildAppLink({
  appId: 'gpay',        // 'gpay' | 'phonepe' | 'paytm' | 'bhim' | 'amazonpay' | 'generic'
  upiUri: 'upi://pay?...',
  platform: 'android'   // 'android' | 'ios' | auto-detected
});

// Returns:
{
  url: "intent://pay?pa=...",           // Platform-specific URL
  fallbackUrl: "https://play.google...", // App store URL
  app: { id: 'gpay', label: 'Google Pay', verified: true },
  platform: 'android',
  action: 'pay'
}

detectPlatform()

Detects the current platform from user agent.

const platform = detectPlatform(); // 'android' | 'ios'

Utility Functions

generateQRCode(upiUri)

Generates QR codes for desktop fallback.

const qr = generateQRCode(upiUri);
console.log(qr.svg);     // SVG string
console.log(qr.dataUrl); // Data URL for downloads

App Registry

import { getAllApps, getApp, getVerifiedApps } from 'upi-intents';

const allApps = getAllApps();           // All registered UPI apps
const gpay = getApp('gpay');            // Specific app details
const verified = getVerifiedApps();     // Only verified apps

🏗️ Framework Integration

React Component

import React from 'react';
import { createPaymentUri, buildAppLink, detectPlatform } from 'upi-intents';

const UPIPaymentButton = ({ payeeAddress, payeeName, amount, note }) => {
  const handlePayment = (appId) => {
    const upiUri = createPaymentUri(payeeAddress, payeeName, amount, note);
    const platform = detectPlatform();
    const link = buildAppLink({ appId, upiUri, platform });
    
    window.location.href = link.url;
  };

  return (
    <div className="upi-buttons">
      <button onClick={() => handlePayment('gpay')}>
        Pay with Google Pay
      </button>
      <button onClick={() => handlePayment('phonepe')}>
        Pay with PhonePe
      </button>
    </div>
  );
};

Vue.js Integration

<template>
  <div class="upi-payment">
    <button @click="payWithApp('gpay')">Google Pay</button>
    <button @click="payWithApp('phonepe')">PhonePe</button>
  </div>
</template>

<script>
import { createPaymentUri, buildAppLink, detectPlatform } from 'upi-intents';

export default {
  methods: {
    payWithApp(appId) {
      const upiUri = createPaymentUri(
        this.payeeAddress,
        this.payeeName,
        this.amount,
        this.note
      );
      
      const link = buildAppLink({
        appId,
        upiUri,
        platform: detectPlatform()
      });
      
      window.location.href = link.url;
    }
  }
};
</script>

🎯 Supported UPI Apps

| App | Status | Android | iOS | Package/Scheme | |-----|--------|---------|-----|----------------| | Google Pay | ✅ Verified | ✅ | ✅ | com.google.android.apps.nbu.paisa.user | | PhonePe | ⚠️ Community | ✅ | ✅ | com.phonepe.app | | Paytm | ⚠️ Community | ✅ | ✅ | net.one97.paytm | | BHIM | ✅ Verified | ✅ | ✅ | in.org.npci.upiapp | | Amazon Pay | ⚠️ Community | ✅ | ✅ | in.amazon.mShop.android.shopping | | Generic UPI | ✅ Universal | ✅ | ✅ | upi:// |

📱 Platform Support

Android

  • Intent URLs with Chrome fallback handling
  • Package targeting for specific app launches
  • Play Store fallbacks for uninstalled apps
  • Generic UPI handling via system chooser

iOS

  • Custom URL schemes for direct app launching
  • App Store fallbacks for uninstalled apps
  • Universal UPI support where available
  • Graceful degradation for unsupported schemes

🔧 Development

Setup

git clone https://github.com/shambu2k/upi-intent.git
cd upi-intent
bun install

Available Scripts

bun run test          # Run test suite
bun run test:watch    # Run tests in watch mode  
bun run build         # Build for production
bun run lint          # Run ESLint
bun run typecheck     # Run TypeScript checks

Testing

bun run test --run    # Run all 55 tests

Current test coverage will be shown in the coverage badge above.

📋 Examples

Check out the examples/ directory for complete working examples:

Live Demo

Open examples/vanilla/index.html in your browser to see the library in action with:

  • Interactive payment form
  • Platform-specific app buttons
  • QR code generation
  • Real-time validation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Adding New UPI Apps

  1. Update src/data/apps.json with app details
  2. Include verification status and sources
  3. Add tests for the new app integration
  4. Update documentation

📄 License

MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • NPCI for the UPI specification
  • Chrome Intent URLs documentation
  • Community contributors for iOS scheme research
  • UPI app developers for deep-linking support

📞 Support


Made with ❤️ for the Indian payments ecosystem