Skip to content

hachther/mesomb-js

Repository files navigation

Welcome to js-mesomb πŸ‘‹

Version Documentation License: MIT Twitter: hachther

JavaScript client for mobile payment (Orange Money, Mobile Money ...) with MeSomb services.

You can check the full documentation of the api here

🏠 Homepage

Install

yarn add @hachther/mesomb
# or
npm install @hachther/mesomb

Usage

Check the full documentation here

Runtime and framework compatibility

This SDK is compatible with common JavaScript ecosystems (React, React Native, Vue, Next.js, Angular) with the notes below.

Runtime Status Notes
React (Vite/Webpack) Supported Works out of the box in browser bundles.
React Native Supported Use the default signer or switch signer explicitly if your runtime requires it.
Vue.js (Vite/Nuxt client) Supported Works in client apps with bundlers.
Angular Supported Works in browser builds via Angular CLI/Webpack.
Next.js (Node runtime) Supported Recommended for signed requests.
Next.js Edge runtime Supported with Web Crypto signer Use WebCryptoSigner and avoid Node-only APIs.

Signature engines

By default, the SDK uses CryptoJsSigner for compatibility. You can switch signer globally:

import { Signature, WebCryptoSigner } from '@hachther/mesomb';

// Use Web Crypto where available (Edge runtimes, modern browsers).
Signature.setSigner(new WebCryptoSigner());

To restore the default implementation:

import { Signature } from '@hachther/mesomb';

Signature.resetSigner();

Security recommendation for frontend apps

For React, React Native, Vue, Angular, and browser-only Next.js pages:

  • Do not ship your MeSomb secretKey to client devices.
  • Prefer server-side signing in your backend/API route/serverless function.
  • Let clients call your backend, then your backend calls MeSomb.

This is the safest strategy and avoids secret leakage.

Below some quick examples

Collect money from an account

import {PaymentOperation, RandomGenerator} from '@hachther/mesomb';

// or Modular import
// const {PaymentOperation} = require('@hachther/mesomb');

const applicationKey = '<your application key>'
const accessKey = '<your access key>'
const secretKey = '<your secret key>'
const client = new PaymentOperation({applicationKey, accessKey, secretKey});

const response = await client.makeCollect({
  payer: '670000000',
  amount: 10000,
  service: 'MTN',
  country: 'CM',
  currency: 'XAF',
  customer: {
    email: '[email protected]',
    firstName: 'Dan',
    lastName: 'Fisher',
    town: 'Douala',
    region: 'Littoral',
    country: 'CM',
    address: 'Bepanda',
  },
  location: {town: 'Douala', region: 'Littoral', country: 'CM'},
  products: [
    {name: 'Sac a Main SM', category: 'Sac a Main', quantity: 1, amount: 10000}
  ],
});

Depose money in an account

import {PaymentOperation} from '@hachther/mesomb';

// Modular import
// const {PaymentOperation} = require('@hachther/mesomb');

const applicationKey = '<your application key>'
const accessKey = '<your access key>'
const secretKey = '<your secret key>'
const client = new PaymentOperation({applicationKey, accessKey, secretKey});

const response = await client.makeDeposit({
  receiver: '670000000',
  amount: 10000,
  service: 'MTN',
  country: 'CM',
  currency: 'XAF',
  customer: {
    email: '[email protected]',
    first_name: 'Dan',
    last_name: 'Fisher',
    town: 'Douala',
    region: 'Littoral',
    country: 'CM',
    address: 'Bepanda',
  },
  location: {town: 'Douala', region: 'Littoral', country: 'CM'},
  products: [
    {name: 'Sac a Main SM', category: 'Sac a Main', quantity: 1, 'amount': 10000}
  ],
});

response.isOperationSuccess()
response.isTransactionSuccess()

Get application status

import {PaymentOperation} from '@hachther/mesomb';
// Modular import
// const {PaymentOperation} = require('@hachther/mesomb');

const payment = new PaymentOperation({applicationKey: '<applicationKey>', accessKey: '<AccessKey>', secretKey: '<SecretKey>'});
const application = await payment.getStatus();
console.log(application);

Get transactions by IDs

import {PaymentOperation} from '@hachther/mesomb';
// Modular import
// const {PaymentOperation} = require('@hachther/mesomb');

const applicationKey = '<your application key>'
const accessKey = '<your access key>'
const secretKey = '<your secret key>'
const client = new PaymentOperation({applicationKey, accessKey, secretKey});

const transactions = await client.getTransactions(['a483a9e8-51d7-44c9-875b-1305b1801274']);

console.log(transactions)

Author

πŸ‘€ Hachther LLC [email protected]

Show your support

Give a ⭐️ if this project helped you!

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors