Simple wrapper for Creditguard API
A simple wrapper to creditguard api
npm install creditguard
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 valuesuccess_url: 'localhost/payment/proceed?'error_url: 'localhost/payment/rejected?'cancel_url: 'localhost/payment/rejected?';var options =verbose: true // prints more logs, default to falsecleanup: true // remove empty fields from result, default to false;var cg = creditguardenv 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')var charge =cardNo: '458045XXXXXX4580'cardExpiration: '1212'creditType: 'RegularCredit'currency: 'USD'transactionCode: 'Phone'transactionType: 'Debit'total: 10010validation: 'AutoComm'user: '567890';cgcallchargeif errconsole.errorerr;console.errorres;elseconsole.logres;;
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
chargecustomerData =userData1: 'userData1'userData3: 'userData3'
If your terminal supports invoices you can easily attach invoice to the call again, by attaching it to the
// check out cg invoice documentation for complete list of propertieschargeinvoice =invoiceCreationMethod: 'wait'invoiceSubject: 'Subject'invoiceItemQuantity: 1invoiceItemPrice: 10010companyInfo: 'Vandelay Industries'mailTo 'email@example.com'
creditguard-node takes cg
xml response and converts it to a
000 (OK) and if not, throws an informative error that you can catch.
*_urlfields to optional to allow non-redirect api calls
Copyright (C) 2013 Michael Derazon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.