1.0.3 • Published 8 years ago

node-trustcommerce v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

node-trustcommerce

npm version Build codecov.io

Summary

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

Examples

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']
    // }
});
1.0.3

8 years ago

1.0.2

9 years ago

1.0.0

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago