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

universal-payment-gateway

v0.2.3

Published

A cross-platform React & React Native SDK for native payments including UPI, Stripe, and Razorpay.

Readme

@sammeddoshi03/universal-payment-gateway

A powerful, cross-platform React and React Native SDK for seamless payment integrations. Instantly accept UPI Intents, Credit Cards (Stripe), and Netbanking (Razorpay) using a single, incredibly clean unified React Hook.

🚀 Features

  • True Universal SDK: Write your checkout code once. Route traffic based on the user's choice.
  • Zero Bundle Bloat: Stripe and Razorpay SDKs are loaded via Dynamic Imports. If you only use UPI, your app size stays incredibly small.
  • Native Android UPI Intents: Opens GPay, PhonePe, and Paytm instantly. Zero Commission.
  • Desktop Web Fallback: Displays dynamic, scannable QR Codes seamlessly when users open UPI on a Desktop browser!
  • Expo & Bare RN Compatible: Powered by the modern JSI architecture.

📦 Requirements & Installation

npm install universal-payment-gateway

Gateway Dependencies (Optional but required if routing)

If you configure the hook to route to Stripe or Razorpay, you must install their respective official SDKs. Because of our dynamic imports, you do not have to install them if you only plan to use UPI.

npm install @stripe/stripe-react-native react-native-razorpay

Expo Native Linking (Required for Mobile)

Add the plugin to your app.json or app.config.js to automatically inject the correct intent schemas into your mobile manifests.

{
  "expo": {
    "plugins": ["universal-payment-gateway"]
  }
}

Prebuild to apply the native changes:

npx expo prebuild

🛠️ The Global Provider

Before invoking the payment logic, wrap your application in the UniversalPaymentProvider to securely inject your Gateway API keys.

// App.tsx
import { UniversalPaymentProvider } from 'universal-payment-gateway';

export default function App() {
  return (
    <UniversalPaymentProvider config={{
      defaultGateway: 'RAZORPAY',
      stripePublishableKey: 'pk_live_your_stripe_key',
      razorpayKeyId: 'rzp_live_your_razorpay_key'
    }}>
      <CheckoutScreen />
    </UniversalPaymentProvider>
  );
}

💻 Usage & Examples

Our SDK simplifies multi-gateway routing into a single hook: useUniversalPayment({ method }).

Example 1: Direct UPI Intent (Zero Commission)

Using the UPI method bypasses Stripe/Razorpay entirely and directly invokes the Google Pay / PhonePe native apps installed on the device.

import { useUniversalPayment, UpiWebInterface } from 'universal-payment-gateway';
import { useState } from 'react';

export function UPIButton() {
  const { checkout, globalStatus } = useUniversalPayment();
  const [webQrUrl, setWebQrUrl] = useState<string | null>(null);

  const handlePay = async () => {
    try {
      const response = await checkout({
        method: 'UPI',
        pa: 'merchant@upi',
        pn: 'Awesome Store',
        am: '100.00',
        tr: 'order_12345678',
      });
      console.log('UPI Transaction Successful:', response.nativeData);
      
      // 🌐 WEB FALLBACK HANDLING
      // If the user clicked UPI on a Desktop Browser, we get the 'AWAITING_WEB_SCAN' status!
      if (response.status === 'AWAITING_WEB_SCAN') {
         setWebQrUrl(response.nativeData);
      }
    } catch (err) {
      console.error('Payment failed / cancelled', err);
    }
  };

  return (
    <>
      <Button title="Pay via native UPI📱" onPress={handlePay} />
      {webQrUrl && <UpiWebInterface paymentUrl={webQrUrl} size={250} />}
    </>
  );
}

Example 2: Stripe Credit Cards

import { useUniversalPayment } from 'universal-payment-gateway';

export function CreditCardButton() {
  const { checkout } = useUniversalPayment();

  const handlePay = async () => {
    // Triggers '@stripe/stripe-react-native' Payment Sheet dynamically
    const response = await checkout({
      method: 'CARD',
      gatewayOverride: 'STRIPE',
      amount: '100.00',
      currency: 'INR' // or 'USD'
    });
  };

  return <Button title="Pay via Credit Card 💳" onPress={handlePay} />;
}

Example 3: Razorpay Netbanking & Wallets

import { useUniversalPayment } from 'universal-payment-gateway';

export function NetbankingButton() {
  const { checkout } = useUniversalPayment();

  const handlePay = async () => {
    // Triggers 'react-native-razorpay' drop-in UI dynamically
    const response = await checkout({
      method: 'NETBANKING',
      gatewayOverride: 'RAZORPAY',
      amount: '100.00'
    });
  };

  return <Button title="Pay via Netbanking / Wallet 🏦" onPress={handlePay} />;
}

⚠️ Security Warning

Never mark an order as "paid" exclusively based on the client-side SUCCESS response. Modified Android APKs can intercept intent results. Pinging your secure backend server for Server-to-Server (S2S) validation is explicitly required before fulfilling an order.


⚖️ License

MIT License. Created by Sammed Doshi.