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

react-js-phonepe-pg

v1.1.1

Published

React PhonePe Payment Gateway Component

Readme

react-js-phonepe-pg

A simple and ready-to-use React component to integrate PhonePe Payment Gateway in your React web application.
This package helps developers quickly trigger PhonePe checkout flow without writing complex logic.

📌 If environment is not provided, it will automatically use sandbox mode.


🚀 Installation

npm install react-js-phonepe-pg

or

yarn add react-js-phonepe-pg
import { useState } from 'react';
import PhonepePg from 'react-js-phonepe-pg';

function Payment() {
  const [initiate, setInitiate] = useState(false);

  const client_id = "your_client_id"; 
  const client_secret = "your_secret_id"; 

  const requestBody = JSON.stringify({
    "amount": 10000,
    "expireAfter": 1200,
    "metaInfo": {
      "udf1": "info-1"
    },
    "paymentFlow": {
      "type": "PG_CHECKOUT",
      "message": "Payment message",
      "merchantUrls": {
        "redirectUrl": ""
      }
    },
    "merchantOrderId": "test-order-1"
  });

  const success = (res) => console.log("Payment Success:", res);
  const error = (err) => console.log("Payment Failed:", err);

  return (
    <div>
      {initiate && (
        <PhonepePg
          bodyPayload={requestBody}
          environment="sandbox"
          client_id={client_id}
          client_secret={client_secret}
          onSuccess={success}
          onError={error}
        />
      )}

      <button onClick={() => setInitiate(true)}>Pay Now</button>
    </div>
  );
}

export default Payment;

🧩 Component Props | Prop Name | Type | Required | Default | Description | | --------------- | ---------- | -------- | ------------- | --------------------------------------------------------------------------------------------------------------------------- | | bodyPayload | string | ✔ Yes | — | Payment request body in JSON string format. Must be created using JSON.stringify({...}). | | client_id | string | ✔ Yes | — | Your PhonePe Merchant client_id used to authenticate API requests. | | client_secret | string | ✔ Yes | — | Your PhonePe Merchant client_secret used for secure checksum generation. | | environment | string | ❌ No | sandbox | The environment where the payment should run. Options: "sandbox" for testing or "production" for live transactions. | | onSuccess | function | ❌ No | console.log | Callback function triggered when payment succeeds. Receives payment response as an argument. | | onError | function | ❌ No | console.log | Callback triggered when payment fails or is cancelled. Receives error object as an argument. |

📝 Notes | Behavior | Meaning | | ----------------------------------- | --------------------------------------------------------------------------------- | | environment defaults to sandbox | If you don’t pass environment prop, payment will use Sandbox mode automatically | | Payment auto-starts on render | When <PhonepePg /> component appears in DOM, phonepe flow begins | | Callbacks are optional | If not provided, results will be logged using console.log |

💡 Tips

  • Always wrap <PhonepePg /> inside a button condition like initiate === true
  • Always convert payload using JSON.stringify
  • After success, update your backend or redirect the user
  • Callbacks are optional but recommended

🔍 Preview (coming soon)

Live demo link will be added here soon.

🤝 Support & Contributions

If you face any bugs or want to contribute:

We welcome pull requests that improve developer experience.