1.2.0 • Published 7 years ago

node-payant v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

node-payant

A nodejs API for Payant.

Installation

npm install node-payant

Features

  • Promisified
  • Callback chaining with promise handlers

Parameters For Each Call

Resource/methodRefparams
Clients.addNilYes - firstname, lastname, email, phone
Clients.getYesNil
Clients.editYesYes - firstname, lastname, email, phone
Clients.deleteYesNil
Invoices.addNilYes - firstname, lastname, email, phone or client_id, due_date, fee_bearer, items
Invoices.getYesNil
Invoices.sendYesNil
Invoices.historyNilYes - period
Invoices.deleteYesNil
misc.getBanksNilNil
Payments.createNilYes - reference_code, date, amount, channel
Payments.getYesNil
Payments.historyNilYes - period
Products.createNilYes - customer, plan
Products.disableNilYes - code, token
Products.enableNilYes - code, token
Products.getYesNil
Products.listNilNil

The parameters specified in the third column are the complusory ones. But they are not limited to them alone. Check over at Payant for the complete list.

Examples

The Payant constructor takes in two arguments in a particular order.

  • secret_key: Your secret key derived from your payant dashboard.
  • demo_flag: It is used to set your endpoint either for production or testing, It is your default endpoint, to remove it in production set it to false.
// Requiring the library
var Payant = require('node-payant');

// To set endpoint for demo
Payant = Payant(secret_key);

// OR 
Payant = Payant(secret_key, true);

// To set endpoint for production
Payant = Payant(secret_key, false);

// Adding a new client
payant.clients.add({
		data: {
				first_name: "Subomi",
				last_name: "Oluwalana",
				email: "subomi.oluwalana@yahoo.com",
				phone: "2348077886076"
			}
		}, (error, data) => {
			if(!error) {
				return data;
			} 
			return error;
		})

// Retrieving a client's details
payant.clients.get(
		{ref: 900}, 
		(error, data) => {
			// parse response as json object
			return JSON.parse(data);
		})
		.then((value) => {}, (reason) => {});

TODO

  • Write Tests

Saying Thank You

Just star, and report issues. Thank you.