Daraja Client is a type-safe NodeJS library for Safaricom's Daraja API. With Daraja Client you get full access to all of the operations provided by the Daraja platform.
Install Daraja Client with:
npm install @daraja/client
or
yarn add @daraja/client
Daraja Client provides a DarajaCredentials
class that manages the credentials required to access the Daraja API.
First create an instance of DarajaCredentials
like so:
import { DarajaCredentials } from '@daraja/client';
const credentials = new DarajaCredentials({
consumerKey: '{YOUR_CONSUMER_KEY}',
consumerSecret: '{YOUR_CONSUMER_SECRET}',
environment: 'sandbox',
});