installation

Installation

In the directory containing package.json, run your package manager`s install command:

npm

pnpm

yarn

npm install daraja-kit

Before using the library, make sure to set up the required environment variables in the .env file. These variables include:

ENVIRONMENT: Set the environment to either production ordevelopment.

MPESA_CONSUMER_KEY: Consumer Key obtained from Safaricom Daraja.

MPESA_CONSUMER_SECRET: Consumer Secret obtained from Safaricom Daraja.

MPESA_BUSINESS_SHORT_CODE: Your M-Pesa business short code. For Sandbox use the code 174379

MPESA_TRANSACTION_TYPE : Set the transaction type, either CustomerPayBillOnline orCustomerBuyGoodsOnline

MPESA_API_PASS_KEY: Your M-Pesa API pass key. For sandbox usebfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919

The library throws errors if any of this values are missing from your .env file.

INFO

Daraja Kit has a peer dependency on React 18. If you use the node apis you don`t need to have react installed.

Basic usage

The library consists of a collection of typescript functions, types and some react components. To use them just import the function you want from the library and use it in your app.