# SDK Initialisation

  1. Clone the develop branch of the repository mmapi-php-sdk:
git clone git@github.com:gsmainclusivetechlab/mmapi-php-sdk.git -b develop
export MMAPI_PHP_SDK=$(pwd)/mmapi-php-sdk
cd $MMAPI_PHP_SDK
  1. Install Composer.

  2. From the root of the mmapi-php-sdk project, type:

composer install
  1. Copy config.env.sample to config.env and 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.
consumer_key=<consumer_key>
consumer_secret=<consumer_secret>
api_key=<api_key>
callback_url=<callback_url>
  1. Sample code to initialise PHP SDK:
<?php
//require the autoload file
require dirname(__DIR__, 1) . '/autoload.php';

//Parse the config file
$env = parse_ini_file(__DIR__ . '../../config.env');

use mmpsdk\\Common\\Constants\\MobileMoney;
use mmpsdk\\Common\\Enums\\SecurityLevel;
use mmpsdk\\Common\\Exceptions\\SDKException;

//Initialize SDKa
try {
  MobileMoney::initialize(
      MobileMoney::SANDBOX,
      $env['consumer_key'],
      $env['consumer_secret'],
      $env['api_key']
  );
  MobileMoney::setCallbackUrl($env['callback_url']);
  MobileMoney::setSecurityLevel(SecurityLevel::DEVELOPMENT);
} catch (SDKException $exception) {
  prettyPrint($exception->getMessage());
}

function prettyPrint($data)
{
  echo PHP_EOL . print_r($data, true) . PHP_EOL;
}

print("Consumer Key : " . MobileMoney::getConsumerKey() . PHP_EOL);
print("Consumer Secret : " . MobileMoney::getConsumerSecret() . PHP_EOL);
print("API Key : " . MobileMoney::getApiKey() . PHP_EOL);
print("Environment : " . MobileMoney::getEnvironment() . PHP_EOL);
print("Security Level : " . MobileMoney::getSecurityLevel() . PHP_EOL);
print("Callback URL : " . MobileMoney::getCallbackUrl() . PHP_EOL);
print("MMAPI URL : " . MobileMoney::getBaseUrl() . PHP_EOL);
?>