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

pakpay-js

v1.1.1

Published

JazzCash & Easypaisa payment SDK for Node.js — hosted checkout, verify callback, status inquiry (Pakistan)

Downloads

113

Readme

pakpay-js

npm version JazzCash Easypaisa Node License

pakpay-js is a Node.js SDK for JazzCash and Easypaisa online payments in Pakistan. It handles hosted checkout, callback verification, and status inquiry with a small API and zero runtime dependencies.

Unofficial — not affiliated with JazzCash or Easypaisa. Always test in sandbox before going live.


What this package does

| Feature | Description | |---------|-------------| | Hosted checkout | Builds a signed form; you redirect the customer to JazzCash or Easypaisa | | Verify callback | Validates the gateway POST on your return URL before marking an order paid | | Status inquiry | Checks payment status from the gateway (reconciliation / cron jobs) | | txnDateTime | Returns a timestamp you must store for JazzCash getStatus() |


Requirements

  • Node.js 18+ (uses native fetch)
  • Server-side only — never put merchant passwords or hash keys in frontend code
  • A merchant account with JazzCash and/or Easypaisa

Installation

npm install pakpay-js

Optional — Express middleware wrapper:

npm install pakpay-js express
# or: npm install pakpay-js @pakpay-js/express express

Quick usage (3 steps)

Step 1 — Create the client

JazzCash:

import { PakPay } from "pakpay-js";

const payment = new PakPay({
  provider: "jazzcash",
  merchantId: process.env.JAZZCASH_MERCHANT_ID,
  password: process.env.JAZZCASH_PASSWORD,
  integritySalt: process.env.JAZZCASH_INTEGRITY_SALT,
  sandbox: true, // false in production
});

Easypaisa:

const payment = new PakPay({
  provider: "easypaisa",
  storeId: process.env.EASYPAISA_STORE_ID,
  hashKey: process.env.EASYPAISA_HASH_KEY,
  sandbox: true,
  username: process.env.EASYPAISA_USERNAME, // required for getStatus()
  password: process.env.EASYPAISA_PASSWORD,
});

Step 2 — Start a payment

import { renderPaymentForm } from "pakpay-js";

const session = payment.createPayment({
  amount: 1000,        // PKR
  orderId: "ORDER-123",
  returnUrl: "https://yoursite.com/payments/callback",
  customerEmail: "[email protected]",
  customerPhone: "03001234567",
});

if (!session.success) {
  throw new Error(session.error);
}

// Save in your database (required for JazzCash getStatus)
await saveOrder({
  orderId: session.data.orderId,
  txnDateTime: session.data.txnDateTime,
  status: "pending",
});

// Redirect customer to the gateway
res.send(renderPaymentForm(session.data.redirectUrl, session.data.formFields));

Step 3 — Handle the callback

import express from "express";
import { createCallbackHandler } from "pakpay-js";

app.post(
  "/payments/callback",
  express.urlencoded({ extended: false }),
  createCallbackHandler(payment, {
    onPaid: async (data) => {
      // Signature is valid AND payment succeeded
      await markOrderPaid(data.orderId, data.amount);
    },
    onFailed: async (data) => {
      await markOrderFailed(data.orderId);
    },
  }),
);

Optional — reconcile stuck orders:

const status = await payment.getStatus({
  orderId: "ORDER-123",
  transactionDate: savedTxnDateTime, // from session.data.txnDateTime
});

if (status.success && status.data.status === "paid") {
  await markOrderPaid("ORDER-123");
}

API summary

| Method | Type | Purpose | |--------|------|---------| | createPayment(input) | Sync | Build signed checkout form | | verifyPayment(body) | Sync | Verify gateway callback | | getStatus(input) | Async | Query payment status | | createCallbackHandler(payment, options) | — | Express-style callback middleware | | renderPaymentForm(url, fields) | — | Auto-submit HTML redirect page |

Response format:

{ success: true, data: { ... } }
{ success: false, error: "message", code?: "INVALID_SIGNATURE" }

Environment variables

Copy .env.example to .env:

JAZZCASH_MERCHANT_ID=
JAZZCASH_PASSWORD=
JAZZCASH_INTEGRITY_SALT=

EASYPAISA_STORE_ID=
EASYPAISA_HASH_KEY=
EASYPAISA_USERNAME=
EASYPAISA_PASSWORD=

Sandbox testing

cp .env.example .env
# fill credentials, then:
npm run test:e2e

Full walkthrough: docs/SANDBOX-E2E.md


Documentation

| Document | Contents | |----------|----------| | API Reference | Types and parameters | | Behaviour & flows | How hashing and callbacks work | | JazzCash setup | Sandbox credentials | | Easypaisa setup | Sandbox credentials | | Publish to npm | Release guide | | Market readiness | Pre-publish checklist |


Example app

cd examples/express-callback
npm install
node server.mjs

Roadmap

  • v2 — PayFast, Safepay
  • v3 — Refunds, webhooks, subscriptions

License

MIT