mpesa 0.0.3

mpesa #

A dart wrapper around mpesa daraja api.

Work in progress

Not tested. Will be functional at version 1.0.0

Ready Methods/APIs

  • [x] LIPA NA MPESA
  • [ ] C2BSIMULATE
  • [ ] B2B
  • [ ] C2B
  • [ ] B2C
  • [ ] TRANSACTION STATUS
  • [ ] ACCOUNT BALANCE
  • [ ] REVERSAL

Requisites #

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

Getting Started #

For help getting started with Flutter, view their online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

mpesa #

Any entries below v1.0.0 will not be useful 😅😅

[0.0.1] - 14/8/2019

  • Init to win it

[0.0.2] - 14/8/2019

  • Added barebones Lipa na Mpesa method

[0.0.3] - 14/8/2019

  • Some tweaking.

example/main.dart

import 'package:mpesa/mpesa.dart';

void main() {
  var mpesa = Mpesa(
    clientKey: "YOUR_CONSUMER_KEY_HERE",
    clientSecret: "YOUR_CONSUMER_SECRET_HERE",
    passKey: "YOUR_LNM_PASS_KEY_HERE",
    initiatorPassword: "YOUR_SECURITY_CREDENTIAL_HERE",
    environment: "sandbox",
  );

  mpesa
      .lipaNaMpesa(
        phoneNumber: "",
        amount: 1,
        businessShortCode: "",
        callbackUrl: "",
      )
      .then((result) {})
      .catchError((error) {});
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mpesa: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mpesa/mpesa.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/mpesa.dart. (-1.99 points)

Analysis of lib/mpesa.dart reported 4 hints:

line 21 col 16: The value of the field '_clientKey' isn't used.

line 22 col 16: The value of the field '_clientSecret' isn't used.

line 23 col 16: The value of the field '_environment' isn't used.

line 26 col 10: The value of the field '_securityCredential' isn't used.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test