The @mpesaflow/sdk is a type-safe Typescript SDK that allows you to access the resources and methods of the MpesaFlow REST API.

1. Install

Get the MpesaFlow Node.js SDK.
npm install @mpesaflow/sdk

2. Add Authentcation

Add your MpesaFlow API Token into the SDK
server.ts
import { MpesaFlow } from "@mpesaflow/sdk";

const mpesaFlow = new MpesaFlow({
  token: "MPESAFLOW_API_KEY",
});

3. Send your first payment

Send your first payment with the MpesaFlow SDK
server.ts
import { MpesaFlow } from "@mpesaflow/sdk";

const mpesaFlow = new MpesaFlow({
  token: "MPESAFLOW_API_KEY",
});

async function run() {
  const result = await mpesaFlow.express.pay({
    phoneNumber: "254712345678",
    amount: "100.00",
    transactionDesc: "mpesaflow",
    customerName: "John Doe",
    accountReference: "mpesaflow",
  });

  console.log(result);
}

run();