Dart wrapper for mpesa daraja api by safaricom

Overview

mpesa-daraja-plugin-flutter-dart

dart wrapper for mpesa daraja api by safaricom

Features

  1. [Done]Lipa na mpesa [x]
  2. [inprogress] C2B
  3. [inprogress] B2B
  4. [inprogress] C2B
  5. [inprogress] B2C
  6. [inprogress] TRANSACTION STATUS
  7. [inprogress] ACCOUNT BALANCE
  8. [inprogress] REVERSAL

Getting started

You Will need a few things from Safaricom before development.

  1. Consumer Key
  2. Consumer Secret
  3. Test Credentials for Development/Sanbox environment
  • Login or Register as a Safaricom developer here if you haven't.
  • Add a new App here
  • You will be issued with a Consumer Key and Consumer Secret. You will use these to initiate an Mpesa Instance.
  • Obtain Test Credentials here.
  • The Test Credentials Obtained Are only valid in Sandbox/Development environment. Take note of them.
  • To run in Production Environment you will need real Credentials.
  • To go Live and be issued with real credentials,please refer to this guide
  1. Add dependancy in pubspec.yaml
dependencies:
  mpesadaraja: ^0.1.2

Lipa Na MPesa Online

  1. creat MpesaDaraja object and pass the following parameters:
 MpesaDaraja stkpush = MpesaDaraja(
   consumerKey:<>
   consumerSecret:<>
   passKey:<>
 )

or make it a final as shown below:

  final  stkpush = MpesaDaraja(
    consumerKey:<>
    consumerSecret:<>
    passKey:<>
  )
  1. cosumerKey:
  2. consumerSecret
  3. passKey
  • The keys are generated when you create an app at [Daraja 2.0] website Click here to create your keys

  • The keys are a secret, so be sure to use them as environment variables in production code

  1. Use the object created to call lipaNaMpesaStk() function to initialize the process
    • if the function is inside anaother be sure to use a Future with await when caloing the function
    • pass the required parameters in the function as shwon below
 await stk.lipaNaMpesaStk(
    <BusinnessShortCode>,
    <Amount>,
    <PartyA>,
    <PartB>,
    <PhoneNumber>,
    <CallBackUrl>,
    <AccountReference>,
    <TransactionDescription>,
  );

Parameters passed in lipaNaMpesaStk() function

BusinessShortCode Amount PartyA PartyB PhoneNUmber CallBackUrl AccountReference TransactionDescription

Future<void> main() async {
  final stk = MpesaDaraja(
    consumerKey: 'Dm4oJgziMyOT7WTmJzQfEZS6jjzg1Frd',
    consumerSecret: 'RGRvsUGkO4jc3NuW',
    passKey: 'bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919',
  );

  await stk.lipaNaMpesaStk(
    "174379",
    1,
    "254798071520",
    "174379",
    "254798071520",
    "https://mydomain.com/path",
    "accountReference",
    "transactionDesc",
  );
}

Demo

  • coming soon ....
You might also like...

A simple dart zeromq implementation/wrapper around the libzmq C++ library

dartzmq A simple dart zeromq implementation/wrapper around the libzmq C++ library Features Currently supported: Creating sockets (pair, pub, sub, req,

Dec 29, 2022

Unofficial wrapper for using Rapid7 insightOps logs (former LogEntries) with Dart.

An unofficial wrapper for using Rapid7 insightOps logs (former LogEntries) with Dart. This package is using logging package to do the actual logging,

Mar 3, 2021

A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.

A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.

Ably Flutter Plugin A Flutter plugin wrapping the ably-cocoa (iOS) and ably-java (Android) client library SDKs for Ably, the platform that powers sync

Dec 13, 2022

A most easily usable JSON wrapper library in Dart

A most easily usable JSON response wrapper library in Dart! 1. About 1.1. Introd

Jan 4, 2022

An asynchronous Kaboom wrapper, written in Dart.

Kaboom Dart An asynchronous Kaboom wrapper, written in Dart. Usage To get started, initialize a Kaboom instane: // Initializes a new Kaboom instance.

Apr 7, 2022

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Apr 5, 2022

Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Flutter Weather App using API with darkmode support Flutter 2.8.1 Null Safety Beautiful Weather App using https://github.com/MonsieurZbanowanYY/Weathe

Nov 29, 2022

App HTTP Client is a wrapper around the HTTP library Dio to make network requests and error handling simpler, more predictable, and less verbose.

App HTTP Client App HTTP Client is a wrapper around the HTTP library Dio to make network requests and error handling simpler, more predictable, and le

Nov 1, 2022

A wrapper around Navigator 2.0 and Router/Pages to make their use a easier.

A wrapper around Navigator 2.0 and Router/Pages to make their use a easier.

APS Navigator - App Pagination System This library is just a wrapper around Navigator 2.0 and Router/Pages API that tries to make their use easier: 🔧

Oct 17, 2022
Releases(pubspec)
Owner
Anselmo.Jr
craft(software);
Anselmo.Jr
A most easily usable Duolingo API wrapper in Dart. Duolingo4D is an open-sourced Dart library.

A most easily usable Duolingo API wrapper in Dart! 1. About Duolingo4D Duolingo4D is an open-sourced Dart library. With Duolingo4D, you can easily int

Kato Shinya 18 Oct 17, 2022
Federico 1 Feb 3, 2022
A Dart wrapper of the SMHI Open Data API

SMHI Open Data for Dart This package is in early development and some features may not work as intended. If so, feel free to submit a pull request. A

Lukas 1 Sep 19, 2022
A MangaDex API wrapper for Dart/Flutter

A MangaDex API wrapper for Dart Usage A simple usage example: import 'package:mangadex_api/mangadex_api.dart'; main() { var client = MDClient();

Matyáš Caras 4 Dec 2, 2022
An api wrapper for FortniteApi.io in dart.

Fortnite An api wrapper for FortniteApi.io in dart. Installation Add this to your package's pubspec.yaml file: dependencies: fortnite_api_io: any

Vanxh 3 Jan 29, 2022
The lightweight and powerful wrapper library for Twitter Ads API written in Dart and Flutter 🐦

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Twitter.dart 2 Aug 26, 2022
Dart wrapper via `dart:js` for webusb

Dart wrapper via dart:js for https://wicg.github.io/webusb/ Features canUseUsb g

Woodemi Co., Ltd 1 Jan 25, 2022
An unofficial wrapper for the kdecole api

This is an UNOFFICIAL wrapper for the kdecole api How to use ? Login First, you need to create a Client() object : LOGIN AND PASSWORD ARE NOT YOUR ENT

null 5 Nov 2, 2022
Flutter wrapper widget for Avataaars API

Flutter_avataaar Flutter wrapper widget for Avataaars API - a free online avatar

null 8 Nov 11, 2022
DiceBear API wrapper. DiceBear is an avatar library for designers and developers. Generate random avatar profile pictures!

dice_bear Flutter Package DiceBear API wrapper. DiceBear is an avatar library for designers and developers. Generate random avatar profile pictures! C

Zaif Senpai 8 Oct 31, 2022