Gathering detailed insights and metrics for node-mtn-momo
Gathering detailed insights and metrics for node-mtn-momo
Gathering detailed insights and metrics for node-mtn-momo
Gathering detailed insights and metrics for node-mtn-momo
npm install node-mtn-momo
Typescript
Module System
Min. Node Version
Node Version
NPM Version
50.2
Supply Chain
94.2
Quality
75.3
Maintenance
100
Vulnerability
98.9
License
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
39
Introduction
Language and tools
Project Structure
Installation
- On developemnt using npm
- Test
- Documentation
Functions and methods
This repository contains the source code for the MTN integration module.
This service exposes some methods and functions for communication with MTN .
The service is developed using NodeJS and NestJS
Additionally, the project is written using ES6/ES7 features and follows a recommended folder structure as follows:
├── src # Contains all service logic
│ ├── common # Contains scommon files
| | ├──enums
│ ├── config # Contains configs for service
│ │ ├── config.ts
│ └── helpers # Contains helpers files
│ │ ├── collections
│ │ | ├── requestToPay.ts
│ │ | ├── requestToPayStatus.ts
│ │ ├── disbursements
│ │ | ├── transfer.ts
│ │ | ├── transferStatus.ts
│ │ ├── account.ts
│ │ ├── apiKey.ts
│ │ ├── apiUser.ts
│ │ ├── token.ts
│ └── interfaces # Contains all interfaces
│ │ ├── auth
│ │ | ├── apiKey.ts
│ │ | ├── apiUser.ts
│ │ | ├── token.ts
│ │ ├── collections
│ │ | ├── requestToPay.ts
│ │ | ├── requestToPayStatus.ts
│ │ ├── disbursements
│ │ | ├── transfer.ts
│ │ | ├── transferStatus.ts
│ │ ├── account.ts
│ │ ├── joi.ts
│ │ ├── response.ts
│ └── modules # Contains all mtn integration modules
│ │ ├── auth
│ │ | ├── collections
│ │ | | ├── token.ts
│ │ | ├── disbursements
│ │ | | ├── token.ts
│ │ | ├── apiKey.ts
│ │ | ├── apiUser.ts
│ │ | ├── index.ts
│ │ ├── collections
│ │ | ├── requestToPay.ts
│ │ | ├── requestToPayStatus.ts
│ │ | ├── account.ts
│ │ | ├── index.ts
│ │ ├── disbursements
│ │ | ├── account.ts
│ │ | ├── index.ts
│ │ | ├── transfer.ts
│ │ | ├── transferStatus.ts
│ │ ├── account.ts
│ │ ├── index.ts
│ │ ├── README.md
│ ├── schema # Contains all schemas
│ │ ├── auth
│ │ | ├── apiKey.ts
│ │ | ├── apiUser.ts
│ │ | ├── token.ts
│ │ ├── collections
│ │ | ├── requestToPay.ts
│ │ | ├── requestToPayStatus.ts
│ │ ├── disbursements
│ │ | ├── transfer.ts
│ │ | ├── transferStatus.ts
│ │ ├── account.ts
│ ├── utils
│ │ ├── errors.ts
│ │ ├── joi.ts
│ │ ├── readme.ts
│ │ ├── responses.ts
| ├── index.ts
├── test # Contains all tests for the service and fixtures definition
│ ├── mocks
| | ├── auth
│ │ | ├── collections
| │ │ | ├── token.ts
│ │ | ├── disursements
| │ │ | ├── token.ts
│ │ | ├── apiKey.ts
│ │ | ├── apiUser.ts
│ │ | ├── index.ts
│ │ | ├── token.ts
| | ├── collections
│ │ | ├── requestToPay.ts
│ │ | ├── index.ts
│ │ | ├── requestToPayStatus.ts
| | ├── disbursements
│ │ | ├── transfer.ts
│ │ | ├── index.ts
│ │ | ├── transferStatus.ts
| | ├── account.ts
| | ├── index.ts
├── .babelrc
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── CHANGELOG.MD
├── nestjs-cli.json
├── package.json
├── package-lock.json
|── README.md
|── tsconfig.build.json
└── README.json
The following environment requires the usage of the following:
For installing dependencies npm
is used. The dependencies used in this project can be found in the package.json file. In order to install them use npm ci
.
Then run npm run build
.
All tests are collected in the src/test/
project folder.
Documentation for the project can be generated using the JSDoc
annotations within the code.
To generate the documentation issue the command npm docs
.
The docs generated will be available in HTML format in the .docs/
folder.
1import { auth } from './src/index'; 2 3const apiUser = auth.createApiUser({ 4 baseUrl: string, - The remote mtn base url 5 referenceId: string, - Format - UUID. Recource ID for the API user to be created. UUID version 4 is required. 6 subscriptionKey: string,- The subscription key is used to give access to APIs in the API Manager portal. 7 providerCallbackHost: string | null, - The callback host url 8}); 9 10console.log(apiUser);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 5 providerCallbackHost: 'example.com', 6 referenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 7 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 8}; 9const mockResponse = mock.auth.createApiUserSuccessResponse(requestPayload);
1{ 2 "statusCode": 201, 3 "data": null, 4 "message": 'Successfull', 5 "requestPayload": { 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 providerCallbackHost: 'example.com', 8 referenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 9 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 10 }, 11}
1import { auth } from './src/index'; 2 3const apiKey = auth.createApiKey({ 4 baseUrl: string, - The remote mtn base url 5 referenceId: string, - Format - UUID. Recource ID for the API user to be created. UUID version 4 is required. 6 subscriptionKey: string,- The subscription key is used to give access to APIs in the API Manager portal. 7 apiUserReferenceId: string, - The same reference id used to create the api user. 8}); 9 10console.log(apiKey);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 5 referenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 6 apiUserReferenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 7 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 8}; 9const mockResponse = mock.auth.createApiKeySuccessResponse(requestPayload);
1{ 2 "statusCode": 201, 3 "data": { apikey: '5tt6yjirf67hhjhfdd' }, 4 "message": 'Successfull', 5 "requestPayload": { 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 referenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 8 apiUserReferenceId: 'eb54164c-d0fa-4f0e-b5ed-b9421a9cf7f7', 9 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 10 }, 11}
1import { auth } from './src/index'; 2 3const collectionToken = auth.collection.createToken({ 4 apiKey: string, - The generated API key 5 apiUserId: string, The generated API user id 6 subscriptionKey: string,- The subscription key is used to give access to APIs in the API Manager portal. 7 baseUrl: string, - The remote mtn base url 8}); 9 10console.log(collectionToken);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 apiKey: 'bc35f0d89c8a406e821b7febfc3b300f', 5 apiUserId: '9ff96246-f861-459f-a8ec-47d200427003', 6 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 7 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 8}; 9const mockResponse = mock.auth.createCollectionTokenSuccessResponse(requestPayload);
1{ 2 "statusCode": 200, 3 "message": 'Successfull', 4 "requestPayload": { 5 apiKey: 'bc35f0d89c8a406e821b7febfc3b300f', 6 apiUserId: '9ff96246-f861-459f-a8ec-47d200427003', 7 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 8 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 9 }, 10 "data": { 11 "accessToken": 'test-token', 12 "tokenType": 'Bearer', 13 "expiresIn": 300, 14 }, 15}
1import { auth } from './src/index'; 2 3const disbursementToken = auth.disbursement.createToken({ 4 apiKey: string, - The generated API key 5 apiUserId: string, The generated API user id 6 subscriptionKey: string,- The subscription key is used to give access to APIs in the API Manager portal. 7 baseUrl: string, - The remote mtn base url 8}); 9 10console.log(disbursementToken);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 apiKey: 'bc35f0d89c8a406e821b7febfc3b300f', 5 apiUserId: '9ff96246-f861-459f-a8ec-47d200427003', 6 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 7 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 8}; 9const mockResponse = mock.auth.createDisbursementTokenSuccessResponse(requestPayload);
1{ 2 "statusCode": 200, 3 "message": 'Successfull', 4 "requestPayload": { 5 apiKey: 'bc35f0d89c8a406e821b7febfc3b300f', 6 apiUserId: '9ff96246-f861-459f-a8ec-47d200427003', 7 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 8 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 9 }, 10 "data": { 11 "accessToken": 'test-token', 12 "tokenType": 'Bearer', 13 "expiresIn": 300, 14 }, 15}
The subscription key is used to give access to APIs in the API Manager portal. A user is assigned a subscription Key as and when the user subscribes to products in the API Manager Portal.
The API User and API Key are used to grant access to the wallet system in a specific country. API user and Key are wholly managed by the user through Partner Portal.
Users are allowed to generate/revoke API Keys through the Partner Portal.
However, on Sandbox Environment a Provisioning API is exposed to enable users to generate their own API User and API Key for testing purposes only.
The API user and API key are provisioned differently in the sandbox and production environment.
In the Sandbox a provisioning API is used to create the API User and API Key, whereas in the production environment the provisioning is done through the User Portal.
1import { collections } from './src/index'; 2 3 const validateAccount = collections.validateAccountHolderStatusForCollections({ 4 baseUrl: string, - The remote mtn base url 5 accountHolderId: string, -The AccountHolder number.Validated according to the AccountHolderID type.eg MSISDN 6 bearerToken:string - The generated access token for collections, 7 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal. , 8 targetEnvironment: string - The identifier of the Wallet Platform system where the transaction shall be processed. 9 }) 10 11console.log(validateAccount);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 5 accountHolderId: '46733123451', 6 accountHolderIdType: AccountHolderIdTypeEnum.msisdn, 7 bearerToken: 'test-token', 8 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 9 targetEnvironment: 'sandbox', 10}; 11const mockResponse = mock.collections.validateCollectionsAccountHolderStatusSuccessResponse(requestPayload);
1{, 2 "statusCode": 202, 3 message: "Successfull", 4 "requestPayload": { 5 accountHolderId: '46733123451', 6 accountHolderIdType: AccountHolderIdTypeEnum.msisdn, 7 bearerToken:"test-token", 8 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 9 targetEnvironment: 'sandbox', 10 } 11 "data": { 12 result: false, 13 }, 14}
1import { collections } from './src/index'; 2 3 const requestToPay = collections.requestToPay({ 4 baseUrl: string, - The remote mtn base url 5 accountHolderId: string, -The AccountHolder number.Validated according to the AccountHolderID type.eg MSISDN 6 bearerToken:string - The generated access token for collections, 7 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal , 8 targetEnvironment: string- The identifier of the Wallet Platform system where the transaction shall be processed., 9 referenceId: string - Format - UUID. Recource ID for the API user to be created. UUID version 4 is required., 10 amount: string - Amount that will be debited from the payer account., 11 currency:string - ISO4217 Currency, 12 payerPartyId: string - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN, 13 payerPartyIdType: string - 'MSISDN' or "EMAIL", 14 externalId: string - External id is used as a reference to the transaction. External id is used forreconciliation., 15 payeeNote: string - Message that will be written in the payee transaction history note field., 16 payerMessage: Message that will be written in the payer transaction history message field., 17 }) 18 19console.log(requestToPay);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 5 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 6 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 7 targetEnvironment: 'sandbox', 8 referenceId: '9ff96246-f861-459f-a8ec-47d200427003', 9 amount: '500', 10 currency: 'EUR', 11 payerPartyId: '46733123453', 12 payerPartyIdType: 'MSISDN', 13 externalId: 'external-id', 14 payeeNote: 'This is a note', 15 payerMessage: 'This is a message', 16}; 17const mockResponse = mock.collections.requestToPaySuccessResponse(requestPayload);
1{, 2 "statusCode": 202, 3 message: "Successfull", 4 "requestPayload": { 5 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 8 targetEnvironment: 'sandbox', 9 referenceId: '9ff96246-f861-459f-a8ec-47d200427003', 10 amount: '500', 11 currency: 'EUR', 12 payerPartyId: '46733123453', 13 payerPartyIdType: 'MSISDN', 14 externalId: 'external-id', 15 payeeNote: 'This is a note', 16 payerMessage: 'This is a message', 17 } 18 "data": {}, 19}
1import { collections } from './src/index'; 2 3 const requestToPayStatus = collections.requestToPayStatus({ 4 baseUrl: string, - The remote mtn base url 5 bearerToken:string - The generated access token for collections, 6 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal , 7 targetEnvironment: string- The identifier of the Wallet Platform system where the transaction shall be processed., 8 requestToPayReferenceId: string - The same reference that was used in the request to pay transaction. 9 }) 10 11console.log(requestToPayStatus);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 5 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 6 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 7 targetEnvironment: 'sandbox', 8 requestToPayReferenceId: '9ff96246-f861-459f-a8ec-47d200427003', 9}; 10const mockResponse = mock.collections.requestToPayStatusSuccessResponse(requestPayload);
1{, 2 "statusCode": 200, 3 message: "Successfull", 4 "requestPayload": { 5 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 8 targetEnvironment: 'sandbox', 9 requestToPayReferenceId: '9ff96246-f861-459f-a8ec-47d200427003', 10 } 11 "data": { 12 externalId: 'test-external-Id', 13 amount: '500', 14 currency: 'EURO', 15 payer: { 16 partyIdType: PartyIdTypeEnum.MSISDN, 17 partyId: '544413229', 18 }, 19 payerMessage: 'This is a message', 20 payeeNote: 'This is a note', 21 status: "SUCCESSFULL", 22 financialTransactionId: 'test', 23 }, 24}
1import { collections } from './src/index'; 2 3 const validateAccount = collections.validateAccountHolderStatusForCollections({ 4 baseUrl: string, - The remote mtn base url 5 accountHolderId: string, -The AccountHolder number.Validated according to the AccountHolderID type.eg MSISDN 6 bearerToken:string - The generated access token for collections, 7 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal. , 8 targetEnvironment: string - The identifier of the Wallet Platform system where the transaction shall be processed. 9 }) 10 11console.log(validateAccount);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 5 accountHolderId: '46733123451', 6 accountHolderIdType: AccountHolderIdTypeEnum.msisdn, 7 bearerToken: 'test-token', 8 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 9 targetEnvironment: 'sandbox', 10}; 11const mockResponse = mock.collections.validateCollectionsAccountHolderStatusSuccessResponse(requestPayload);
1{, 2 "statusCode": 202, 3 message: "Successfull", 4 "requestPayload": { 5 accountHolderId: '46733123451', 6 accountHolderIdType: AccountHolderIdTypeEnum.msisdn, 7 bearerToken:"test-token", 8 subscriptionKey: 'fb127b0faea742498dd40d88456def2f', 9 targetEnvironment: 'sandbox', 10 } 11 "data": { 12 result: true, 13 }, 14}
1import { disbursements } from './src/index'; 2 3 const transfer = disbursements.transfer({ 4 baseUrl: string, - The remote mtn base url 5 accountHolderId: string, -The AccountHolder number.Validated according to the AccountHolderID type.eg MSISDN 6 bearerToken:string - The generated access token for collections, 7 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal , 8 targetEnvironment: string- The identifier of the Wallet Platform system where the transaction shall be processed., 9 referenceId: string - Format - UUID. Recource ID for the API user to be created. UUID version 4 is required., 10 amount: string - Amount that will be debited from the payer account., 11 currency:string - ISO4217 Currency, 12 payeePartyId: string - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN, 13 payeePartyIdType: string - 'MSISDN' or "EMAIL", 14 externalId: string - External id is used as a reference to the transaction. External id is used forreconciliation., 15 payeeNote: string - Message that will be written in the payee transaction history note field., 16 payerMessage: Message that will be written in the payer transaction history message field., 17 }) 18 19console.log(transfer);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 5 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 6 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 7 targetEnvironment: 'sandbox', 8 referenceId: '9ff96246-f861-459f-a8ec-47d200427003', 9 amount: '500', 10 currency: 'EUR', 11 payeePartyId: '46733123453', 12 payeePartyIdType: 'MSISDN', 13 externalId: 'external-id', 14 payeeNote: 'This is a note', 15 payerMessage: 'This is a message', 16}; 17const mockResponse = mock.disbursements.transferSuccessResponse(requestPayload);
1{, 2 "statusCode": 202, 3 message: "Successfull", 4 "requestPayload": { 5 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 8 targetEnvironment: 'sandbox', 9 referenceId: '9ff96246-f861-459f-a8ec-47d200427003', 10 amount: '500', 11 currency: 'EUR', 12 payeePartyId: '46733123453', 13 payeePartyIdType: 'MSISDN', 14 externalId: 'external-id', 15 payeeNote: 'This is a note', 16 payerMessage: 'This is a message', 17 } 18 "data": {}, 19}
-This operation is used to get the status of a transfer. ReferenceId that was passed in the post is used as reference to the request.
1import { disbursements } from './src/index'; 2 3 const transferStatus = disbursements.transferStatus({ 4 baseUrl: string, - The remote mtn base url 5 bearerToken:string - The generated access token for collections, 6 subscriptionKey:string- The subscription key is used to give access to APIs in the API Manager portal , 7 targetEnvironment: string- The identifier of the Wallet Platform system where the transaction shall be processed., 8 transferReferenceId: string - The same reference that was used in the transfer transaction. 9 }) 10 11console.log(transferStatus);
1import { mock } from './src/index'; 2 3const requestPayload = { 4 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 5 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 6 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 7 targetEnvironment: 'sandbox', 8 transferReferenceId: '9ff96246-f861-459f-a8ec-47d200427003', 9}; 10const mockResponse = mock.disbursements.transferStatusSuccessResponse(requestPayload);
1{, 2 "statusCode": 202, 3 message: "Successfull", 4 "requestPayload": { 5 subscriptionKey: '9ff96246-f861-459f-a8ec-47d200427003', 6 baseUrl: 'https://sandbox.momodeveloper.mtn.com', 7 bearerToken: 'jgdugddgydgdygdygdygdgydgydgyd', 8 targetEnvironment: 'sandbox', 9 referenceId: '9ff96246-f861-459f-a8ec-47d200427003', 10 amount: '500', 11 currency: 'EUR', 12 payeePartyId: '46733123453', 13 payeePartyIdType: 'MSISDN', 14 externalId: 'external-id', 15 payeeNote: 'This is a note', 16 payerMessage: 'This is a message', 17 } 18 "data": {}, 19}
No vulnerabilities found.
No security vulnerabilities found.