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-open-upi

v0.1.0

Published

Deep linking for UPI app in Android

Readme

react-native-open-upi

Deep linking for UPI payment apps in Android. This library allows you to initiate UPI payments from your React Native app by launching UPI-enabled apps installed on the user's device.

Note: This library only works on Android. iOS will return a failure status as UPI payment apps are not available on iOS.

Installation

npm install react-native-open-upi

or

yarn add react-native-open-upi

Usage

import { startPayment } from 'react-native-open-upi';

// Initiate a UPI payment
const handlePayment = async () => {
  try {
    const result = await startPayment(
      'upi://pay?pa=merchant@upi&pn=MerchantName&am=100.00&cu=INR&tn=Payment%20for%20Order',
      'ORDER_123456'
    );

    if (result.status === 'SUCCESS') {
      console.log('Payment successful!', result);
    } else {
      console.log('Payment failed or cancelled', result);
    }
  } catch (error) {
    console.error('Payment error:', error);
  }
};

API Reference

startPayment(url, requestID)

Initiates a UPI payment by opening a chooser dialog with available UPI apps.

Input Parameters

| Parameter | Type | Required | Description | | ----------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------ | | url | string | Yes | The UPI deep link URL containing payment details (e.g., upi://pay?pa=...&pn=...&am=...&cu=INR&tn=...) | | requestID | string | Yes | A unique identifier for the transaction (e.g., order ID). This will be returned in the response for tracking |

UPI URL Parameters

The url parameter should be a valid UPI deep link. Common parameters include:

| Parameter | Description | Example | | --------- | ------------------------ | -------------------- | | pa | Payee VPA (UPI ID) | merchant@upi | | pn | Payee Name | MerchantName | | am | Amount | 100.00 | | cu | Currency (usually INR) | INR | | tn | Transaction Note | Payment for Order | | tr | Transaction Reference ID | TXN123456 | | mc | Merchant Category Code | 5411 |

Output (PaymentResult)

Returns a Promise<PaymentResult> with the following structure:

| Property | Type | Description | | --------- | -------- | ----------------------------------------------------------------------------------------------------------------------- | | status | string | Payment status: SUCCESS, FAILURE, or SUBMITTED. Status is always uppercase | | message | string | Response message from the UPI app or error description | | orderID | string | The requestID that was passed to the function, useful for tracking |

Status Values

| Status | Description | | ----------- | -------------------------------------------------------------- | | SUCCESS | Payment was completed successfully | | FAILURE | Payment failed or was cancelled by user | | SUBMITTED | Payment was submitted but final status is pending confirmation |

Error Scenarios

The function will return a FAILURE status in the following cases:

  • No UPI app is installed on the device
  • User cancelled the payment or closed the app chooser
  • Activity does not exist (app is in background)
  • Request code mismatch (internal error)

Example

import React, { useState } from 'react';
import { View, Button, Text, Alert } from 'react-native';
import { startPayment, type PaymentResult } from 'react-native-open-upi';

export default function App() {
  const [result, setResult] = useState<PaymentResult | null>(null);

  const handlePayment = async () => {
    const upiUrl = 'upi://pay?pa=example@upi&pn=ExampleMerchant&am=1.00&cu=INR&tn=TestPayment';
    const orderId = `ORDER_${Date.now()}`;

    const paymentResult = await startPayment(upiUrl, orderId);
    setResult(paymentResult);

    if (paymentResult.status === 'SUCCESS') {
      Alert.alert('Success', 'Payment completed successfully!');
    } else {
      Alert.alert('Failed', paymentResult.message);
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Button title="Pay with UPI" onPress={handlePayment} />
      {result && (
        <View style={{ marginTop: 20 }}>
          <Text>Status: {result.status}</Text>
          <Text>Message: {result.message}</Text>
          <Text>Order ID: {result.orderID}</Text>
        </View>
      )}
    </View>
  );
}

Platform Support

| Platform | Supported | | -------- | --------- | | Android | Yes | | iOS | No |

On iOS, the startPayment function will return:

{
  "status": "FAILURE",
  "message": "UPI payment is only supported on Android",
  "orderID": "<your-request-id>"
}