Socket
Socket
Sign inDemoInstall

pesa-lib

Package Overview
Dependencies
58
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pesa-lib

Node.js package for Mpesa.


Version published
Weekly downloads
1
Maintainers
1
Install size
11.5 MB
Created
Weekly downloads
 

Readme

Source

Pesa Lib

NPM

An Node.js package for Mpesa.

Before using this package, create an account on the Safaricom Developer Portal to receive a Consumer Key and Consumer Secret.
Business short code and pass key can be found at the Test credentials page.

Features

Installation

yarn add pesa-lib

Usage

  • All methods return a promise.
  • See Sample.ts

Initialization

// For Javascript use
// const PesaLib = require("pesa-lib").default;
import PesaLib from "pesa-lib";

const pesalib = new PesaLib(
  consumerKey,
  consumerSecret,
  businessShortCode,
  passKey,
  baseUrl // Optional. Used to switch from sandbox to production.
);

OAuth access token

Use this API to generate an OAuth access token to access other APIs.
Other methods with use do this automatically so it's not needed.

pesaLib.oAuth()

Lipa na Mpesa Online - Process request

Use this API to initiate online payment on behalf of a customer.
Phone number should begin with 254.

pesalib.lnmProcess(amount, phoneNumber,callbackUrl, accountRef, transactionDesc)

Lipa na Mpesa Online - Query request

Use this API to check the status of a Lipa Na M-Pesa Online Payment.

pesalib.lnmQuery(checkoutRequestId)

C2B - Register Url

Use this API to register validation and confirmation URLs on M-Pesa

pesalib.c2bRegister(confirmationUrl, validationUrl)

C2B - Simulate Transaction

Use this API to simulate a C2B transaction

pesalib.c2bSimulate(amount, phoneNumber, billingRef, commandId)

Security Credentials

Encrypt credentials using a certificate file.

pesalib.security(credential, pathToCert)

Account Balance

Enquire the balance on an M-Pesa

pesalib.balance(securityCredential, initiator, partyA, idType, remarks, queueTimeoutUrl, resultUrl)

Transaction Status

Use this api to check the transaction status.

pesa.transactionStatus(identifierType, remarks, initiator, securityCredential, queueTimeoutUrl, resultTimeoutUrl, transactionId, occassion)

Disclaimer

This is an unofficial package, not made by Safaricom.

Keywords

FAQs

Last updated on 12 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc