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

react-native-android-upi

v1.0.6

Published

Easy UPI Payment Integration for React Native - Support for Google Pay, PhonePe, Paytm and other UPI apps

Readme

React Native Android UPI

A simple React Native UPI payment integration for Android.


About

This package simplifies UPI payment integration in React Native Android apps, supporting all major payment apps (Google Pay, PhonePe, Paytm) and following the latest NPCI guidelines. Built to provide a seamless payment experience with minimal setup.

Tutorial

📺 Watch the implementation tutorial: React Native UPI Payment Integration

Setup

  • Copy this folder from node_modules/react-native-android-upi/android/src/main/java/com/rnupi/ to your project:

    • rnupi copy this folder
  • In your current project go to below path in android:

src/main/java/com
  • Paste the folder you copied

  • open MainApplication and Add below to MainApplication.kt:

import com.rnupi.RNAndroidUPIPackage

// Inside getPackages()
add(RNAndroidUPIPackage())
  • Add to android/app/src/main/AndroidManifest.xml (below </application> tag):
<queries>
    <package android:name="com.google.android.apps.nbu.paisa.user" />
    <package android:name="com.phonepe.app" />
    <package android:name="net.one97.paytm" />
    <package android:name="in.org.npci.upiapp" />
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="upi" />
    </intent>
</queries>
  • After making these changes, clean and rebuild your project:
cd android
./gradlew clean

This ensures the app builds freshly with the new changes.

Basic Usage

import UPIPayment from 'react-native-android-upi';


const paymentData = {
    vpa: "merchant.vpa@upi",
    name: "Merchant Name",
    note: "Payment Note",
    amount: "1.00",
    transactionRef: "TXN_" + Date.now()
};

// Make payment using Google Pay
const makeGPayPayment = async () => {
    try {
        const response = await UPIPayment.initiateGPayPayment(paymentData);
        console.log('Success:', response);
    } catch (error) {
        console.error('Error:', error);
    }
};

Available Methods

  • Check App Installation:
const isInstalled = await UPIPayment.isAppInstalled("com.google.android.apps.nbu.paisa.user");
  • Google Pay Payment:
const response = await UPIPayment.initiateGPayPayment(paymentData);
  • PhonePe Payment:
const response = await UPIPayment.initiatePhonePePayment(paymentData);
  • Paytm Payment:
const response = await UPIPayment.initiatePaytmPayment(paymentData);
  • Generic UPI Payment:
const response = await UPIPayment.initiateUPIPayment(paymentData);

Payment Data Structure

{
    vpa: string,           // Merchant UPI ID
    name: string,          // Merchant Name
    amount: string,        // Amount (e.g., "1.00")
    note: string,          // Payment Note
    transactionRef: string // Unique Reference
}

Response Structure

{
    status: string,        // "SUCCESS" or "FAILURE"
    transactionId: string, // UPI Transaction ID
    responseCode: string,  // Response Code
    approvalRefNo: string  // Reference Number
}

App Package Names

  • Google Pay: com.google.android.apps.nbu.paisa.user
  • PhonePe: com.phonepe.app
  • Paytm: net.one97.paytm

Complete Example

import React, { useState } from 'react';
import { View, Button, Alert } from 'react-native';
import UPIPayment from 'react-native-android-upi';

const PaymentScreen = () => {
    const [loading, setLoading] = useState(false);

    const makePayment = async () => {
        try {
            setLoading(true);
            
            const paymentData = {
                vpa: "merchant.vpa@upi",
                name: "Merchant Name",
                amount: "1.00",
                note: "Test Payment",
                transactionRef: "TXN_" + Date.now()
            };

            const response = await UPIPayment.initiateGPayPayment(paymentData);
            Alert.alert('Success', 'Payment completed!');
            
        } catch (error) {
            Alert.alert('Error', error.message);
        } finally {
            setLoading(false);
        }
    };

    return (
        <View style={{padding: 20}}>
            <Button 
                title="Pay ₹1" 
                onPress={makePayment}
                disabled={loading}
            />
        </View>
    );
};

export default PaymentScreen;

Error Handling

  • Common Errors:
    • APP_NOT_FOUND
    • PAYMENT_CANCELLED
    • PAYMENT_FAILED
    • INVALID_DATA

Supported Apps

  • Google Pay
  • PhonePe
  • Paytm
  • Other UPI apps (via generic payment)

Notes

  • Android only
  • Requires Android SDK 21+
  • Test with small amounts first
  • Handle all possible errors
  • Check app installation before payment

License

MIT