Giter Site home page Giter Site logo

node-pay's Introduction

Paystack Build status

Nodejs API wrapper for Paystack.

Installation

npm install paystack

Usage

// Require the library
var paystack = require('paystack')('secret_key');

Making calls to the resources

The resource methods accepts are promisified, but can receive optional callback as the last argument.

// First Option
// paystack.{resource}.{method}
paystack.customer.list(function(error, body) {
  console.log(error);
  console.log(body);
});
// Second Option
// paystack.{resource}
paystack.customer.list()
	.then(function(body) {
  		console.log(body);
	})
	.catch(function(error) {
		console.log(error);
	});

For resource methods that use POST or PUT, the JSON body can be passed as the first argument.

paystack.plan.create({
  name: 'API demo',
  amount: 10000,
  interval: 'monthly'
})
  .then(function(error, body) {
  	 console.log(error);
    console.log(body);
	});

For GET, you can pass the required ID as string and optional parameters as an optional object argument.

paystack.plan.get(90)
	.then(function(error, body) {
		console.log(error);
		console.log(body);
	});
paystack.transactions.list({perPage: 20})
	.then(function(error, body) {
		console.log(error);
		console.log(body);
	});

Resources

  • customer
    • create
    • get
    • list
    • update
  • transaction
    • initialize
    • charge
    • get
    • list
    • totals
    • verify
  • plan
    • create
    • get
    • list
    • update
  • page
    • create
    • get
    • list
    • update
  • subscription
    • create
    • disable
    • enable
    • get
    • list
  • subaccount
    • create
    • get
    • list
    • listBanks
    • update
  • Miscellanous
    • list_banks
    • resolve_bin

Contributing

Tests

To run tests, add your Paystack test secret key to package.json. (The test line should look something like this: env KEY=sk_test_1a68ac96a0171fb72111a24295d8d31d41c28eed ./node_modules/.bin/mocha...). Now run:

npm test

If you are contributing to the repo, kindly update the necessary test file in /test or add a new one and ensure all tests are passed before sending a PR.

Todo

  • Proper resource examples
  • ES6 support

node-pay's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.