Logo Lanfrica

aitmiloud/cmi-node

Domaine:

digital infrastructure

Type de record:

software
Créateur:
ait
Hôte:
:credit_card: npm package to communicate with the CMI payment gateway in Morocco :package: cmi-payment-nodejs npm package to communicate with the CMI payment plateform in Morocco Report Bug Request Feature ## Installation Install cmi-node with npm ```bash npm i cmi-payment-nodejs ``` ## Usage/Examples using Express.js ```javascript 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: 'your-shop-url.com', // Your shop's URL for redirection okUrl: 'your-success-redirect-url.c…', // Redirection after a successful payment failUrl: 'your-failure-redirect-url.c…', // 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: '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}`); }); ``` ## ## 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: ` …