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 🙏

© 2024 – Pkg Stats / Ryan Hefner

phonepe-kit

v1.1.1

Published

SDK for Phonepe web checkout

Downloads

49

Readme

PhonePe SDK - Easy PhonePe Payments Gateway Integration for Node.js

npm version

Overview

phonepe-kit is an easy-to-use npm package that simplifies the integration of the PhonePe Payments Gateway into your Node.js applications. With this package, you can quickly set up payment processing and generate PAY_PAGE links for seamless payment experiences.

Installation

You can install the package using npm:

npm install phonepe-kit

Usage

To get started with the PhonePe Payments Gateway integration, follow these steps:

  1. Import the phonepe-kitpackage into your Node.js application:
const PhonePe = require("phonepe-kit");
  1. Create an instance of the PhonePe class by providing your merchant key, merchant ID, secret key and host url (test or production):
const initilizePhonePe = new PhonePe(
  "MERCHANT_ID",
  "MERCHANT_USER_ID",
  "API_KEY",
  "API_KEY_INDEX",
  "HOST_URL"
);
  1. Generate the PAY_PAGE link by providing the amount and calling the generatePaymentUrl() method:
let transactionData = {
  amount: 100,
  transactionId: "ABCDEFG12345",
  callbackUrl: "https://example.com/callback-url",
  redirectUrl: "https://example.com/return-url",
  redirectMode: "GET",
  mobileNumber: "+91234567890",
  paymentInstrumentType: "PAY_PAGE",
};

initilizePhonePe.generatePaymentUrl(transactionData).then((data) => {
  //payment url will be in `data`
});

OR;

try {
  let data = await initilizePhonePe.generatePaymentUrl(transactionData);
  //payment url will be in `data`
} catch (error) {
  console.log(error);
}

Note: If transactionId is not passed it will be generated automatically.

Parameters

MERCHANT_ID: Your PhonePe Payments Gateway merchant key.
MERCHANT_USER_ID: Your PhonePe Payments Gateway merchant ID.
SECRET_SALT_KEY: Your secret key for secure communication with PhonePe.
HOST_URL: The base url to interact with payment gateway APIs.
callbackUrl: The URL to which PhonePe will send the payment response callback.

Sample Code

const PhonePe = require("phonepe-kit");

const initilizePhonePe = new PhonePe(
  "ABCDEF",
  "abcdef123",
  "12345-45679-sadfg-asdfgh",
  "1",
  "https://api-preprod.phonepe.com/apis/hermes"
);

let transactionData = {
  amount: 100,
  transactionId: "ABCDEFG12345",
  callbackUrl: "https://example.com/callback-url",
  redirectUrl: "https://example.com/return-url",
  redirectMode: "REDIRECT",
  mobileNumber: "+91234567890",
  paymentInstrumentType: "PAY_PAGE",
};

initilizePhonePe.generatePaymentUrl(transactionData).then((data) => {
  console.log(data);
});

Response

The generate() method will return a promise that, when resolved, will provide you with the PAY_PAGE link. This link can be used to redirect users to the PhonePe payment page for completing the transaction.

Support

If you encounter any issues or have questions regarding the package, please feel free to create an issue.

License

This package is open-source and available under the MIT License.