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

pesapal3-sdk

v0.0.11

Published

pesapal api version 3 node library

Downloads

191

Readme

pesapal3-sdk

A Node.js library for integrating PesaPal payment services into your applications. It provides a comprehensive, type-safe interface for payment-related operations

PesaPal API Integration

This project connects to the PesaPal API to handle payments. Here’s what it does:

  • Get Tokens: Retrieves tokens needed to make secure API requests.
  • Handle Payments: Listens for payment notifications from PesaPal (IPN).

Key Dependencies

The project relies on several important packages:

  • For Production:
    • axios: Used to send HTTP requests.
    • axios-mock-adapter: Helps in testing by mocking requests.
    • tracer: Assists with debugging.
  • For Development:
    • ESLint plugins for maintaining code quality.
    • TypeScript for adding type safety.
    • Testing tools like supertest and vitest.

Logging

The application logs important information using log4js. You can find these logs in the pesapal.log file, which helps in debugging issues.

IPN Notifications

Make sure to set up your IPN URL in your PesaPal account settings so that the application can receive payment notifications.

Installation

with npm

npm install pesapal3-sdk

with yarn

yarn add pesapal3-sdk

Usage

import { initialisePesapal, Iconfig, IpayDetails } from "pesapal3-sdk";

// this credentials are from your PesaPal account, login or register here: https://pesapal.com/
const config: Iconfig = {
  PESAPAL_ENVIRONMENT: "live", // or "sandbox"
  PESAPAL_CONSUMER_KEY: "your-consumer-key",
  PESAPAL_CONSUMER_SECRET: "your-consumer-secret",
  PESAPAL_IPN_URL: "https://yourserverdomain/pesapal/ipn",
};

const paymentInstance = initialisePesapal(config);

const details: IpayDetails = {
  amount: 1000,
  currency: "USD",
  description: "This is a test payment",
  // ...other_details
};

const ordered = await paymentInstance.submitOrder(
  details,
  "ProductId",
  "description"
);

if (ordered.success) {
  console.log(ordered.response);
} else {
  console.error(ordered.error);
}

// Handle IPN callback, this is the endpoint that PesaPal will call when a payment is completed and must be registered in your PesaPal account
// for express.js
app.get("/ipn", async (req, res) => {
  const currntUrl = new URL(req.url);
  const searchParams = currntUrl.searchParams;

  const orderTrackingId = searchParams.get("OrderTrackingId") as string;
  const orderNotificationType = searchParams.get(
    "OrderNotificationType"
  ) as string;
  const orderMerchantReference = searchParams.get(
    "OrderMerchantReference"
  ) as string;

  if (!paymentInstance) {
    // choose how to handle this error
    // may be just return a response
    return res
      .status(500)
      .send({ success: false, err: "internal server error or something else" });
  }

  const response = await paymentInstance.getTransactionStatus(orderTrackingId);
  return response;
});

Documentation

Complete documentation is available on PESAPAL3.

License

pesapal3-sdk is licensed under the MIT License.