You must have a Smartex merchant account to use this library. It's free to sign-up for a Smartex merchant account.
Once you have a Smartex merchant account, you will need a working Smartex Access Token – this can be done either via the library or manually in The Smartex Dashboard.
Using Smartex with your Node.js project is extremely simple. Once you've registered a Smartex account, install the smartex
project via npm:
$ cd <your project folder>
You'll notice that we've added the --save
parameter to automatically save the Smartex library to your package.json
file.
Now, in your Node application, creating an Invoice is as simple as follows:
var Smartex = require('smartex');
var privkey = fs.readFileSync('path/to/private.key');
var smartex = Smartex.createClient( privkey );
smartex.on('ready', function() {
smartex.post('invoices', function(err, invoice) {
console.log(err || invoice);
});
});
You will receive either an err
if any error took place, or an invoice
if the invoice was successfully created.
Every Invoice on Smartex has a "refunds" subcollection. To create a refund request, POST into it:
smartex.post('invoices/:invoiceID/:refunds', function(err, refundRequest) {
});
smartex.post('subscriptions', {
billData: {/*...*/},// type: Bill. See the Bill Schema.
schedule: 'monthly' // type: enumerable, ['weekly', 'monthly', 'quarterly', 'yearly']
})
Bill Schema: https://smartex.io/api