Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adonisjs-paystack

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonisjs-paystack

An addon/plugin package to provide PayStack payment services in AdonisJS 4.1+

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

adonis-paystack

An addon/plugin package to provide PayStack payment services in AdonisJS 4.1+

NPM Version Build Status Coveralls

Getting Started

Install from the NPM Registry


    $ adonis install adonisjs-paystack

Make use of it inside a HTTP/Web Socket Controller(s)


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:

const PayStack = use('PayStack')

//start faking the provider instance
PayStack.fake()

//stop faking the provider instance
PayStack.restore()

License

MIT

Running Tests


    npm i


	npm run lint

    npm run test

Credits

Contributing

See the 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.

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. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Keywords

FAQs

Package last updated on 23 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc