1.0.0 • Published 1 year ago

nodejs-maib v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

MAIB Payment Gateway for Node.js

Table of Contents

Installation

Get started by installing the package:

npm install --save nodejs-maib

Usage

Setup

First, require the package in your file:

const MAIB = require('nodejs-maib');

Then, instantiate the class providing the cert file and passphrase:

const maib = new MAIB('certificate_path', 'certificate_pass', 'merchanthandler_endpoint');

Test certificate: 0149583.pem

Password: Za86DuC$

Test MerchantHandler URL: https://maib.ecommerce.md:21440/ecomm/MerchantHandler

Test ClientHandler URL: https://maib.ecommerce.md:21443/ecomm/ClientHandler

Use openssl to convert certificate in .pem format from .pfx and password provided by bank:

openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes

You can now start working with the payment gateway.

Create SMS Transaction

const smstrans = async function() {
  const result = await maib
  .setDescription('Test Transaction')
  .setClientIpAddress('127.0.0.1')
  .setLanguage('ro')
  .setCurrency(498)
  .setAmount(1)
  .createTransaction();
  
console.log(result);
 }
smstrans();

/*
{
  TRANSACTION_ID: 'TRANSACTION_ID_HERE'
}
*/

To enter card details redirect transaction ID to ClientHandler URL. Ex:

https://maib.ecommerce.md:21443/ecomm/ClientHandler?trans_id=rEsfhyIk8s9ypxkcS9fjo3C8FqA=

Create DMS Transaction

const dmstrans = async function() {
  const result = await maib
  .setDescription('Test Transaction')
  .setClientIpAddress('127.0.0.1')
  .setLanguage('ro')
  .setCurrency(498)
  .setAmount(1)
  .createTransaction(type = 'DMS');
  
console.log(result);
}
dmstrans();

/*
{
  TRANSACTION_ID: 'TRANSACTION_ID_HERE'
}
*/

To enter card details redirect transaction ID to ClientHandler URL.

Commit DMS Transaction

const commitdms = async function() {
const result = await maib
  .setDescription('Test Transaction')
  .setClientIpAddress('127.0.0.1')
  .setCurrency(498)
  .setAmount(1)
  .commitTransaction('TRANSACTION_ID_HERE');
  
console.log(result);
}
commitdms();

/*
{
  RESULT: '...',
  RESULT_CODE: '...',
  RRN: '...',
  APPROVAL_CODE: '...',
  CARD_NUMBER: '...'
}
*/

Transaction Status

const status = async function() {
const result = await maib.getTransactionStatus('TRANSACTION_ID_HERE');

console.log(result);
}
status();

/*
{
  RESULT: '...',
  RESULT_CODE: '...',
  3DSECURE: '...',
  RRN: '...',
  APPROVAL_CODE: '...',
  CARD_NUMBER: '...'
  RECC_PMNT_ID: '...'
  RECC_PMNT_EXPIRY: '...'
  MRCH_TRANSACTION_ID: '...'
}
*/

Reverse Transaction

const revers = async function() {
const result = await maib
  .setAmount(1)
  .reverseTransaction('TRANSACTION_ID_HERE');
  
console.log(result);
}
revers();

/*
{
  RESULT: '...',
  RESULT_CODE: '...',
}
*/

Close Day

const closeday = async function() {
const result = await maib.closeDay();

console.log(result);
}
closeday();

/*
{
  RESULT: '...',
  RESULT_CODE: '...',
  FLD_074: '...',
  FLD_075: '...',
  FLD_076: '...',
  FLD_077: '...',
  FLD_086: '...',
  FLD_087: '...',
  FLD_088: '...',
  FLD_089: '...',
}
*/

Card Registration

const cardregist = async function() {
const result = await maib
  .setCurrency(498)
  .setClientIpAddress('127.0.0.1')
  .setDescription('Card Registration Test')
  .registerCard('CARD_ID');
  
console.log(result);
}
cardregist();

/*
{
  TRANSACTION_ID: '...',
}
*/

To enter card details redirect transaction ID to ClientHandler URL.

Regular Payments

const regularpayment = async function() {
const result = await maib
  .setCurrency(498)
  .setClientIpAddress('127.0.0.1')
  .setDescription('Regular Payment Test')
  .setAmount(1)
  .makeRegularPayment('CARD_ID');
  
console.log(result);
}
regularpayment();

/*
{
  TRANSACTION_ID: '...',
  RESULT: '...',
  RESULT_CODE: '...',
  RRN: '...',
  APPROVAL_CODE: '...',
}
*/

Delete Regular Payment

const deleterec = async function() {
const result = await maib
  .deleteRegularPayment('CARD_ID');

console.log(result);
}
deleterec();

/*
{
  RESULT: '...',
}
*/