npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mtnapimomo

v1.2.7

Published

MTN MoMo SDK (Collection, Disbursement, Remittance) with auto-provisioning, token caching, daily file logs.

Readme

MOMO

This package provides a modern and simple SDK for the MTN Mobile Money (MoMo) API, supporting both sandbox and production environments.

  • ✅ Automatic provisioning (apiUser / apiKey) if not already provided
  • ✅ OAuth token caching per product (30 minutes)
  • ✅ Supports all 3 products: Collection, Disbursement, Remittance
  • ✅ Auto generation of X-Reference-Id (UUID v4)
  • ✅ Daily logs (./logs/YYYY-MM-DD.log)
  • ✅ Works with Node.js (CommonJS & ESM)
  • ✅ Can also be used in the browser with a custom transport (proxy through your backend)

Installation

  • From source :
git clone https://github.com/k2pme/MOMO.git   
cd MOMO 
npm install
npm run build
npm pack
# then install the .tgz in your Node project   
  • With npm :
npm i mtnapimomo

Configuration (.env)

Create a .env file:

# MTN endpoints
MTN_API_BASE_URL=https://sandbox.momodeveloper.mtn.com
MTN_API_ENVIRONMENT=sandbox

# Callback host required for provisioning (hostname only, no http/https)
MTN_URL_CALLBACK=callback.yourdomain.com

# Subscription Keys (from MTN Developer Portal)
MTN_COLLECTION_SUBSCRIPTION_KEY=xxxxxxxxxxxxxxxx
MTN_DISBURSEMENT_SUBSCRIPTION_KEY=yyyyyyyyyyyyyy
MTN_REMITTANCE_SUBSCRIPTION_KEY=zzzzzzzzzzzzzz

# (Optional) bypass provisioning if you already have apiUser/apiKey
# MTN_COLLECTION_API_USER=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# MTN_COLLECTION_API_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# MTN_DISBURSEMENT_API_USER=...
# MTN_DISBURSEMENT_API_KEY=...
# MTN_REMITTANCE_API_USER=...
# MTN_REMITTANCE_API_KEY=...

# Logs
MOMO_LOG_DIR=./logs
MOMO_LOG_LEVEL=info

Usage (Generic JavaScript Example)

async function main() {
  const momo = new MtnMomoClient();

  // --- COLLECTION ---
  const req = await momo.collection.requestToPay(1000, '242060000000', 'XAF');
  console.log('requestToPay =>', req);

  const status = await momo.collection.getStatus(req.referenceId);
  console.log('status =>', status);

  const balance = await momo.collection.getBalance();
  console.log('collection balance =>', balance);

  // --- DISBURSEMENT ---
  const disb = await momo.disbursement.transfer(1500, '242060000001', 'XAF');
  console.log('disbursement.transfer =>', disb);

  const dStatus = await momo.disbursement.getStatus(disb.referenceId);
  console.log('disbursement status =>', dStatus);

  // --- REMITTANCE ---
  const rem = await momo.remittance.cashTransfer(2000, '242060000002', 'XAF');
  console.log('remittance.cashTransfer =>', rem);

  const rStatus = await momo.remittance.getTransferStatus(rem.referenceId);
  console.log('remittance status =>', rStatus);

  const rBalance = await momo.remittance.getAccountBalance();
  console.log('remittance balance =>', rBalance);
}

main().catch((e) => {
  console.error('MoMo test error:', e?.response?.data || e);
  process.exit(1);
});

Available Functions

Collection

  • requestToPay(amount, msisdn, currency?)

  • getStatus(referenceId)

  • getBalance()

  • validateAccount(msisdn)

  • getUserinfo(msisdn)

Disbursement

  • transfer(amount, msisdn, currency?)

  • getStatus(referenceId)

Remittance

  • cashTransfer(amount, msisdn, currency?)

  • getTransferStatus(referenceId)

  • getAccountBalance()

Logs

Every action is logged automatically. Logs are written to ./logs/YYYY-MM-DD.log.

Example log line:

{"ts":"2025-08-20T16:32:07.900Z","level":"info","msg":"[Collection:RequestToPay] Success","meta":{"ref":"...","amount":"1000","currency":"XAF","phone":"242060000000"}}

Collection

collection is an MTN MOMO API product used for remote collection of bills, fees or taxes.

Ressources : Collection

userProvisioning

Useful for sandbox users, you can POST your apiUser and your apikey or GET

Ressource : sandbox User Provisioning

More ? See these videos
Part 1
Part 2

Licence

This project is licensed under the LICENSE

Author

  • github : @k2pme