@sails-pay/paystack 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/helpers/parameters.js
CHANGED
|
@@ -6,16 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
9
|
-
|
|
9
|
+
PAYSTACK_SECRET_KEY: {
|
|
10
10
|
type: 'string',
|
|
11
|
-
friendlyName: '
|
|
12
|
-
description: 'A valid Paystack
|
|
11
|
+
friendlyName: 'Secret Key',
|
|
12
|
+
description: 'A valid Paystack Secret Key',
|
|
13
13
|
protect: true,
|
|
14
14
|
whereToGet: {
|
|
15
15
|
url: 'https://dashboard.paystack.com/#/settings/developers',
|
|
16
|
-
description: 'Generate
|
|
16
|
+
description: 'Generate a secret key in your Paystack dashboard.',
|
|
17
17
|
extendedDescription:
|
|
18
|
-
'To generate
|
|
18
|
+
'To generate a secret key, you will first need to log in to your Paystack account, or sign up for one if you have not already done so.'
|
|
19
19
|
}
|
|
20
|
+
},
|
|
21
|
+
PAYSTACK_PUBLIC_KEY: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
friendlyName: 'Public Key',
|
|
24
|
+
description: 'A valid Paystack Public Key',
|
|
25
|
+
whereToGet: {
|
|
26
|
+
url: 'https://dashboard.paystack.com/#/settings/developers',
|
|
27
|
+
description: 'Get your public key from your Paystack dashboard.',
|
|
28
|
+
extendedDescription:
|
|
29
|
+
'To get your public key, you will first need to log in to your Paystack account, or sign up for one if you have not already done so.'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
PAYSTACK_CALLBACK_URL: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
friendlyName: 'Callback URL',
|
|
35
|
+
description: 'The default callback URL for Paystack transactions',
|
|
36
|
+
extendedDescription:
|
|
37
|
+
'This URL will be used as the default callback for all transactions unless overridden per request.'
|
|
20
38
|
}
|
|
21
39
|
}
|
package/machines/checkout.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = require('machine').build({
|
|
|
4
4
|
description: 'Creates and return a checkout authorization URL',
|
|
5
5
|
moreInfoUrl: 'https://paystack.com/docs/api/transaction/#initialize',
|
|
6
6
|
inputs: {
|
|
7
|
-
|
|
7
|
+
secretKey: require('../helpers/parameters').PAYSTACK_SECRET_KEY,
|
|
8
8
|
amount: {
|
|
9
9
|
type: 'number',
|
|
10
10
|
description: 'Amount should be in the subunit of the supported currency'
|
|
@@ -89,7 +89,7 @@ module.exports = require('machine').build({
|
|
|
89
89
|
},
|
|
90
90
|
fn: async function (
|
|
91
91
|
{
|
|
92
|
-
|
|
92
|
+
secretKey,
|
|
93
93
|
amount,
|
|
94
94
|
email,
|
|
95
95
|
currency,
|
|
@@ -107,12 +107,13 @@ module.exports = require('machine').build({
|
|
|
107
107
|
exits
|
|
108
108
|
) {
|
|
109
109
|
const adapterConfig = require('../adapter').config
|
|
110
|
+
const resolvedCallbackUrl = callbackUrl || adapterConfig.callbackUrl
|
|
110
111
|
const payload = JSON.stringify({
|
|
111
112
|
amount,
|
|
112
113
|
email,
|
|
113
114
|
currency,
|
|
114
115
|
reference,
|
|
115
|
-
callback_url:
|
|
116
|
+
...(resolvedCallbackUrl && { callback_url: resolvedCallbackUrl }),
|
|
116
117
|
plan,
|
|
117
118
|
invoice_limit: invoiceLimit,
|
|
118
119
|
metadata,
|
|
@@ -125,7 +126,7 @@ module.exports = require('machine').build({
|
|
|
125
126
|
const checkout = await fetch('/transaction/initialize', {
|
|
126
127
|
method: 'POST',
|
|
127
128
|
headers: {
|
|
128
|
-
authorization: `Bearer ${
|
|
129
|
+
authorization: `Bearer ${secretKey || adapterConfig.secretKey}`
|
|
129
130
|
},
|
|
130
131
|
body: payload
|
|
131
132
|
})
|
package/package.json
CHANGED
|
Binary file
|