Mpesa constructor
Mpesa({})
Initializes a new instance of Mpesa Requires 4 parameters:
-
clientKey
- This is your consumer key -
clientSecret
- This is your consumer secret -
environment
- This is the environment our app is running on. It can either besandbox
orproduction
. -
initiatorPassword
- You can get this from Your Portal(production) or from test credentials(Sandbox). It will be the Security Credential (Shortcode 1)
Implementation
Mpesa({
required this.clientKey,
required this.clientSecret,
required this.environment,
required String passKey,
}) : assert(environment == "production" || environment == "sandbox"),
_passKey = passKey,
_baseUrl =
environment == "production" ? Routes.production : Routes.sandbox,
_accessToken = base64Url.encode("$clientKey:$clientSecret".codeUnits) {
// _generateSecurityCredential(password: "", certificatepath: null);
}