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

pesapaljs-v3

v1.0.13

Published

Integrate PesaPal into your Node application v3

Downloads

55

Readme

pesapaljs-v3 (MAINTAINED)

NPM

Goal

Make it easy to integrate PesaPal into a website or mobile app.

Core Features

  • init(options) : Initialize Package. options should contain a key , a secret and debug together.

  • authenticate(): Authenticate with pesapal servers and set bearer token.

  • register_ipn_url(options): Register an IPN url, that will be used by pesapal to inform your server on any changes. options should contain a url and a ipn_notification_type.

  • get_ipn_list(): Returns the list of registered IPN's

  • submit_order(options): Initiates an order to pesapal and returns the iframe src url. options should include, id -unique system generated id, currency - if KES or other, amount,description,callback_url - to where the user will be redirected to on the UI , notification_id - unique id associated with yout IPN url, billing_address - an object with user details as such { "email_address": "[email protected]", "phone_number": None, "country_code": "", "first_name": "John", "middle_name": "", "last_name": "Doe", "line_1": "", "line_2": "", "city": "", "state": "", "postal_code": None, "zip_code": None }

  • get_transaction_status(oPTIONS): Returns the status details of a trasaction. options should include OrderTrackingId that you receives from the callback.

Usage

Install
$ npm i pesapaljs-v3
Setup

var PesaPal = require('pesapaljs-v3').init({
    key: CONSUMER_KEY,
    secret: CONSUMER_SECRET,
    debug: true // false in production!
});

When the debug option is set, pesapaljs-v3 will use the cybqa.pesapal.com* endpoints.

Authenticate with pesapal

// initiate an authentication with the package
PesaPal.authenticate();
POST an IPN url

var options = {
    url: "ngrok.something/ipn", 
    ipn_notification_type: "GET" 
};
PesaPal.register_ipn_url(options)
        .then(function(status){ /* do stuff*/ })
        .catch(function(error){ /* do stuff*/ });
GET registered IPN list

PesaPal.get_ipn_list()
        .then(function(status){ /* do stuff*/ })
        .catch(function(error){ /* do stuff*/ });
POST an order request

PesaPal.submit_order({
    "id": 231323, //generate some unique value, probably use uuid.
    "currency": "KES",
    "amount": 10,
    "description": "payment for masterclass", // transaction description
    "callback_url": "https://some.com/home", //front end url for redirect
    "notification_id": "b3699d97-1c04-45b5-8062-de69d6dad9a1", //IPN url
    "billing_address": {
        "email_address": "[email protected]",
        "phone_number": "",
        "country_code": "KE",
        "first_name": "John",
        "middle_name": "",
        "last_name": "Doe",
        "line_1": "",
        "line_2": "",
        "city": "",
        "state": "",
        "postal_code": "",
        "zip_code": ""
    }
})
        .then(function(status){ /* do stuff*/ })
        .catch(function(error){ /* do stuff*/ });


GET transaction status

PesaPal.get_transaction_status({
    OrderTrackingId:OrderTrackingId // ensure you get the spelling correct!
  })
        .then(function(status){ /* do stuff*/ })
        .catch(function(error){ /* do stuff*/ });

Contributing

  1. Fork this repo and make changes in your own fork.
  2. Commit your changes and push to your fork git push origin master
  3. Create a new pull request and submit it back to the project.

Bugs & Issues

To report bugs (or any other issues), use the issues page.