Skip to content

Commit

Permalink
Edited README
Browse files Browse the repository at this point in the history
  • Loading branch information
subomi committed Mar 18, 2017
1 parent 298053d commit 3ce8118
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
54 changes: 37 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## paystack ![Build status](https://travis-ci.org/theslyone/node-paystack.svg?branch=master)
## Paystack ![Build status](https://travis-ci.org/theslyone/node-paystack.svg?branch=master)

Promisified version of the original paystack API wrapper for [Paystack](https://paystack.co/).
Nodejs API wrapper for [Paystack](https://paystack.co/).

### Installation

Expand All @@ -16,15 +16,29 @@ var paystack = require('paystack')('secret_key');
```

#### Making calls to the resources
The resource methods accepts an optional callback as the last argument. The callback returns two JSON objects - `error`, which will be null for successful calls, and `body`, the response from the API call. All resources return a promise and hence calls can be cascaded (A callback argument is not required when cascading calls).
The resource methods accepts are promisified, but can receive optional callback as the last argument.

```js
// First Option
// paystack.{resource}.{method}
paystack.customer.list(function(error, body) {
console.log(error);
console.log(body);
});
```
```js
// 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.

Expand All @@ -33,28 +47,29 @@ paystack.plan.create({
name: 'API demo',
amount: 10000,
interval: 'monthly'
},function(error, body) {
console.log(error);
console.log(body);
});
})
.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.

```js
paystack.plan.get(90, function(error, body) {
console.log(error);
console.log(body);
});
paystack.plan.get(90)
.then(function(error, body) {
console.log(error);
console.log(body);
});
```

```js
paystack.transactions.list({
perPage: 20
}, 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
Expand Down Expand Up @@ -93,6 +108,11 @@ paystack.transactions.list({
- list
- listBanks
- update
- Miscellanous
- list_banks
- resolve_bin



### Contributing
- To ensure consistent code style, please follow the [editorconfig rules](http://obem.be/2015/06/01/a-quick-note-on-editorconfig.html) in .editorconfig
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paystack",
"version": "2.0.0",
"version": "2.0.1",
"description": "Paystack API wrapper",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 3ce8118

Please sign in to comment.