Mpesa class

Constructors

Mpesa({required String shortCode, required String consumerKey, required String consumerSecret, String? initiatorName, String? securityCredential, String? passKey, ApplicationMode applicationMode = ApplicationMode.production, IdentifierType identifierType = IdentifierType.OrganizationShortCode})

Properties

applicationMode ApplicationMode
getter/setter pair
consumerKey String
getter/setter pair
consumerSecret String
getter/setter pair
fetchToken Future<Map<String, dynamic>>
no setter
hashCode int
The hash code for this object.
no setterinherited
identifierType IdentifierType
Type of organization
getter/setter pair
initiatorName String?
This is an API user created by the Business Administrator of the M-PESA Bulk disbursement account that is active and authorized to initiate B2C transactions via API.
getter/setter pair
passKey String?
getter/setter pair
password String
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
securityCredential String?
This is the value obtained after encrypting the API initiator password. The password on Sandbox has been provisioned on the simulator. However, on production the password is created when the user is being created on the M-PESA organization portal.
getter/setter pair
shortCode String
getter/setter pair
timestamp String
no setter

Methods

accountBalance({required String remarks, required String queueTimeOutURL, required String resultURL}) Future<MpesaResponse>
Enquire the balance on an M-Pesa BuyGoods (Till Number) remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
b2bBuyGoodsTransaction({required String shortCode, required double amount, required String remarks, required String queueTimeOutURL, required String resultURL}) Future<MpesaResponse>
A transfer of funds from one Organization's Working Account to another Organization's Merchant Account. shortCode This is the customer business number to receive the amount. amount The amount of money being sent to the customer. remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
b2bPaybillTransaction({required String shortCode, required double amount, required String remarks, required String accountReference, required String queueTimeOutURL, required String resultURL}) Future<MpesaResponse>
This is a transfer of funds from one Organization's Working Account to another Organization's Utility Account. shortCode This is the customer business number to receive the amount. amount The amount of money being sent to the customer. accountReference Any additional information to be associated with the transaction. Sentence of upto 100 characters remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
b2bTransaction({required String shortCode, required IdentifierType identifierType, required double amount, required String remarks, String? accountReference, required String queueTimeOutURL, required String resultURL, required BbCommandId commandID}) Future<MpesaResponse>
The Business to Business (B2B) API is used to transfer money from one business to another business. shortCode This is the customer business number to receive the amount. amount The amount of money being sent to the customer. identifierType Type of organization receiving the transaction accountReference Any additional information to be associated with the transaction. Sentence of upto 100 characters commandID This is a unique command that specifies B2B transaction type. (BusinessPayBill, BusinessBuyGoods, DisburseFundsToBusiness, BusinessToBusinessTransfer, MerchantToMerchantTransfer) remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
b2cTransaction({required String phoneNumber, required double amount, required String remarks, required String occassion, required String queueTimeOutURL, required String resultURL, BcCommandId commandID = BcCommandId.BusinessPayment}) Future<MpesaResponse>
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. phoneNumber This is the customer mobile number to receive the amount. - The number should have the country code (254) without the plus sign. amount The amount of money being sent to the customer. commandID This is a unique command that specifies B2C transaction type.(BusinessPayment, SalaryPayment, PromotionPayment) remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
c2bOnlineSimulation({required String phoneNumber, required double amount, String? billRefNumber, CbCommandID commandID = CbCommandID.CustomerPayBillOnline}) Future<MpesaResponse>
Make payment requests from Client to Business (C2B). Simulate is available on sandbox only phoneNumber This is the phone number initiating the C2B transaction. amount This is the amount being transacted. The parameter expected is a numeric value. billRefNumber This is used on CustomerPayBillOnline option only. This is where a customer is expected to enter a unique bill identifier, e.g. an Account Number. Alpha-Numeric less then 20 digits. commandID This is a unique identifier of the transaction type. (CustomerPayBillOnline, CustomerBuyGoodsOnline)
lipanaMpesaOnline({required String phoneNumber, required double amount, required String accountReference, required String transactionDesc, required String callBackURL}) Future<MpesaResponse>
LIPA NA M-PESA ONLINE API also know as M-PESA express (STK Push) is a Merchant/Business initiated C2B (Customer to Business) Payment. phoneNumber The Mobile Number to receive the STK Pin Prompt. amount The amount of money being sent to the customer. 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. Maximum of 12 characters. transactionDesc This is any additional information/comment that can be sent along with the request from your system. Any string between 1 and 13 characters. 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 API.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reversalTransaction({required String transactionID, required double amount, required String remarks, required String occassion, required String queueTimeOutURL, required String resultURL}) Future<MpesaResponse>
Reverses a B2B, B2C or C2B M-Pesa transaction. transactionID This is the Mpesa Transaction ID of the transaction which you wish to reverse. amount The amount of money being sent to the customer. occassion Any additional information to be associated with the transaction. Sentence of upto 100 characters remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.
stkPushQuery({required String checkoutRequestID}) Future<MpesaResponse>
Use this API to check the status of a Lipa Na M-Pesa Online Payment. checkoutRequestID This is a global unique identifier of the processed checkout transaction request.
toString() String
A string representation of this object.
inherited
transactionStatus({required String transactionID, required IdentifierType identifierType, required String remarks, required String occassion, required String queueTimeOutURL, required String resultURL}) Future<MpesaResponse>
Check the status of a transaction transactionID This is the Mpesa Transaction ID of the transaction which you wish to reverse. identifierType Type of organization receiving the transaction (MSISDN, TillNumber, OrganizationShortCode) occassion Any additional information to be associated with the transaction. Sentence of upto 100 characters remarks Comments that are sent along with the transaction. Sentence of up to 100 characters queueTimeOutURL This is the URL to be specified in your request that will be used by API Proxy to send notification incase the payment request is timed out while awaiting processing in the queue. resultURL This is the URL to be specified in your request that will be used by M-PESA to send notification upon processing of the payment request.

Operators

operator ==(Object other) bool
The equality operator.
inherited