TrustCommerce API Wrapper
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


npm version Build


A node.js library for communicating with the TrustCommerce payment gateway. This library returns promises.

You can install via npm:

npm install node-trustcommerce --save


In order to use this library, you'll need your account ID and password.

The send() function takes two parameters: the action, and an object of parameters to send. The action and parameters are defined in the TC Link API developer's guide.

On success, the promise will be fulfilled with an object representing the API response.

Process a new sale

var TCLink = require('node-trustcommerce');

var client = new TCLink('YOUR_ACCOUNT_ID', 'YOUR_PASSWORD');

client.send('sale', {
    amount: 1000,
    cc: '4111111111111111',
    exp: '0419',
    cvv: 123
}).then(function(response) {
    console.log('Successfully processed transaction #: ' + response.transid);
}, function(error) {
    console.error('Encountered error: ' + error.status);

Handling Errors

If the request encountered an error, the promise will be rejected with an object containing an err message, a statusCode, and the request body.

If the action itself failed on TrustCommerce's end, then the rejection error will be an object representation of the API's response.

client.send('sale', {
    amount: 1000
}).catch(function(error) {
    // error = {
    //   status: 'baddata',
    //   error: 'missingfields',
    //   offenders: ['cc', 'exp']
    // }