https://github.com/stitchng/adonis-paystack
An addon/plugin package to provide PayStack payment services in AdonisJS 4.1+
https://github.com/stitchng/adonis-paystack
adonis-framework adonisjs adonisjs-addon api payments paystack
Last synced: 3 months ago
JSON representation
An addon/plugin package to provide PayStack payment services in AdonisJS 4.1+
- Host: GitHub
- URL: https://github.com/stitchng/adonis-paystack
- Owner: stitchng
- License: mit
- Created: 2019-01-02T16:31:18.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T22:21:43.000Z (almost 5 years ago)
- Last Synced: 2025-04-06T17:49:33.233Z (10 months ago)
- Topics: adonis-framework, adonisjs, adonisjs-addon, api, payments, paystack
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# adonis-paystack
An addon/plugin package to provide PayStack payment services in AdonisJS 4.1+
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coveralls][coveralls-image]][coveralls-url]

## Getting Started
>Install from the NPM Registry
```bash
$ adonis install adonisjs-paystack
```
>Make use of it inside a HTTP/Web Socket Controller(s)
```js
const Paystack = use('PayStack')
/**
* This class handles all requests for
* the checkout flow of the app
*
* @class CheckOutController
*/
class CheckOutController {
/**
* Begin Transaction Process
*
* @method initTransaction
*
* @param {Object} context.request
* @param {Object} context.response
*
* @return {Promise}
*/
async initTransaction({ request, response }) {
//.....
try {
let paystackResponse = await Paystack.initializeTransaction({
callback_url:"https://locahost:3333/trans/hooks/paystack",
amount: 3000,
email: "xyz@abc.com"
})
}catch(ex){
console.error(ex.message);
return response.status(400).json({
data: null,
error: true,
message: ex.message
});
}
return await response.status(200).json({
data: response.body.data
});
}
async fetchCustomer({ request, response }){
//.....
try {
let paystackResponse = await Paystack.getCustomer({
customer_id:'CUS_reu3738we993wsnqah'
});
}catch(ex){
console.error(ex.message);
return response.status(400).json({
data: null,
error: true,
message: ex.message
});
}finally{
return response.status(200).json({
data: response.body.data
})
}
}
}
module.exports = CheckOutController
```
## Creating fakes (for Unit/Integration Testing in AdonisJS)
>It's possible to fake the `PayStack` instance like so:
```js
const PayStack = use('PayStack')
//start faking the provider instance
PayStack.fake()
//stop faking the provider instance
PayStack.restore()
```
## License
MIT
## Running Tests
```bash
npm i
```
```bash
npm run lint
npm run test
```
## Credits
- [Ifeora Okechukwu](https://twitter.com/isocroft)
- [Ahmad Abdul-Aziz](https://twitter.com/dev_amaz)
## Contributing
See the [CONTRIBUTING.md](https://github.com/stitchng/adonis-paystack/blob/master/CONTRIBUTING.md) file for info
## Support
**Coolcodes** is a non-profit software foundation (collective) created by **Oparand** - parent company of StitchNG, Synergixe based in Abuja, Nigeria. You'll find an overview of all our work and supported open source projects on our [Facebook Page](https://www.facebook.com/coolcodes/).
>Follow us on facebook if you can to get the latest open source software/freeware news and infomation.
Does your business depend on our open projects? Reach out and support us on [Patreon](https://www.patreon.com/coolcodes/). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
[npm-image]: https://img.shields.io/npm/v/adonisjs-paystack.svg?style=flat-square
[npm-url]: https://npmjs.org/package/adonisjs-paystack
[travis-image]: https://img.shields.io/travis/stitchng/adonis-paystack/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/stitchng/adonis-paystack
[coveralls-image]: https://img.shields.io/coveralls/stitchng/adonis-paystack/develop.svg?style=flat-square
[coveralls-url]: https://coveralls.io/github/stitchng/adonis-paystack