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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@spreeloop/orange_money

v1.0.16

Published

A orange money api integration package

Downloads

1,995

Readme

Welcome to @spreeloop/orange_money 👋

The Y-note Orange Money Node.js Integration Module is a powerful toolkit designed to simplify the integration of Orange Money's payment capabilities into Node.js applications. This module provides developers with a convenient interface to interact with Orange Money APIs, enabling seamless payment processing and transaction management.

Features

  • Easy Integration: Simplifies the integration of Orange Money payment functionality into Node.js applications.
  • Flexible Configuration: Allows developers to customize payment configurations based on specific requirements.
  • Comprehensive Documentation: Provides comprehensive documentation and examples for easy integration and usage.
  • Supports Multiple Environments: Supports multiple target environments, including production and testing environments.

Installation

To install the Orange Money Node.js Integration Module, simply add it to your Node.js project using npm:

npm install @spreeloop/orange_money

Run tests

npm run test

Table content

import {OrangeMoneyPayment} from  @spreeloop/orange_money;

// Creates payment configuration
const config = {
  /** In test mode use the TargetEnvironment.fake that return static data since
    the y-note payment don't have the sandbox environment.
  */
  targetEnvironment: TargetEnvironment.prod,
  apiUserName: 'your_api_username',
  apiPassword: 'your_api_password',
  xAuthToken: 'your_x_auth_token',

// By default we use the 'console' to display the log but you can decide to 
// use your own custom log.
  logger: console;
};

const payment = OrangeMoneyPayment.createPayment(config);
  • Generate access-token

const accessTokenResponse = await payment.getAccessToken();
  • Generate pay-token

const payTokenResponse = await payment.getPayToken('your_access_token');
  • Initiate Payment

The payment initialization depends on the platform on which the application runs. This package only support USSD payment.

// Initialize Orange Money Payment
const initializationResponse = await payment.initializeOrangeMoneyPayment({
  description: 'Payment for goods',
  subscriberNumber: '696600011',
  channelUserNumber: '696600011',
  transactionId: '1234567890',
  amount: '1000',
  pinCode: '1234',
  notifUrl: 'https://yourdomain.com/payment/notify',
  payToken: 'your_pay_token',
  accessToken: 'your_access_token',
});

If you want to receive an answer immediately, always set a correct notifUrl endpoint link. The service notifies the url immediately or 1 minutes after receiving the client validation.
The response received is of the form:

{
    "payToken": "payToken",
    "status" : "status",
    "message" : "message"
}

Note: After initiating the payment, the request goes to status EXPIRED if the user doesn't validate or cancel the payment within 7 minutes.

Express is one of the most popular npm package to manage your endpoint.

Example:

import * as express from 'express';

const app = express();
const expressRouter = express.Router;
const router = expressRouter();

appV1.use('/', router);

router.post('/orange_money/payment/:paymentId', (req, res) => {
  const body = req.body;
  ...
  /** 
   * Your code.......
    Before updating the payment in your system, retrieve the payment status
    by using getOrangeMoneyPaymentStatus function and compare the status 
    received with that sent to your endpoint. This is to ensure the consistency
    of your system.
  */
  ...

  return res.sendStatus(HttpStatusCode.Ok);
});

Get Orange Money Payment Status

// Get Orange Money Payment Status
const paymentStatusResponse = await payment.getOrangeMoneyPaymentStatus({
  payToken: 'your_pay_token',
  accessToken: 'your_access_token',
});

Sometimes Orange Money API will not notify your endpoint url, so we recommend to set up a system that will run getOrangeMoneyPaymentStatus every 2 min depending on your choice.


For more information and detailed API documentation, please refer to the official Y-Note Merchant payment documentation


Author

👤 Spreeloop

🤝 Contributing

Contributions to the Orange Money Node.js Integration Module are welcome! Please feel free to open issues or submit pull requests to contribute to the development of this module.

Show your support

Give a ⭐️ if this project helped you!