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

neppayments

v2.0.6

Published

A simple and easy-to-use package for integrating Nepali payment gateways (Khalti and eSewa) into your applications

Readme

NepPayments: Unified Khalti & eSewa Payment Integration

A simple Node.js package to integrate both Khalti and eSewa payment gateways with a unified, developer-friendly API. This package is designed for backend use, where your server generates the payment form or URL and serves it to the client.

Installation

npm install neppayments

Usage

1. Initialize the Payment Gateway

import { NepPayments } from 'neppayments';

const payments = new NepPayments({
  khalti: {
    secretKey: 'YOUR_KHALTI_SECRET_KEY', // Get from Khalti Dashboard
    environment: 'sandbox' // or 'production'
  },
  esewa: {
    productCode: 'EPAYTEST',
    secretKey: '8gBm/:&EnhH.1/q', // Sandbox secret key
    environment: 'sandbox', // or 'production'
    successUrl: 'https://yourdomain.com/payment-success',
    failureUrl: 'https://yourdomain.com/payment-failure'
  }
});

2. Create a Payment

Khalti

const khaltiPayment = await payments.khalti.createPayment({
  amount: 1000, // in paisa (Rs. 10)
  purchase_order_id: 'ORDER_123',
  purchase_order_name: 'Test Product',
  return_url: 'https://yourdomain.com/payment-success',
  website_url: 'https://yourdomain.com',
  customer_info: {
    name: 'Test User',
    email: '[email protected]',
    phone: '9800000000'
  }
});

// Return the payment URL to the client
console.log(khaltiPayment.payment_url);

eSewa

const esewaPayment = await payments.esewa.createPayment({
  amount: 10, // in rupees
  tax_amount: 0,
  total_amount: 10,
  transaction_uuid: 'ORDER_' + Date.now(),
  product_code: 'EPAYTEST',
  product_service_charge: 0,
  product_delivery_charge: 0,
  success_url: 'https://yourdomain.com/payment-success',
  failure_url: 'https://yourdomain.com/payment-failure',
  signed_field_names: 'total_amount,transaction_uuid,product_code'
});

// The package returns the HTML content for the eSewa payment form
console.log(esewaPayment.form_html);

3. Serve the Payment Form to the Client

  • Khalti: Redirect the client to the payment_url returned by the package
  • eSewa: Serve the HTML content (esewaPayment.form_html) to the client

eSewa Test Credentials

  • eSewa ID: 9806800001 (or 9806800002, 9806800003, 9806800004, 9806800005)
  • Password: Nepal@123
  • Token: 123456

4. Verify the Payment

// Khalti
const verification = await payments.khalti.verifyPayment({ 
  pidx: 'YOUR_KHALTI_PIDX' 
});

// eSewa
const verification = await payments.esewa.verifyPayment({
  product_code: 'EPAYTEST',
  transaction_uuid: 'YOUR_TRANSACTION_UUID',
  total_amount: 10
});

5. Handling Payment Success [KHALTI]

After the user completes the payment, the success response is obtained in the return URL specified during payment initiation. The callback URL should support the GET method, and the user will be redirected to the return URL with the following parameters:

  • pidx: The initial payment identifier
  • status: Status of the transaction
    • Completed: Transaction is successful
    • Pending: Transaction is in a pending state; request the lookup API
    • User canceled: Transaction has been canceled by the user
  • transaction_id: The transaction identifier at Khalti
  • tidx: Same value as the transaction ID
  • amount: Amount paid in paisa
  • mobile: Payer KHALTI ID
  • purchase_order_id: The initial purchase_order_id provided during payment initiation
  • purchase_order_name: The initial purchase_order_name provided during payment initiation
  • total_amount: Same value as the amount

Developer Experience

  • The API for both Khalti and eSewa is designed to be as similar as possible
  • For eSewa, your backend serves the HTML form to the client
  • Payment verification is identical for both gateways

Error Handling

  • All methods throw errors with clear messages if something goes wrong

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

MIT