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

pesapal3

v2.0.5

Published

pesapal api version 3 node library

Downloads

1,334

Readme

pesapal3

A robust and feature-rich Node.js implementation of the PesaPal payment gateway API. This library simplifies the integration of PesaPal payment services into your Node.js applications, providing a secure and reliable payment solution.

Features

pesapal3 offers a comprehensive set of features for seamless PesaPal integration:

Reliability

  • Establishes secure connections even in the presence of proxies, load balancers, personal firewalls, and antivirus software.
  • Handles network disruptions and retries failed requests automatically.

Minimalistic Implementation

  • Abstracts away the complexities of the PesaPal API, allowing you to focus on your application logic.
  • No need to understand the internal structures and operations of the PesaPal systems.

Simple and Intuitive API

  • Clean and well-documented API for easy integration.
  • Supports both TypeScript and JavaScript.
  • Provides clear error handling and detailed response messages.

Comprehensive Functionality

  • Supports various payment scenarios: one-time payments, recurring subscriptions, and refunds.
  • Handles IPN (Instant Payment Notification) callbacks for real-time payment updates.
  • Allows customization of IPN endpoints and notification methods.
  • Retrieves transaction statuses and detailed payment information.

Installation

// with npm npm install pesapal3

// with yarn yarn add pesapal3

Usage

The following example demonstrates how to initialize pesapal3, submit an order, and handle IPN callbacks:

import { Pesapal, Iconfig, IpayDetails } from "pesapal3";

// Configure PesaPal credentials and URLs
const config: Iconfig = {
  pesapalEnvironment: "live", // or "sandbox"
  pesapalConsumerKey: "your-consumer-key",
  pesapalConsumerSecret: "your-consumer-secret",
  pesapalIpnUrl: "https://yourserverdomain/pesapal/ipn",
};

// Initialize PesaPal instance
const pesapal = new Pesapal(config);
const paymentInstance = pesapal.run();

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

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

if (ordered.success) {
  // The make payment request was successful.
  console.log(ordered.response);
} else {
  // The make payment request failed.
  console.error(ordered.error);
}

// Handle IPN callback
paymentRoutes.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) {
    return res
      .status(500)
      .send({ success: false, err: "internal server error" });
  }

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

Documentation

The complete documentation for pesapal3, including detailed API references, usage examples, and advanced features, is available on GitHub. Contributions are welcome!

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site.

License

pesapal3 is licensed under the MIT License.