https://github.com/sailscastshq/sails-hook-paystack
This Sails hook exposes methods for interacting with the Paystack API. Internally it uses the machinepack-paystack package
https://github.com/sailscastshq/sails-hook-paystack
credit-card payment-processing paystack paystack-api sails-hook sailsjs
Last synced: 8 days ago
JSON representation
This Sails hook exposes methods for interacting with the Paystack API. Internally it uses the machinepack-paystack package
- Host: GitHub
- URL: https://github.com/sailscastshq/sails-hook-paystack
- Owner: sailscastshq
- License: mit
- Created: 2020-10-16T08:40:13.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2022-01-18T20:41:37.000Z (about 4 years ago)
- Last Synced: 2025-09-30T02:59:57.951Z (4 months ago)
- Topics: credit-card, payment-processing, paystack, paystack-api, sails-hook, sailsjs
- Language: JavaScript
- Homepage: https://www.npmjs.com/settings/dominuskelvin/packages
- Size: 202 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sails-hook-paystack
This Sails hook exposes methods for interacting with the Paystack API.
Internally it uses the [machinepack-paystack](https://www.npmjs.com/package/machinepack-paystack) package
## Getting Started
```sh
npm i sails-hook-paystack --save
```
## Usage
After installation, you can access the methods to interact with Paystack API as helpers in your Sails application. Like so:
```js
// api/controllers/admin/create-plan
// ...
const createdPlan = await sails.helpers.paystack.createPlan.with({
name: 'Plan from Sails Hook',
amount: 10000,
interval: 'monthly'
})
exits.success({createdPlan})
```
## Secret Key
Note you didn't need to specify your Paystack secret key because this hook look for your secret key if not defined in the call to the helper in 3 places
1. In `config/local.js` via `sails.config.paystackSecret`
2. In `config/custom.js` (which you can override in your `env/production.js` or `env/staging.js`) via `sails.config.custom.paystackSecret`
3. In your app environment via `process.env.PAYSTACK_SECRET`
## Test
To run the test in this machine, rename `env.example` to `.env` then replace the content with your Paystack test API Key
Now run test simply with:
```sh
npm test
```
Alternatively you can run tests by
```sh
PAYSTACK_API_KEY_FOR_TESTS=YOUR_PAYSTACK_TEST_API_KEY npm test
```