# SDK Initialisation

  1. Clone the develop branch of the repository mmapi-javascript-sdk:
git clone git@github.com:gsmainclusivetechlab/mmapi-javascript-sdk.git -b develop
export MMAPI_JAVASCRIPT_SDK=$(pwd)/mmapi-javascript-sdk
cd $MMAPI_JAVASCRIPT_SDK
  1. Create the file .env with all the environment variables needed to run the SDK. The values used in this file comes from your mmapi developer account. The content of the file should look like:
GSMA_BASE_URL=https://sandbox.mobilemoneyapi.io/simulator/v1.2/passthrough/mm/
GSMA_BASE_URL_AUTH=https://sandbox.mobilemoneyapi.io/2/oauth/simulator/v1.2/mm/
GSMA_TOKEN_URL=https://sandbox.mobilemoneyapi.io/v1/oauth/accesstoken/
  1. Build the SDK

After the build, the final javascript SDK file mmsdk.min.js will be in the folder dist.

npm install
npm run build
  1. Sample code to initialise JavaScript SDK:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>GSMA</title>
  </head>
  <body>
    <h1 class="main"></h1>
    <script src="mmsdk.min.js"></script>
    <script>
      // Init with Standard Auth
      gsma.initStandardAuth({
        username: '<consumer key>',
        pass: '<consumer secret>',
        apiKey: '<api key>',
        callbackUrl: '<callback url>',
        onFailure: (error) => {
          console.log('init failed stdAuth', error);
        },
        onSuccess: (success) => {
          console.log('init success stdAuth', success);
        },
      });
    </script>
    <script>
      console.log(window.gsma.auth);
    </script>
  </body>
</html>