Mpesa constructor

Mpesa({
  1. required String clientKey,
  2. required String clientSecret,
  3. required String environment,
  4. required String passKey,
})

Initializes a new instance of Mpesa Requires 4 parameters:

  1. clientKey - This is your consumer key

  2. clientSecret - This is your consumer secret

  3. environment - This is the environment our app is running on. It can either be sandbox or production.

  4. 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);
}