Skip to content

Configuration ​

FieldTypeDescription
environment'sandbox' | 'production'Required. Selects sandbox.safaricom.co.ke or api.safaricom.co.ke.
consumerKeystringRequired. From your Daraja app.
consumerSecretstringRequired. From your Daraja app.
passkeystringThe Lipa na M-Pesa Online passkey. Required for stkPush.
initiatorInitiatorThe API operator. Required for B2C, Transaction Status, Account Balance and Reversal. See Certificates.
tokenStoreTokenStoreWhere access tokens are cached. Defaults to memory. See Token store.
timeoutMsnumberPer-request timeout. Defaults to 30 000.
fetchtypeof fetchThe fetch implementation. Defaults to the global fetch.
onWarning(message: string) => voidReceives non-fatal warnings, such as an expired certificate.

createMpesa validates the configuration and throws a ValidationError listing every problem.

Released under the MIT License.