@toneflix/paystack-cli 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/LICENSE +15 -0
- package/README.md +907 -0
- package/bin/cli.cjs +3277 -0
- package/bin/cli.js +3248 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
# Paystack CLI
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@toneflix/paystack-cli)
|
|
4
|
+
[](https://github.com/toneflix/paystack-cli/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/toneflix/paystack-cli/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/toneflix/paystack-cli/actions/workflows/deploy-docs.yml)
|
|
7
|
+
|
|
8
|
+
The Paystack CLI helps you build, test, and manage your Paystack integration right from the terminal. Interact with the Paystack API, test webhooks locally, and manage your integration settings without leaving your command line.
|
|
9
|
+
|
|
10
|
+
**[View Documentation](https://paystack.cli.toneflix.net)**
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
- [Features](#features)
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Quick Start](#quick-start)
|
|
17
|
+
- [Authentication](#authentication)
|
|
18
|
+
- [Commands](#commands)
|
|
19
|
+
- [Core Commands](#core-commands)
|
|
20
|
+
- [API Commands](#api-commands)
|
|
21
|
+
- [Webhook Commands](#webhook-commands)
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [Webhook Testing](#webhook-testing)
|
|
24
|
+
- [API Resources](#api-resources)
|
|
25
|
+
- [Examples](#examples)
|
|
26
|
+
- [Development](#development)
|
|
27
|
+
- [Troubleshooting](#troubleshooting)
|
|
28
|
+
- [Contributing](#contributing)
|
|
29
|
+
- [License](#license)
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
**Complete Paystack API Access** - Access all Paystack API endpoints directly from your terminal
|
|
34
|
+
|
|
35
|
+
**Secure Authentication** - Login once and securely manage your Paystack integration
|
|
36
|
+
|
|
37
|
+
**Local Webhook Testing** - Test webhooks locally using ngrok integration
|
|
38
|
+
|
|
39
|
+
**Configuration Management** - Configure API settings, timeouts, and debug modes
|
|
40
|
+
|
|
41
|
+
**Beautiful Output** - Formatted JSON responses with colored output for better readability
|
|
42
|
+
|
|
43
|
+
**Developer Friendly** - Built with TypeScript for type safety and better DX
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
### NPM
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g @toneflix/paystack-cli
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### PNPM
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm add -g @toneflix/paystack-cli
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Yarn
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
yarn global add @toneflix/paystack-cli
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
After installation, verify the CLI is installed correctly:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
paystack-cli --version
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
1. **Initialize the CLI**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
paystack-cli init
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. **Login to your Paystack account**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
paystack-cli login
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
3. **Start using Paystack API commands**
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# List all transactions
|
|
89
|
+
paystack-cli transaction:list
|
|
90
|
+
|
|
91
|
+
# Fetch customer details
|
|
92
|
+
paystack-cli customer:fetch --id=CUS_xxxxx
|
|
93
|
+
|
|
94
|
+
# Create a new plan
|
|
95
|
+
paystack-cli plan:create --name="Monthly Plan" --amount=5000 --interval=monthly
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Authentication
|
|
99
|
+
|
|
100
|
+
### Login
|
|
101
|
+
|
|
102
|
+
The CLI uses your Paystack account credentials for authentication:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
paystack-cli login
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
You'll be prompted for:
|
|
109
|
+
|
|
110
|
+
- **Email**: Your Paystack account email
|
|
111
|
+
- **Password**: Your Paystack account password
|
|
112
|
+
- **Remember**: Option to save your email for future logins
|
|
113
|
+
|
|
114
|
+
After successful login, you'll select which integration to use (if you have multiple).
|
|
115
|
+
|
|
116
|
+
### Logout
|
|
117
|
+
|
|
118
|
+
To logout and clear your session:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
paystack-cli logout
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Session Management
|
|
125
|
+
|
|
126
|
+
- Sessions automatically expire after the token timeout period
|
|
127
|
+
- You'll be prompted to login again when your session expires
|
|
128
|
+
- Login credentials are securely stored in a local SQLite database
|
|
129
|
+
|
|
130
|
+
## Commands
|
|
131
|
+
|
|
132
|
+
### Core Commands
|
|
133
|
+
|
|
134
|
+
#### `init`
|
|
135
|
+
|
|
136
|
+
Initialize the Paystack CLI application and setup the local database.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
paystack-cli init
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### `login`
|
|
143
|
+
|
|
144
|
+
Authenticate with your Paystack account.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
paystack-cli login
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
|
|
152
|
+
- Interactive prompts for email and password
|
|
153
|
+
- Option to remember email for faster login
|
|
154
|
+
- Automatic integration selection for accounts with multiple integrations
|
|
155
|
+
|
|
156
|
+
#### `logout`
|
|
157
|
+
|
|
158
|
+
Sign out and clear your authentication session.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
paystack-cli logout
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### `config`
|
|
165
|
+
|
|
166
|
+
Configure CLI settings like API base URL, timeout duration, and debug mode.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
paystack-cli config
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Available configurations:
|
|
173
|
+
|
|
174
|
+
- **API Base URL**: Default Paystack API endpoint
|
|
175
|
+
- **Timeout Duration**: Request timeout in milliseconds
|
|
176
|
+
- **Debug Mode**: Enable/disable detailed error logging
|
|
177
|
+
- **Ngrok Auth Token**: Set ngrok authentication token for webhook testing
|
|
178
|
+
|
|
179
|
+
### Webhook Commands
|
|
180
|
+
|
|
181
|
+
#### `webhook listen`
|
|
182
|
+
|
|
183
|
+
Start a local webhook listener using ngrok tunneling.
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
paystack-cli webhook listen [local_route]
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Arguments:
|
|
190
|
+
|
|
191
|
+
- `local_route` (optional): Your local webhook endpoint (e.g., `http://localhost:8080/webhook`)
|
|
192
|
+
|
|
193
|
+
Options:
|
|
194
|
+
|
|
195
|
+
- `--domain, -D`: Specify domain to ping (test/live) `[default: test]`
|
|
196
|
+
- `--forward, -F`: Forward webhook to a specific URL
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Listen on default route
|
|
202
|
+
paystack-cli webhook listen
|
|
203
|
+
|
|
204
|
+
# Listen on specific route
|
|
205
|
+
paystack-cli webhook listen http://localhost:3000/api/webhook
|
|
206
|
+
|
|
207
|
+
# Listen with custom domain
|
|
208
|
+
paystack-cli webhook listen http://localhost:8080 --domain=live
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### `webhook ping`
|
|
212
|
+
|
|
213
|
+
Send a test webhook event to your configured webhook URL.
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
paystack-cli webhook ping
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Options:
|
|
220
|
+
|
|
221
|
+
- `--event, -E`: Event type to simulate (charge.success, transfer.success, etc.)
|
|
222
|
+
- `--domain, -D`: Domain to ping (test/live) `[default: test]`
|
|
223
|
+
- `--forward, -F`: Forward to specific URL instead of saved webhook
|
|
224
|
+
|
|
225
|
+
Example:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Test charge success event
|
|
229
|
+
paystack-cli webhook ping --event=charge.success
|
|
230
|
+
|
|
231
|
+
# Test transfer failed on live
|
|
232
|
+
paystack-cli webhook ping --event=transfer.failed --domain=live
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### API Commands
|
|
236
|
+
|
|
237
|
+
All Paystack API endpoints are available as commands. The general format is:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
paystack-cli [resource]:[action] [options]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## API Resources
|
|
244
|
+
|
|
245
|
+
The CLI provides access to the following Paystack resources:
|
|
246
|
+
|
|
247
|
+
### Transactions
|
|
248
|
+
|
|
249
|
+
Manage payment transactions.
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Initialize a transaction
|
|
253
|
+
paystack-cli transaction:initialize --email=customer@email.com --amount=10000
|
|
254
|
+
|
|
255
|
+
# List all transactions
|
|
256
|
+
paystack-cli transaction:list --perPage=50 --page=1
|
|
257
|
+
|
|
258
|
+
# Verify a transaction
|
|
259
|
+
paystack-cli transaction:verify --reference=xyz123
|
|
260
|
+
|
|
261
|
+
# View transaction details
|
|
262
|
+
paystack-cli transaction:view --id=123456
|
|
263
|
+
|
|
264
|
+
# Charge authorization
|
|
265
|
+
paystack-cli transaction:charge --authorization_code=AUTH_xxx --email=user@example.com --amount=5000
|
|
266
|
+
|
|
267
|
+
# Export transactions
|
|
268
|
+
paystack-cli transaction:export --from=2024-01-01 --to=2024-12-31
|
|
269
|
+
|
|
270
|
+
# Check authorization
|
|
271
|
+
paystack-cli transaction:check --authorization_code=AUTH_xxx --email=user@example.com --amount=5000
|
|
272
|
+
|
|
273
|
+
# Get transaction totals
|
|
274
|
+
paystack-cli transaction:transaction --from=2024-01-01 --to=2024-12-31
|
|
275
|
+
|
|
276
|
+
# Fetch transaction
|
|
277
|
+
paystack-cli transaction:fetch --id=12345
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Customers
|
|
281
|
+
|
|
282
|
+
Manage customer information.
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Create customer
|
|
286
|
+
paystack-cli customer:create --email=user@example.com --first_name=John --last_name=Doe
|
|
287
|
+
|
|
288
|
+
# Update customer
|
|
289
|
+
paystack-cli customer:update --code=CUS_xxx --first_name=Jane
|
|
290
|
+
|
|
291
|
+
# Fetch customer
|
|
292
|
+
paystack-cli customer:fetch --code=CUS_xxx
|
|
293
|
+
|
|
294
|
+
# List customers
|
|
295
|
+
paystack-cli customer:list --perPage=20 --page=1
|
|
296
|
+
|
|
297
|
+
# Set risk action
|
|
298
|
+
paystack-cli customer:set_risk_action --customer=CUS_xxx --risk_action=allow
|
|
299
|
+
|
|
300
|
+
# Deactivate authorization
|
|
301
|
+
paystack-cli customer:deactivate --authorization_code=AUTH_xxx
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Plans
|
|
305
|
+
|
|
306
|
+
Create and manage subscription plans.
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Create plan
|
|
310
|
+
paystack-cli plan:create --name="Premium Plan" --amount=50000 --interval=monthly
|
|
311
|
+
|
|
312
|
+
# Update plan
|
|
313
|
+
paystack-cli plan:update --code=PLN_xxx --amount=60000
|
|
314
|
+
|
|
315
|
+
# List plans
|
|
316
|
+
paystack-cli plan:list --interval=monthly --amount=50000
|
|
317
|
+
|
|
318
|
+
# Fetch plan
|
|
319
|
+
paystack-cli plan:fetch --code=PLN_xxx
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Subscriptions
|
|
323
|
+
|
|
324
|
+
Manage customer subscriptions.
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Create subscription
|
|
328
|
+
paystack-cli subscription:create --customer=CUS_xxx --plan=PLN_xxx
|
|
329
|
+
|
|
330
|
+
# Disable subscription
|
|
331
|
+
paystack-cli subscription:disable --code=SUB_xxx --token=email_token
|
|
332
|
+
|
|
333
|
+
# Enable subscription
|
|
334
|
+
paystack-cli subscription:enable --code=SUB_xxx --token=email_token
|
|
335
|
+
|
|
336
|
+
# Fetch subscription
|
|
337
|
+
paystack-cli subscription:fetch --code=SUB_xxx
|
|
338
|
+
|
|
339
|
+
# List subscriptions
|
|
340
|
+
paystack-cli subscription:list --customer=CUS_xxx --plan=PLN_xxx
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Transfers
|
|
344
|
+
|
|
345
|
+
Handle money transfers.
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Initiate transfer
|
|
349
|
+
paystack-cli transfer:initiate --source=balance --amount=10000 --recipient=RCP_xxx
|
|
350
|
+
|
|
351
|
+
# List transfers
|
|
352
|
+
paystack-cli transfer:list --perPage=50
|
|
353
|
+
|
|
354
|
+
# Verify transfer
|
|
355
|
+
paystack-cli transfer:verify --reference=TRF_xxx
|
|
356
|
+
|
|
357
|
+
# Finalize transfer
|
|
358
|
+
paystack-cli transfer:finalize --transfer_code=TRF_xxx --otp=123456
|
|
359
|
+
|
|
360
|
+
# Bulk transfer
|
|
361
|
+
paystack-cli transfer:initiate --transfers='[{"amount":10000,"recipient":"RCP_xxx"}]'
|
|
362
|
+
|
|
363
|
+
# Disable OTP
|
|
364
|
+
paystack-cli transfer:disable
|
|
365
|
+
|
|
366
|
+
# Enable OTP
|
|
367
|
+
paystack-cli transfer:enable
|
|
368
|
+
|
|
369
|
+
# Resend OTP
|
|
370
|
+
paystack-cli transfer:resend --transfer_code=TRF_xxx --reason=resend_otp
|
|
371
|
+
|
|
372
|
+
# Fetch transfer
|
|
373
|
+
paystack-cli transfer:fetch --code=TRF_xxx
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Transfer Recipients
|
|
377
|
+
|
|
378
|
+
Manage transfer recipients.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Create recipient
|
|
382
|
+
paystack-cli transferrecipient:create --type=nuban --name="John Doe" --account_number=0123456789 --bank_code=033
|
|
383
|
+
|
|
384
|
+
# Update recipient
|
|
385
|
+
paystack-cli transferrecipient:update --code=RCP_xxx --name="Jane Doe"
|
|
386
|
+
|
|
387
|
+
# Delete recipient
|
|
388
|
+
paystack-cli transferrecipient:delete --code=RCP_xxx
|
|
389
|
+
|
|
390
|
+
# List recipients
|
|
391
|
+
paystack-cli transferrecipient:list --perPage=50
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Subaccounts
|
|
395
|
+
|
|
396
|
+
Manage split payment subaccounts.
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
# Create subaccount
|
|
400
|
+
paystack-cli subaccount:create --business_name="Vendor Co" --settlement_bank=033 --account_number=0123456789 --percentage_charge=10
|
|
401
|
+
|
|
402
|
+
# Update subaccount
|
|
403
|
+
paystack-cli subaccount:update --code=ACCT_xxx --business_name="New Name"
|
|
404
|
+
|
|
405
|
+
# Fetch subaccount
|
|
406
|
+
paystack-cli subaccount:fetch --code=ACCT_xxx
|
|
407
|
+
|
|
408
|
+
# List subaccounts
|
|
409
|
+
paystack-cli subaccount:list
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Payment Pages
|
|
413
|
+
|
|
414
|
+
Create and manage payment pages.
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
# Create page
|
|
418
|
+
paystack-cli page:create --name="Donation Page" --amount=5000
|
|
419
|
+
|
|
420
|
+
# Update page
|
|
421
|
+
paystack-cli page:update --code=PAGE_xxx --name="New Page Name"
|
|
422
|
+
|
|
423
|
+
# Fetch page
|
|
424
|
+
paystack-cli page:fetch --code=PAGE_xxx
|
|
425
|
+
|
|
426
|
+
# List pages
|
|
427
|
+
paystack-cli page:list
|
|
428
|
+
|
|
429
|
+
# Check slug availability
|
|
430
|
+
paystack-cli page:check --slug=my-page
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Payment Requests (Invoices)
|
|
434
|
+
|
|
435
|
+
Manage payment requests and invoices.
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
# Create payment request
|
|
439
|
+
paystack-cli paymentrequest:create --customer=CUS_xxx --amount=10000 --description="Invoice for services"
|
|
440
|
+
|
|
441
|
+
# List payment requests
|
|
442
|
+
paystack-cli paymentrequest:list
|
|
443
|
+
|
|
444
|
+
# Fetch payment request
|
|
445
|
+
paystack-cli paymentrequest:fetch --code=PRQ_xxx
|
|
446
|
+
|
|
447
|
+
# Update payment request
|
|
448
|
+
paystack-cli paymentrequest:update --code=PRQ_xxx --amount=15000
|
|
449
|
+
|
|
450
|
+
# Verify payment request
|
|
451
|
+
paystack-cli paymentrequest:verify --code=PRQ_xxx
|
|
452
|
+
|
|
453
|
+
# Send notification
|
|
454
|
+
paystack-cli paymentrequest:send --code=PRQ_xxx
|
|
455
|
+
|
|
456
|
+
# Finalize payment request
|
|
457
|
+
paystack-cli paymentrequest:finalize --code=PRQ_xxx
|
|
458
|
+
|
|
459
|
+
# View invoice
|
|
460
|
+
paystack-cli paymentrequest:invoice --code=PRQ_xxx
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Charges
|
|
464
|
+
|
|
465
|
+
Handle card charges and tokenization.
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
# Submit OTP
|
|
469
|
+
paystack-cli charge:submit --otp=123456 --reference=ref_xxx
|
|
470
|
+
|
|
471
|
+
# Submit PIN
|
|
472
|
+
paystack-cli charge:submit --pin=1234 --reference=ref_xxx
|
|
473
|
+
|
|
474
|
+
# Submit birthday
|
|
475
|
+
paystack-cli charge:submit --birthday=1990-01-01 --reference=ref_xxx
|
|
476
|
+
|
|
477
|
+
# Submit phone
|
|
478
|
+
paystack-cli charge:submit --phone=08012345678 --reference=ref_xxx
|
|
479
|
+
|
|
480
|
+
# Tokenize charge
|
|
481
|
+
paystack-cli charge:tokenize --card=xxx
|
|
482
|
+
|
|
483
|
+
# Check pending charge
|
|
484
|
+
paystack-cli charge:check --reference=ref_xxx
|
|
485
|
+
|
|
486
|
+
# Charge
|
|
487
|
+
paystack-cli charge:charge --email=user@example.com --amount=10000
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Bulk Charges
|
|
491
|
+
|
|
492
|
+
Manage bulk charge operations.
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
# Initiate bulk charge
|
|
496
|
+
paystack-cli bulkcharge:initiate --charges='[{"authorization":"AUTH_xxx","amount":10000}]'
|
|
497
|
+
|
|
498
|
+
# Fetch bulk charge
|
|
499
|
+
paystack-cli bulkcharge:fetch --code=BCH_xxx
|
|
500
|
+
|
|
501
|
+
# Fetch bulk charge charges
|
|
502
|
+
paystack-cli bulkcharge:fetch --code=BCH_xxx
|
|
503
|
+
|
|
504
|
+
# Pause bulk charge
|
|
505
|
+
paystack-cli bulkcharge:pause --code=BCH_xxx
|
|
506
|
+
|
|
507
|
+
# Resume bulk charge
|
|
508
|
+
paystack-cli bulkcharge:resume --code=BCH_xxx
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Refunds
|
|
512
|
+
|
|
513
|
+
Process refunds for transactions.
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
# Create refund
|
|
517
|
+
paystack-cli refund:create --transaction=TRX_xxx --amount=5000
|
|
518
|
+
|
|
519
|
+
# List refunds
|
|
520
|
+
paystack-cli refund:list --transaction=TRX_xxx
|
|
521
|
+
|
|
522
|
+
# Fetch refund
|
|
523
|
+
paystack-cli refund:fetch --code=RFD_xxx
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### Banks
|
|
527
|
+
|
|
528
|
+
Get bank information.
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
# List banks
|
|
532
|
+
paystack-cli bank:list --country=nigeria --use_cursor=true
|
|
533
|
+
|
|
534
|
+
# Resolve account number
|
|
535
|
+
paystack-cli bank:resolve --account_number=0123456789 --bank_code=033
|
|
536
|
+
|
|
537
|
+
# Resolve BVN
|
|
538
|
+
paystack-cli bank:resolve --bvn=12345678901
|
|
539
|
+
|
|
540
|
+
# Match BVN with account
|
|
541
|
+
paystack-cli bank:match --account_number=0123456789 --bank_code=033 --bvn=12345678901
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### Settlements
|
|
545
|
+
|
|
546
|
+
View settlement information.
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
# Fetch settlements
|
|
550
|
+
paystack-cli settlement:fetch --from=2024-01-01 --to=2024-12-31 --subaccount=ACCT_xxx
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
### Integration
|
|
554
|
+
|
|
555
|
+
Manage integration settings.
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
# Fetch payment session timeout
|
|
559
|
+
paystack-cli integration:fetch
|
|
560
|
+
|
|
561
|
+
# Update payment session timeout
|
|
562
|
+
paystack-cli integration:update --timeout=600
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### Balance
|
|
566
|
+
|
|
567
|
+
Check account balance.
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
# Check balance
|
|
571
|
+
paystack-cli balance:check
|
|
572
|
+
|
|
573
|
+
# View balance ledger
|
|
574
|
+
paystack-cli balance:balance
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Verifications
|
|
578
|
+
|
|
579
|
+
Verify customer information.
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# Resolve verification
|
|
583
|
+
paystack-cli verifications:resolve --verification_type=truecaller --phone=08012345678
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### Decision
|
|
587
|
+
|
|
588
|
+
Card information lookup.
|
|
589
|
+
|
|
590
|
+
```bash
|
|
591
|
+
# Resolve card BIN
|
|
592
|
+
paystack-cli decision:resolve --bin=123456
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### Invoices
|
|
596
|
+
|
|
597
|
+
Manage invoices.
|
|
598
|
+
|
|
599
|
+
```bash
|
|
600
|
+
# Archive invoice
|
|
601
|
+
paystack-cli invoice:archive --code=INV_xxx
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
## Configuration
|
|
605
|
+
|
|
606
|
+
The CLI stores configuration in a local database. Use the `config` command to modify settings:
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
paystack-cli config
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### Available Settings
|
|
613
|
+
|
|
614
|
+
1. **API Base URL**
|
|
615
|
+
- Default: `https://api.paystack.co`
|
|
616
|
+
- Change this to use a different Paystack API endpoint
|
|
617
|
+
|
|
618
|
+
2. **Timeout Duration**
|
|
619
|
+
- Default: `3000ms`
|
|
620
|
+
- HTTP request timeout in milliseconds
|
|
621
|
+
|
|
622
|
+
3. **Debug Mode**
|
|
623
|
+
- Default: `false`
|
|
624
|
+
- Enable to see detailed error messages and stack traces
|
|
625
|
+
|
|
626
|
+
4. **Ngrok Auth Token**
|
|
627
|
+
- Required for webhook testing
|
|
628
|
+
- Get your token from [ngrok.com](https://dashboard.ngrok.com/get-started/your-authtoken)
|
|
629
|
+
|
|
630
|
+
### Environment Variables
|
|
631
|
+
|
|
632
|
+
You can also set configuration via environment variables:
|
|
633
|
+
|
|
634
|
+
- `NGROK_AUTH_TOKEN`: Your ngrok authentication token
|
|
635
|
+
- `NGROK_DOMAIN`: Custom ngrok domain (if you have a paid plan)
|
|
636
|
+
|
|
637
|
+
## Webhook Testing
|
|
638
|
+
|
|
639
|
+
### Setting Up
|
|
640
|
+
|
|
641
|
+
1. **Configure ngrok token** (first time only):
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
paystack-cli config
|
|
645
|
+
# Select "Ngrok Auth Token" and enter your token
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
2. **Start webhook listener**:
|
|
649
|
+
```bash
|
|
650
|
+
paystack-cli webhook listen http://localhost:3000/webhook
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
The CLI will:
|
|
654
|
+
|
|
655
|
+
- Create an ngrok tunnel to your local server
|
|
656
|
+
- Update your Paystack webhook URL automatically
|
|
657
|
+
- Forward all webhook events to your local endpoint
|
|
658
|
+
|
|
659
|
+
### Testing Webhooks
|
|
660
|
+
|
|
661
|
+
Send test webhook events:
|
|
662
|
+
|
|
663
|
+
```bash
|
|
664
|
+
# Test successful charge
|
|
665
|
+
paystack-cli webhook ping --event=charge.success
|
|
666
|
+
|
|
667
|
+
# Test transfer events
|
|
668
|
+
paystack-cli webhook ping --event=transfer.success
|
|
669
|
+
paystack-cli webhook ping --event=transfer.failed
|
|
670
|
+
|
|
671
|
+
# Test subscription event
|
|
672
|
+
paystack-cli webhook ping --event=subscription.create
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### Available Events
|
|
676
|
+
|
|
677
|
+
- `charge.success` - Successful payment
|
|
678
|
+
- `transfer.success` - Successful transfer
|
|
679
|
+
- `transfer.failed` - Failed transfer
|
|
680
|
+
- `subscription.create` - New subscription created
|
|
681
|
+
|
|
682
|
+
## Examples
|
|
683
|
+
|
|
684
|
+
### Complete Transaction Flow
|
|
685
|
+
|
|
686
|
+
```bash
|
|
687
|
+
# 1. Initialize transaction
|
|
688
|
+
paystack-cli transaction:initialize \
|
|
689
|
+
--email=customer@example.com \
|
|
690
|
+
--amount=50000 \
|
|
691
|
+
--reference=ORDER_12345
|
|
692
|
+
|
|
693
|
+
# 2. After customer pays, verify transaction
|
|
694
|
+
paystack-cli transaction:verify --reference=ORDER_12345
|
|
695
|
+
|
|
696
|
+
# 3. View transaction details
|
|
697
|
+
paystack-cli transaction:view --id=123456
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
### Subscription Management
|
|
701
|
+
|
|
702
|
+
```bash
|
|
703
|
+
# 1. Create a plan
|
|
704
|
+
paystack-cli plan:create \
|
|
705
|
+
--name="Monthly Premium" \
|
|
706
|
+
--amount=50000 \
|
|
707
|
+
--interval=monthly
|
|
708
|
+
|
|
709
|
+
# 2. Create customer
|
|
710
|
+
paystack-cli customer:create \
|
|
711
|
+
--email=subscriber@example.com \
|
|
712
|
+
--first_name=John \
|
|
713
|
+
--last_name=Doe
|
|
714
|
+
|
|
715
|
+
# 3. Create subscription
|
|
716
|
+
paystack-cli subscription:create \
|
|
717
|
+
--customer=CUS_xxx \
|
|
718
|
+
--plan=PLN_xxx
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
### Transfer Workflow
|
|
722
|
+
|
|
723
|
+
```bash
|
|
724
|
+
# 1. Create transfer recipient
|
|
725
|
+
paystack-cli transferrecipient:create \
|
|
726
|
+
--type=nuban \
|
|
727
|
+
--name="Jane Doe" \
|
|
728
|
+
--account_number=0123456789 \
|
|
729
|
+
--bank_code=033
|
|
730
|
+
|
|
731
|
+
# 2. Initiate transfer
|
|
732
|
+
paystack-cli transfer:initiate \
|
|
733
|
+
--source=balance \
|
|
734
|
+
--amount=50000 \
|
|
735
|
+
--recipient=RCP_xxx \
|
|
736
|
+
--reason="Payment for services"
|
|
737
|
+
|
|
738
|
+
# 3. If OTP is required, finalize with OTP
|
|
739
|
+
paystack-cli transfer:finalize \
|
|
740
|
+
--transfer_code=TRF_xxx \
|
|
741
|
+
--otp=123456
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
## Development
|
|
745
|
+
|
|
746
|
+
### Prerequisites
|
|
747
|
+
|
|
748
|
+
- Node.js >= 18
|
|
749
|
+
- PNPM (recommended) or NPM
|
|
750
|
+
|
|
751
|
+
### Setup
|
|
752
|
+
|
|
753
|
+
```bash
|
|
754
|
+
# Clone repository
|
|
755
|
+
git clone https://github.com/toneflix/paystack-cli.git
|
|
756
|
+
cd paystack-cli
|
|
757
|
+
|
|
758
|
+
# Install dependencies
|
|
759
|
+
pnpm install
|
|
760
|
+
|
|
761
|
+
# Run in development mode
|
|
762
|
+
pnpm runner [command]
|
|
763
|
+
|
|
764
|
+
# Build
|
|
765
|
+
pnpm build
|
|
766
|
+
|
|
767
|
+
# Run tests
|
|
768
|
+
pnpm test
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Project Structure
|
|
772
|
+
|
|
773
|
+
```md
|
|
774
|
+
paystack-cli/
|
|
775
|
+
├── src/
|
|
776
|
+
│ ├── Commands/ # CLI command classes
|
|
777
|
+
│ │ ├── Commands.ts # Dynamic API command generator
|
|
778
|
+
│ │ ├── InitCommand.ts
|
|
779
|
+
│ │ ├── LoginCommand.ts
|
|
780
|
+
│ │ ├── LogoutCommand.ts
|
|
781
|
+
│ │ ├── ConfigCommand.ts
|
|
782
|
+
│ │ └── WebhookCommand.ts
|
|
783
|
+
│ ├── Contracts/ # TypeScript interfaces
|
|
784
|
+
│ ├── paystack/ # Paystack API definitions
|
|
785
|
+
│ │ ├── apis.ts # All API endpoint schemas
|
|
786
|
+
│ │ └── webhooks.ts # Webhook event handlers
|
|
787
|
+
│ ├── utils/ # Utility functions
|
|
788
|
+
│ ├── cli.ts # Application entry point
|
|
789
|
+
│ ├── db.ts # Local database management
|
|
790
|
+
│ ├── helpers.ts # Helper functions
|
|
791
|
+
│ ├── hooks.ts # Custom hooks
|
|
792
|
+
│ └── Paystack.ts # Paystack API client
|
|
793
|
+
├── bin/ # Executable files
|
|
794
|
+
├── tests/ # Test files
|
|
795
|
+
└── package.json
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
### Technology Stack
|
|
799
|
+
|
|
800
|
+
- **Framework**: [H3ravel Musket](https://github.com/h3ravel/musket) - CLI framework
|
|
801
|
+
- **Language**: TypeScript
|
|
802
|
+
- **Database**: SQLite (via better-sqlite3)
|
|
803
|
+
- **HTTP Client**: Axios
|
|
804
|
+
- **Tunneling**: ngrok
|
|
805
|
+
- **Build Tool**: tsdown
|
|
806
|
+
|
|
807
|
+
## Troubleshooting
|
|
808
|
+
|
|
809
|
+
### Common Issues
|
|
810
|
+
|
|
811
|
+
**1. "You're not signed in" error**
|
|
812
|
+
|
|
813
|
+
```bash
|
|
814
|
+
# Solution: Login first
|
|
815
|
+
paystack-cli login
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
**2. "Session expired" error**
|
|
819
|
+
|
|
820
|
+
```bash
|
|
821
|
+
# Solution: Login again
|
|
822
|
+
paystack-cli logout
|
|
823
|
+
paystack-cli login
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
**3. Webhook listener not working**
|
|
827
|
+
|
|
828
|
+
```bash
|
|
829
|
+
# Solution: Check ngrok token is configured
|
|
830
|
+
paystack-cli config
|
|
831
|
+
# Select "Ngrok Auth Token" and enter your token from ngrok.com
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
**4. Command not found**
|
|
835
|
+
|
|
836
|
+
```bash
|
|
837
|
+
# Solution: Ensure CLI is installed globally
|
|
838
|
+
npm install -g @toneflix/paystack-cli
|
|
839
|
+
# Or reinstall
|
|
840
|
+
npm uninstall -g @toneflix/paystack-cli
|
|
841
|
+
npm install -g @toneflix/paystack-cli
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
**5. Permission errors on macOS/Linux**
|
|
845
|
+
|
|
846
|
+
```bash
|
|
847
|
+
# Solution: Use sudo for global installation
|
|
848
|
+
sudo npm install -g @toneflix/paystack-cli
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
### Debug Mode
|
|
852
|
+
|
|
853
|
+
Enable debug mode to see detailed error information:
|
|
854
|
+
|
|
855
|
+
```bash
|
|
856
|
+
paystack-cli config
|
|
857
|
+
# Select "Debug Mode" and choose "true"
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
### Getting Help
|
|
861
|
+
|
|
862
|
+
For any command, you can get help by running:
|
|
863
|
+
|
|
864
|
+
```bash
|
|
865
|
+
paystack-cli [command] --help
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
Or visit the [Paystack API Documentation](https://paystack.com/docs/api/) for API-specific information.
|
|
869
|
+
|
|
870
|
+
## Contributing
|
|
871
|
+
|
|
872
|
+
Contributions are welcome! Please follow these steps:
|
|
873
|
+
|
|
874
|
+
1. Fork the repository
|
|
875
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
876
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
877
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
878
|
+
5. Open a Pull Request
|
|
879
|
+
|
|
880
|
+
### Development Guidelines
|
|
881
|
+
|
|
882
|
+
- Write TypeScript with proper type definitions
|
|
883
|
+
- Follow existing code style
|
|
884
|
+
- Add tests for new features
|
|
885
|
+
- Update documentation for API changes
|
|
886
|
+
- Ensure all tests pass before submitting PR
|
|
887
|
+
|
|
888
|
+
## License
|
|
889
|
+
|
|
890
|
+
This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
|
|
891
|
+
|
|
892
|
+
## Support
|
|
893
|
+
|
|
894
|
+
- Email: support@toneflix.net
|
|
895
|
+
- Issues: [GitHub Issues](https://github.com/toneflix/paystack-cli/issues)
|
|
896
|
+
- Docs: [Paystack Documentation](https://paystack.com/docs)
|
|
897
|
+
- Community: [Paystack Slack](https://paystack.com/slack)
|
|
898
|
+
|
|
899
|
+
## Acknowledgments
|
|
900
|
+
|
|
901
|
+
- Built with [H3ravel Musket](https://github.com/h3ravel/musket)
|
|
902
|
+
- Powered by [Paystack](https://paystack.com)
|
|
903
|
+
- Tunneling by [ngrok](https://ngrok.com)
|
|
904
|
+
|
|
905
|
+
---
|
|
906
|
+
|
|
907
|
+
**© Copyright 2026 - [ToneFlix Technologies Limited](https://toneflix.net)**
|