@paychainly/cli 1.1.0 → 1.1.2
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/README.md +149 -0
- package/package.json +1 -1
- package/src/listen.js +3 -2
- package/src/status.js +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @paychainly/cli
|
|
2
|
+
|
|
3
|
+
> Relay live Paychainly webhooks to your local server during development — no public URL needed.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@paychainly/cli)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @paychainly/cli
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
paychainly listen --api-key pk_live_... --forward-to http://localhost:3000/webhook
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Webhooks fired on [api.paychainly.com](https://api.paychainly.com) are forwarded in real time to your local server.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
### `listen` — relay live webhooks
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
paychainly listen [options]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Option | Description | Default |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `--api-key` | Your Paychainly API key (`pk_live_...` or `pk_test_...`) | `PAYCHAINLY_API_KEY` env |
|
|
39
|
+
| `--forward-to` | Full local URL to POST webhooks to | `http://localhost:3000/webhook` |
|
|
40
|
+
| `--port` | Shorthand for `--forward-to http://localhost:<port>/webhook` | `3000` |
|
|
41
|
+
| `--host` | Paychainly server URL | `https://api.paychainly.com` |
|
|
42
|
+
| `--secret` | Webhook secret — enables HMAC-SHA256 signature verification | — |
|
|
43
|
+
| `--verbose` | Pretty-print the full webhook payload (JSON) | off |
|
|
44
|
+
| `--filter` | Only relay events matching this name (e.g. `deposit_detected`) | all events |
|
|
45
|
+
| `--log` | Append every received event to a JSONL file for later replay | — |
|
|
46
|
+
|
|
47
|
+
**Examples**
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Basic
|
|
51
|
+
paychainly listen --api-key pk_live_... --port 3000
|
|
52
|
+
|
|
53
|
+
# Show full payload for every event
|
|
54
|
+
paychainly listen --api-key pk_live_... --verbose
|
|
55
|
+
|
|
56
|
+
# Only relay deposit events and save them to disk
|
|
57
|
+
paychainly listen --api-key pk_live_... \
|
|
58
|
+
--filter deposit_detected \
|
|
59
|
+
--log deposits.jsonl
|
|
60
|
+
|
|
61
|
+
# Verify webhook signatures
|
|
62
|
+
paychainly listen --api-key pk_live_... --secret whsec_...
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### `status` — check API key & connectivity
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
paychainly status --api-key pk_live_...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Connects to the server, validates the key, and prints the user ID and account mode. Useful for confirming your key is correct before starting a session.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### `replay` — resend saved events to your local server
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
paychainly replay --log events.jsonl [options]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
| Option | Description | Default |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `--log` | JSONL file produced by `listen --log` **(required)** | — |
|
|
86
|
+
| `--forward-to` | Local URL to POST events to | `http://localhost:3000/webhook` |
|
|
87
|
+
| `--port` | Shorthand for `--forward-to http://localhost:<port>/webhook` | `3000` |
|
|
88
|
+
| `--filter` | Only replay events matching this name | all events |
|
|
89
|
+
| `--delay` | Milliseconds between replayed events | `500` |
|
|
90
|
+
| `--verbose` | Pretty-print each payload before sending | off |
|
|
91
|
+
|
|
92
|
+
**Examples**
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Replay everything
|
|
96
|
+
paychainly replay --log events.jsonl
|
|
97
|
+
|
|
98
|
+
# Replay only deposit events with a 1-second gap, show payloads
|
|
99
|
+
paychainly replay --log events.jsonl \
|
|
100
|
+
--filter deposit_detected \
|
|
101
|
+
--delay 1000 \
|
|
102
|
+
--verbose
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Typical Developer Workflow
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. Start listening and capture events to a file
|
|
111
|
+
paychainly listen --api-key pk_live_... --log events.jsonl --verbose
|
|
112
|
+
|
|
113
|
+
# 2. Trigger a test payment on your dashboard
|
|
114
|
+
# 3. Inspect your webhook handler logs
|
|
115
|
+
|
|
116
|
+
# 4. Fix a bug in your handler, restart your server
|
|
117
|
+
|
|
118
|
+
# 5. Replay the captured events — no real payment needed
|
|
119
|
+
paychainly replay --log events.jsonl --filter deposit_detected
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Environment Variables
|
|
125
|
+
|
|
126
|
+
You can set these instead of passing flags every time:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
export PAYCHAINLY_API_KEY=pk_live_...
|
|
130
|
+
export PAYCHAINLY_HOST=https://api.paychainly.com # optional override
|
|
131
|
+
export PAYCHAINLY_WEBHOOK_SECRET=whsec_... # optional
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Webhook Events
|
|
137
|
+
|
|
138
|
+
| Event | Description |
|
|
139
|
+
|---|---|
|
|
140
|
+
| `deposit_detected` | A USDT transfer to a monitored deposit address was confirmed |
|
|
141
|
+
| `sweep_completed` | Funds swept from deposit address to master wallet |
|
|
142
|
+
| `address_expired` | A deposit address session expired without a payment |
|
|
143
|
+
| `withdrawal_completed` | A user-initiated withdrawal was processed |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT © [Paychainly](https://paychainly.com)
|
package/package.json
CHANGED
package/src/listen.js
CHANGED
|
@@ -141,9 +141,10 @@ ${c.bold}${c.cyan} ╔═══════════════════
|
|
|
141
141
|
reconnectionAttempts: Infinity,
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
socket.on('relay_connected', ({ userId, mode }) => {
|
|
144
|
+
socket.on('relay_connected', ({ userId, email, mode }) => {
|
|
145
145
|
connected = true;
|
|
146
|
-
|
|
146
|
+
const identity = email || `userId: ${userId}`;
|
|
147
|
+
console.log(` ${c.green}✓ Connected${c.reset} ${c.gray}(${identity}, mode: ${mode})${c.reset}`);
|
|
147
148
|
console.log(` ${c.gray}Waiting for webhooks... (Ctrl+C to stop)${c.reset}\n`);
|
|
148
149
|
});
|
|
149
150
|
|
package/src/status.js
CHANGED
|
@@ -41,9 +41,10 @@ module.exports = function status(argv) {
|
|
|
41
41
|
timeout: 10000,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
socket.on('relay_connected', ({ userId, mode }) => {
|
|
44
|
+
socket.on('relay_connected', ({ userId, email, mode }) => {
|
|
45
45
|
process.stdout.write(' '.repeat(40) + '\r');
|
|
46
46
|
console.log(` ${c.green}✓ API key valid${c.reset}`);
|
|
47
|
+
if (email) console.log(` ${c.gray}Email :${c.reset} ${email}`);
|
|
47
48
|
console.log(` ${c.gray}User ID :${c.reset} ${userId}`);
|
|
48
49
|
console.log(` ${c.gray}Mode :${c.reset} ${mode}\n`);
|
|
49
50
|
socket.disconnect();
|