Last updated:
0 purchases
mpesadaraja
mpesa-daraja-plugin-flutter-dart #
dart wrapper for mpesa daraja api by safaricom. M-Pesa is a mobile phone-based money transfer, financing and microfinancing service, launched in 2007 by Vodafone for Safaricom and Vodacom the largest mobile network operators in Kenya and Tanzania.
Features #
[+]Lipa na mpesa
[inprogress] C2B
[inprogress] B2B
[inprogress] C2B
[inprogress] B2C
[inprogress] TRANSACTION STATUS
[inprogress] ACCOUNT BALANCE
[inprogress] REVERSAL
Getting started #
You Will need a few things from Safaricom before development.
Consumer Key
Consumer Secret
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
Add dependancy in pubspec.yaml
dependencies:
mpesadaraja: ^0.1.5
copied to clipboard
Lipa Na MPesa Online #
LIPA NA M-PESA ONLINE also known as M-PESA express (STK Push) is a Merchant/Business initiated C2B (Customer to Business) Payment. This process it takes as described in the detailed sequence diagram below is:
Once you, our merchant integrates to the API, you will be able to send a payment prompt on the customers phone (Popularly known as STK Push Prompt) to your customer's M-PESA registered phone number requesting them to enter their M-PESA pin to authorize and complete a payment.
create MpesaDaraja object and pass the following parameters:
MpesaDaraja stkpush = MpesaDaraja(
consumerKey:<>
consumerSecret:<>
passKey:<>
)
copied to clipboard
or make it a final as shown below:
final stkpush = MpesaDaraja(
consumerKey:<>
consumerSecret:<>
passKey:<>
)
copied to clipboard
cosumerKey:
consumerSecret
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
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>,
);
copied to clipboard
Parameters passed in lipaNaMpesaStk() function
BusinessShortCode: This is organizations shortcode (Paybill or Buygoods - A 5 to 7 digit account number) used to identify an organization and receive the transaction.
Amount: This is the Amount transacted normaly a numeric value. Money that customer pays to the Shorcode. Only whole numbers are supported.
PartyA: The phone number sending money. The parameter expected is a Valid Safaricom Mobile Number that is M-Pesa registered in the format 2547XXXXXXXX
PartyB: The organization receiving the funds. The parameter expected is a 5 to 7 digit as defined on the Shortcode description above. This can be the same as BusinessShortCode value above.
PhoneNUmber: The Mobile Number to receive the STK Pin Prompt. This number can be the same as PartyA value above.
CallBackUrl: A CallBack URL is a valid secure URL that is used to receive notifications from M-Pesa API. It is the endpoint to which the results will be sent by M-Pesa A
AccountReference: Account Reference: This is an Alpha-Numeric parameter that is defined by your system as an Identifier of the transaction for CustomerPayBillOnline transaction type. Along with the business name, this value is also displayed to the customer in the STK Pin Prompt message. Maximum of 12 characters.
TransactionDescription: This is any additional information/comment that can be sent along with the request from your system. Maximum of 13 Characters.
N/B: Do not use my demo keys below since they will not work.
Future<void> main() async {
final stk = MpesaDaraja(
consumerKey: 'Dm4oJgziMyOT7WTmJzQfEZS6jjzg1Fkd',
consumerSecret: 'RGRvsUGkO4jc3NuW',
passKey: 'bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919',
);
await stk.lipaNaMpesaStk(
"174379",
1,
"254798071520",
"174379",
"254798071520",
"https://mydomain.com/path",
"accountReference",
"transactionDesc",
);
}
copied to clipboard
Contributers #
Anselmo.Jr
Joel
sav4ner
Demo #
coming soon ....
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.