dart_mpesa 2.0.3 copy "dart_mpesa: ^2.0.3" to clipboard
dart_mpesa: ^2.0.3 copied to clipboard

This library contains methods that make it easy to consume Mpesa Api.

dart_mpesa #

Buy Me A Coffee

This library contains methods that make it easy to consume Mpesa Api. It's multi-platform, and supports CLI, server, mobile, desktop, and the browser.

Ready Methods/APIs include

  • ✅ LIPA NA MPESA
  • ✅ STKPUSH QUERY
  • ✅ C2BSIMULATE
  • ✅ B2B
  • ✅ B2C
  • ✅ C2B
  • ✅ TRANSACTION STATUS
  • ✅ ACCOUNT BALANCE
  • ✅ REVERSAL

Usage #

Create an instance of Mpesa, then use its methods to consume the Api

import 'package:dart_mpesa/dart_mpesa.dart';

main() {
  var mpesa = Mpesa(
    shortCode: "",
    consumerKey: "",
    consumerSecret: "",
    initiatorName: "",
    securityCredential: "",
    passKey: "",
    identifierType: IdentifierType.OrganizationShortCode, // Type of organization, options, OrganizationShortCode, TillNumber, OrganizationShortCode
    applicationMode: ApplicationMode.test
  );
}

lipa na mpesa online #

LIPA NA M-PESA ONLINE API also know as M-PESA express (STK Push) is a Merchant/Business initiated C2B (Customer to Business) Payment.

  MpesaResponse _res = await mpesa.lipanaMpesaOnline(
    phoneNumber: "",
    amount: 0,
    accountReference: "",
    transactionDesc: "",
    callBackURL: "", 
  );

  print(_res.statusCode);
  print(_res.rawResponse);
  print(_res.responseDescription);

B2B #

The Business to Business (B2B) API is used to transfer money from one business to another business.

  _res = await mpesa.b2bTransaction(
    shortCode: "",
    amount: 0,
    remarks: "",
    accountReference: "", // optional
    resultURL: "", 
    queueTimeOutURL: "",
    identifierType: IdentifierType.OrganizationShortCode, // options, OrganizationShortCode, TillNumber, OrganizationShortCode
    commandID: BbCommandId.BusinessToBusinessTransfer, // options, BusinessToBusinessTransfer, BusinessPayBill, BusinessBuyGoods, DisburseFundsToBusiness, MerchantToMerchantTransfer
  );

B2B buy goods #

A transfer of funds from one Organization's Working Account to another Organization's Merchant Account.

  _res = await mpesa.b2bBuyGoodsTransaction(
    shortCode: "",
    amount: 0,
    remarks: "",
    resultURL: "", 
    queueTimeOutURL: "",
  );

fetch token #

  try{
    _res = await mpesa.fetchToken;
    print(_res['token'])
  }catch(e){
    print(e)
  }

See examples or docs for more

6
likes
130
points
28
downloads

Publisher

verified publisherphan-tec.com

Weekly Downloads

This library contains methods that make it easy to consume Mpesa Api.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

http

More

Packages that depend on dart_mpesa