dart_mpesa library Null safety

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.

Classes

Mpesa
MpesaB2B
The Business to Business (B2B) API is used to transfer money from one business to another business. This API enables the business to pay other businesses.
MpesaB2c
B2C API is an API used to make payments from a Business to Customers (Pay Outs). Also known as Bulk Disbursements. B2C API is used in several scenarios by businesses that require to either make Salary Payments, Cashback payments, Promotional Payments(e.g. betting winning payouts), winnings, financial institutions withdrawal of funds, loan disbursements etc.
MpesaC2BSimulation
Make payment requests from Client to Business (C2B). Simulate is available on sandbox only
MpesaResponse
MpesaService

Extensions

IdentifierTypeValue

Constants

mpesaAccountBalanceUrL → const String
'https://api.safaricom.co.ke/mpesa/accountbalance/v1/query'
mpesaAccountBalanceUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/accountbalance/v1/query'
mpesaBbUrL → const String
'https://api.safaricom.co.ke/mpesa/b2b/v1/paymentrequest'
mpesaBbUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/b2b/v1/paymentrequest'
mpesaBcUrL → const String
'https://api.safaricom.co.ke/mpesa/b2c/v1/paymentrequest'
mpesaBcUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/b2c/v1/paymentrequest'
mpesaCbRegisterUrlUrL → const String
'https://api.safaricom.co.ke/mpesa/c2b/v1/registerurl'
mpesaCbRegisterUrlUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/c2b/v1/registerurl'
mpesacbSimulationUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/c2b/v1/simulate'
mpesaLipanaMpesaOnlineUrL → const String
'https://api.safaricom.co.ke/mpesa/stkpush/v1/processrequest'
mpesaLipanaMpesaOnlineUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest'
mpesaReversalUrL → const String
'https://api.safaricom.co.ke/mpesa/reversal/v1/request'
mpesaReversalUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/reversal/v1/request'
mpesaStkpushQueryUrL → const String
'https://api.safaricom.co.ke/mpesa/stkpushquery/v1/query'
mpesaStkpushQueryUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/stkpushquery/v1/query'
mpesaTokenUrl → const String
'https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials'
mpesaTokenUrlTest → const String
'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials'
mpesaTransactionStatusUrL → const String
'https://api.safaricom.co.ke/mpesa/transactionstatus/v1/query'
mpesaTransactionStatusUrLTest → const String
'https://sandbox.safaricom.co.ke/mpesa/transactionstatus/v1/query'

Functions

fetchMpesaToken(String username, String password, {ApplicationMode applicationMode = ApplicationMode.production}) Future<Map<String, dynamic>>
processMpesaTransaction(String url, Map<String, String> headers, Map<String, dynamic> payload) Future<MpesaResponse>

Enums

ApplicationMode
BbCommandId
BbCommandId.BusinessPayBill This is a transfer of funds from one Organization's Working Account to another Organization's Utility Account. BbCommandId.BusinessBuyGoods A transfer of funds from one Organization's Working Account to another Organization's Merchant Account. BbCommandId.DisburseFundsToBusiness A transfer of funds from one Organization's Utility Account to another Organization's Working Account. BbCommandId.BusinessToBusinessTransfer A transfer of funds from one Organization's Working Account to another Organization's Working Account. BbCommandId.MerchantToMerchantTransfer A transfer of funds from one Organization's Merchant Account to another Organization's Merchant Account.
BcCommandId
BcCommandId.SalaryPayment This supports sending money to both registered BcCommandId.BusinessPayment BusinessPayment: This is a normal business to customer payment, supports only M-PESA registered customers. PromotionPayment PromotionPayment: This is a promotional payment to customers. The M-PESA notification message is a congratulatory message. Supports only M-PESA registered customers.
CbCommandID
CbCommandID.CustomerPayBillOnline This is used for Pay Bills shortcodes. CbCommandID.CustomerBuyGoodsOnline This is used for Buy Goods shortcodes.
IdentifierType

Exceptions / Errors

FetchTokenError