Giter Site home page Giter Site logo

aitmiloud / cmi-node Goto Github PK

View Code? Open in Web Editor NEW
84.0 4.0 6.0 594 KB

:credit_card: npm package to communicate with the CMI payment gateway in Morocco

Home Page: https://www.npmjs.com/package/cmi-payment-nodejs

License: MIT License

JavaScript 1.53% TypeScript 98.47%
api-client payment-integration cmi morocco payment-gateway

cmi-node's Introduction

:package: cmi-payment-nodejs

๐Ÿ“ฆ cmi-payment-nodejs

npm package to communicate with the CMI payment plateform in Morocco

Issues GitHub pull requests Npm Total Downloads GitHub release GitHub Downloads

Report Bug Request Feature

codecov

Installation

Install cmi-node with npm

  npm i cmi-payment-nodejs

Usage/Examples using Express.js

const express = require('express');
const cmi = require('cmi-payment-nodejs');

const app = express();
const port = 3000;

// Define a route to initiate a CMI payment
app.get('/pay', (req, res) => {
  // Extract necessary information from the request query parameters
  const { amount, email, tel, BillToName } = req.query;

  // Initialize the CMI payment client with your configuration
  const CmiClient = new cmi.default({
    storekey: 'YOUR_STOREKEY', // Your CMI Store Key
    clientid: 'YOUR_CLIENTID', // Your CMI Client ID
    oid: 'UNIQUE_COMMAND_ID', // A unique command ID
    shopurl: 'https://your-shop-url.com', // Your shop's URL for redirection
    okUrl: 'https://your-success-redirect-url.com', // Redirection after a successful payment
    failUrl: 'https://your-failure-redirect-url.com', // Redirection after a failed payment
    email, // email for CMI platform
    BillToName, // name as it should appear on the CMI platform
    amount, // The amount to be paid
    callbackURL: 'https://your-callback-url.com', // Callback URL for payment confirmation
    tel, // phone number for the CMI platform
  });

  // Generate an HTML form for the CMI payment
  const htmlForm = CmiClient.redirect_post();

  // Send the HTML form as the response
  res.send(htmlForm);
});

app.listen(port, () => {
  console.log(`App is listening on port ${port}`);
});

App Screenshot

Basic test card numbers

Credit Card information cannot be used in test mode. instead, use any of the following test card numbers, a valid expiration date in the future, and any random CVC number, to create a successful payment.

Branch : visa, PAN: 4000000000000010, Expired date: make any date CVC: 000

Branch : MasterCard, PAN: 5453010000066100, Expired date: make any date CVC: 000

3D Secure test card numbers

The following card information try to tests local payments such as Strong Customer Authentication SCA

Branch : MasterCard, PAN: 5191630100004896, Authentication code: 123 Expired date: make any date CVC: 000

cmi-node's People

Contributors

aitmiloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.