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

@openpesa/pesa-js

v0.0.11

Published

MPesa SDK for Nodejs

Downloads

44

Readme

Pesa SDK for Nodejs using M-Pesa Open API

npm (scoped) Build Status documentation NPM

The Pesa SDK for Node.js makes it easy for developers to access OpenAPI in their Javascript code, and build robust applications and software using services like Customer 2 Bussiness, Query, etc.

Documentation

Take a look at the API docs here.

Getting Started

  1. Sign up for OpenAPI Portal – Before you begin, you need to sign up for an account and retrieve your credentials.

  2. Minimum requirements – To run the SDK, your system will need to meet the minimum requirements, including having Node >= 10.1.

  3. Install the SDK – Using NPM is the recommended way to install the Pesa SDK for JS. The SDK is available via [NPM] under the openpesa/pesa-js package. You can run the following in the base directory of your project to add the SDK as a dependency:

    npm install openpesa/pesa-js

    Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means.

  4. Using the SDK – The best way to become familiar with how to use the SDK is to read the User Guide.

Usage

Quick Examples

import { Pesa } from '@openpesa/pesa-js';

// Populate the credentials
const api_key = 'your_api_key';
const public_key = 'the_public_key';

// Intiate with credentials
let pesa = new Pesa({ api_key, public_key });

// Setup the transaction
let data = {
    input_Amount: 10000,
    // ..
};

// Execute the transaction
pesa.c2b(data)
    .then((data) => {
        // Print results
        console.log(data);
    })
    .catch((e) => {
        console.log('err: ' + e);
    });

Testing

npm test

Opening Issues

If you have a feature request or you encounter a bug, please file an issue on our issue tracker on GitHub.

Road Map

  1. Validate data input using Regex before the API call.
  2. If fields are not provided then generate a random string for "input_ThirdPartyConversationID" and "input_TransactionReference"
  3. Allow optional input for not required fields in a request.
  4. Check and Throw an error when used outside of Node.js due to security reasons, Advice on use outside Node.js.
  5. Validate Secret Keys length and format.
  6. Allow user use custom sessionID on any/each transaction. (Portal allow for seesion with several hours of validity)
  7. Add and improve documentation and examples(example will include expressjs app)

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.