/cmcic

A node module for cmcic payments

Primary LanguageJavaScriptMIT LicenseMIT

CMCIC

Build Status Coverage Status Dependency Status NPM version

NPM

How-to use

var cmcic = require('cmcic');

var tpe = new cmcic.tpe({
  CMCIC_TPE: 'tpeid',
  CMCIC_CODESOCIETE: 'societykey',
  CMCIC_CLE: '1234567890abcdef',
  CMCIC_BANK: 'CIC',
  CMCIC_LNG: 'FR',
  CMCIC_CURRENCY: 'EUR',
  CMCIC_URL_RETOUR: '/url/return',
  CMCIC_URLOK: '/url/ok',
  CMCIC_URLKO: '/url/ko'
});

var t = {
  email: 'exemple@exemple.fr',
  amount: 300,
  reference: 'qwerty'
};

var trans = new cmcic.transaction(tpe, t);

// if you use expressjs

res.send(trans.form('paimentid', true));

On your return url (still with expressjs)

var ret = tpe.checkTransactionReturn((req.method == 'POST')? req.body : req.query);

if (!ret.isSealValidated) {
  console.log('MAC seal is invalid')
  return res.send(tpe.RETURN_NOTOK);
}

if (ret.status) {
  console.error('Payment is ok');
  res.send(tpe.RETURN_OK);
} else {
  console.error('Payment is fail : ', ret.motifrefus );
  res.send(tpe.RETURN_OK);
}

Official documentation

https://www.monetico-paiement.fr/fr/info/documentations/Monetico_Paiement_documentation_technique_v1_0c.pdf

Tips

For handle different kind of payment with the same TPE, you can use the 'texte-libre' field ! You can use 'texte-libre' field like an object, it ll be stringified/parsed for you.

Coding Style

  • tabulation (4 width)
  • JsHint

TODO

https://github.com/PierrickP/cmcic/issues?labels=new-feature&page=1&state=open

License

Under MIT license, feel free to contribuate with fork and PR !