0.6.0 • Published 7 years ago

pesa-lib v0.6.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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

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.

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago