lipanampesa

1.0.0 • Public • Published

Lipa Na Mpesa Node Package.

const app = require("express")();
const Mpesa = require("lipanampesa");

// create an instance
// You can have multiple instances of this e.g for production and development
const MpesaApi = new Mpesa({
  consumerKey: "<your consumer key >",
  consumerSecret: "<your consumer secret >",
  environment: "<production or sandbox>",
  shortCode: "< your business shortCode>",
  lipaNaMpesaShortCode: "< your head office number >",
  lipaNaMpesaShortPass: "<your online passKey>"
});

app.get("/test/pay", (req, res) => {
  const senderMsisdn = 2547052871689; // customer phone number
  const amount = 1000; // amount to be paid
  const callbackUrl = ""; // webhook receiveing from safaricom, callbackurl
  const accountRef = ""; // Account Ref
  const TransactionType = ""; // "CustomerBuyGoodsOnline" for till and "CustomerPayBillOnline" for paybill

  MpesaApi.lipaNaMpesaOnline(
    senderMsisdn,
    amount,
    callbackUrl,
    accountRef,
    TransactionType
  )
    .then(res => console.log(res))
    .catch(err => console.error(err));
});

Readme

Keywords

Package Sidebar

Install

npm i lipanampesa

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

4.7 kB

Total Files

8

Last publish

Collaborators

  • mwamodo