# SDK Initialisation

  1. Clone the develop branch of the repository mmapi-nodejs-sdk:
git clone git@github.com:gsmainclusivetechlab/mmapi-nodejs-sdk.git -b develop
export MMAPI_NODEJS_SDK=$(pwd)/mmapi-nodejs-sdk
cd $MMAPI_NODEJS_SDK
  1. Create the file config.env with all the environment variables needed to run the SDK. Replace <consumer_key> , <consumer_secret> and <api_key> with the values taken from your mmapi developer account. Also replace <callback_url> with the value according to your environment.
export CONSUMER_KEY=<consumer_key>
export CONSUMER_SECRET=<consumer_secret>
export API_KEY=<api_key>
export CALLBACK_URL=<callback_url>
export SECURITY_OPTION=DEVELOPMENT_LEVEL
  1. Load the config.env environment variables with the following command:
source config.env
  1. Sample code to initialise the node-js SDK:
/**
* MMAPI Node.js SDK dependency
*/
const mmapi = require('../lib/index');
/**
* Set up and return MMAPI Noe.js SDK environment.
*/
const consumerKey = process.env.CONSUMER_KEY
const consumerSecret = process.env.CONSUMER_SECRET;
const apiKey = process.env.API_KEY;
const securityOption = process.env.SECURITY_OPTION; // optional DEVELOPMENT_LEVEL, STANDARD_LEVEL, ENHANCED_LEVEL
const callbackUrl = process.env.CALLBACK_URL;
let environment;

if (process.env.NODE_ENV === 'production') {
  environment = new mmapi.core.LiveEnvironment(consumerKey, consumerSecret, apiKey, securityOption, callbackUrl);
}

environment = new mmapi.core.SandboxEnvironment(consumerKey, consumerSecret, apiKey, securityOption, callbackUrl);

/**
* Returns MMAPI Node.js SDK HTTP client instance with environment.
* Use this instance to invoke MMAPI APIs
*/
let client = new mmapi.core.MobileMoneyApiHttpClient(environment);

console.log("Consumer Key : " + client.environment.consumerKey)
console.log("Consumer Secret : " + client.environment.consumerSecret)
console.log("API Key : " + client.environment.apiKey)
console.log("Environment : " + client.environment.environment)
console.log("Security Level : " + client.environment.securityOption)
console.log("Callback URL : " + client.environment.callbackUrl)
console.log("MMAPI URL : " + client.environment.baseUrl)