node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A simple wrapper for creditguard api

styled with prettier



$ npm install creditguard

Setting up

var creditguard = require('creditguard');
var env = {
  user: 'username',
  password: 'password',
  server: '',
  terminal: '1234567',
  mid: '531', // required only for redirect
  // optional callback addresses when using cg redirect api
  // when left empty, cg will use the predefined terminal value
  success_url: 'localhost/payment/proceed?',
  error_url: 'localhost/payment/rejected?',
  cancel_url: 'localhost/payment/rejected?',
  // optional interface language of MPI hosted payment page
  language: 'heb' // default vaue is 'eng'
var options = {
  cleanup: true // remove empty fields from result, default to false
var cg = creditguard(env, options);


creditguard-node follows cg xml-api (see their docs) parameters names. For example, if their api expects the following xml :


Then the proper use would be :

// basically create an object with everything you want to put under 'doDeal' element
// (no need to inset terminal number or any other value from 'env')
let charge = {
  cardNo: '458045XXXXXX4580',
  cardExpiration: '1212'
  creditType: 'RegularCredit',
  currency: 'USD',
  transactionCode: 'Phone',
  transactionType: 'Debit',
  total: 10010,
  validation: 'AutoComm'
  user: '567890'
try {
  let res = await
  // ...
} catch (err) {
  // ...

Customer data

If you are using the xml api to get a redirect page and you want to use customerData fields to pass some data into that page, you can do it simply by attaching it to charge object:

charge.customerData = {
  userData1: 'userData1',
  userData3: 'userData3',


If your terminal supports invoices you can easily attach invoice to the call, again, by attaching it to the charge object:

// check out cg invoice documentation for complete list of properties
charge.invoice = {
  invoiceCreationMethod: 'wait',
  invoiceSubject: 'Subject',
  invoiceItemQuantity: 1,
  invoiceItemPrice: 10010,
  companyInfo: 'Vandelay Industries',
  mailTo '',


creditguard-node takes cg xml response and converts it to a javascript object so there's no need for you to parse any xml. It also verifies that the transaction result code is 000 (OK) and if not, throws an informative error that you can catch.


  • Add more tests.
  • Add more apis for common operations like charge, capture and redirect.