Module mpesa::environment

source ·
Expand description

MPESA Environment

Code related to setting up the desired Safaricom API environment. Environment can be either sandbox or production. you will need environment specific credentials (CLIENT_KEY AND CLIENT_SECRET) when creating an instance of the Mpesa client struct. Note that you cannot use sandbox credentials in production and vice versa.

Based on selected environment. You are able to access environment specific data such as the base_url and the public key an X509 certificate used for encrypting initiator passwords. You can read more about that from the Safaricom API docs.

Enums

  • Enum to map to desired environment so as to access certificate and the base url Required to construct a new Mpesa struct

Traits

  • Expected behavior of an Mpesa client environment This abstraction exists to make it possible to mock the MPESA api server for tests