@ktmcp-cli/nowpayments 1.0.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/.env.example +17 -0
- package/AGENT.md +513 -0
- package/INSTALL.md +392 -0
- package/LICENSE +21 -0
- package/OPENCLAW.md +628 -0
- package/PROJECT_SUMMARY.md +305 -0
- package/README.md +375 -0
- package/banner.png +0 -0
- package/bin/nowpayments.js +89 -0
- package/examples/basic-payment.js +66 -0
- package/examples/invoice-flow.js +78 -0
- package/examples/monitor-payment.js +94 -0
- package/logo.png +0 -0
- package/openapi.json +2791 -0
- package/package.json +40 -0
- package/src/commands/auth.js +65 -0
- package/src/commands/currencies.js +95 -0
- package/src/commands/estimate.js +85 -0
- package/src/commands/invoice.js +188 -0
- package/src/commands/payment.js +241 -0
- package/src/commands/payout.js +184 -0
- package/src/commands/status.js +28 -0
- package/src/lib/api.js +133 -0
- package/src/lib/auth.js +70 -0
- package/src/lib/config.js +110 -0
- package/test.sh +250 -0
package/INSTALL.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Installation and Quick Start Guide
|
|
2
|
+
|
|
3
|
+
Complete installation and setup instructions for the NOWPayments CLI.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js >= 16.0.0
|
|
8
|
+
- npm or yarn
|
|
9
|
+
- NOWPayments account and API key
|
|
10
|
+
|
|
11
|
+
## Installation Options
|
|
12
|
+
|
|
13
|
+
### Option 1: Install Globally (Recommended)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @ktmcp-cli/nowpayments
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
After installation, the `nowpayments` command will be available globally.
|
|
20
|
+
|
|
21
|
+
### Option 2: Install Locally
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Clone or download the CLI
|
|
25
|
+
cd ktmcp-nowpayments-cli
|
|
26
|
+
|
|
27
|
+
# Install dependencies
|
|
28
|
+
npm install
|
|
29
|
+
|
|
30
|
+
# Link for global use
|
|
31
|
+
npm link
|
|
32
|
+
|
|
33
|
+
# Or use directly
|
|
34
|
+
node bin/nowpayments.js --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Option 3: Use with npx
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx @ktmcp-cli/nowpayments status
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Getting Your API Key
|
|
44
|
+
|
|
45
|
+
1. Sign up at [NOWPayments.io](https://nowpayments.io)
|
|
46
|
+
2. Complete email verification
|
|
47
|
+
3. Set up your outcome wallet (where you'll receive payments)
|
|
48
|
+
4. Navigate to Settings > API
|
|
49
|
+
5. Generate a new API key
|
|
50
|
+
6. Copy and save the API key securely
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
### Method 1: Save to Config File (Recommended)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
nowpayments auth set YOUR_API_KEY
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This saves the API key to `~/.nowpayments/config.json`.
|
|
61
|
+
|
|
62
|
+
### Method 2: Environment Variable
|
|
63
|
+
|
|
64
|
+
Create a `.env` file in your project:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
cp .env.example .env
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Edit `.env`:
|
|
71
|
+
|
|
72
|
+
```env
|
|
73
|
+
NOWPAYMENTS_API_KEY=your_actual_api_key
|
|
74
|
+
NOWPAYMENTS_SANDBOX=false
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Method 3: Command Line Flag
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
nowpayments --api-key YOUR_API_KEY status
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Method 4: Export to Shell
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
export NOWPAYMENTS_API_KEY=your_api_key
|
|
87
|
+
nowpayments status
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Verify Installation
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Check version
|
|
94
|
+
nowpayments --version
|
|
95
|
+
|
|
96
|
+
# Test API connection
|
|
97
|
+
nowpayments status
|
|
98
|
+
|
|
99
|
+
# View help
|
|
100
|
+
nowpayments --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Expected output:
|
|
104
|
+
```
|
|
105
|
+
✓ NOWPayments API is OK
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## First Steps
|
|
109
|
+
|
|
110
|
+
### 1. List Available Currencies
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
nowpayments currencies list --available
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2. Get a Price Estimate
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
nowpayments estimate convert --from USD --to BTC --amount 100
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 3. Create Your First Payment
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
nowpayments payment create \
|
|
126
|
+
--price 10 \
|
|
127
|
+
--currency USD \
|
|
128
|
+
--pay-currency BTC \
|
|
129
|
+
--order-id "TEST-001" \
|
|
130
|
+
--order-description "Test payment"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 4. Check Payment Status
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Replace with your actual payment ID
|
|
137
|
+
nowpayments payment get <payment_id>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Testing with Sandbox
|
|
141
|
+
|
|
142
|
+
NOWPayments provides a sandbox environment for testing:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Use sandbox for all commands
|
|
146
|
+
nowpayments --sandbox status
|
|
147
|
+
nowpayments --sandbox payment create --price 10 --currency USD --pay-currency BTC
|
|
148
|
+
|
|
149
|
+
# Or set in .env
|
|
150
|
+
NOWPAYMENTS_SANDBOX=true
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Note:** You'll need a separate sandbox API key from the NOWPayments dashboard.
|
|
154
|
+
|
|
155
|
+
## Running Examples
|
|
156
|
+
|
|
157
|
+
The CLI includes example scripts demonstrating common workflows:
|
|
158
|
+
|
|
159
|
+
### Basic Payment Example
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
cd examples
|
|
163
|
+
node basic-payment.js
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
This creates a simple payment and displays the details.
|
|
167
|
+
|
|
168
|
+
### Monitor Payment Example
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# First create a payment, then monitor it
|
|
172
|
+
payment_id=$(nowpayments --json payment create --price 10 --currency USD --pay-currency BTC | jq -r '.payment_id')
|
|
173
|
+
|
|
174
|
+
# Monitor until completion
|
|
175
|
+
node examples/monitor-payment.js "$payment_id"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Invoice Flow Example
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
node examples/invoice-flow.js
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This creates an invoice and demonstrates the invoice workflow.
|
|
185
|
+
|
|
186
|
+
## Troubleshooting
|
|
187
|
+
|
|
188
|
+
### "No API key found"
|
|
189
|
+
|
|
190
|
+
**Problem:** CLI cannot find your API key.
|
|
191
|
+
|
|
192
|
+
**Solutions:**
|
|
193
|
+
1. Run `nowpayments auth set YOUR_KEY`
|
|
194
|
+
2. Check `.env` file exists and has correct key
|
|
195
|
+
3. Verify environment variable: `echo $NOWPAYMENTS_API_KEY`
|
|
196
|
+
|
|
197
|
+
### "API Error (401): Unauthorized"
|
|
198
|
+
|
|
199
|
+
**Problem:** Invalid or expired API key.
|
|
200
|
+
|
|
201
|
+
**Solutions:**
|
|
202
|
+
1. Verify API key is correct
|
|
203
|
+
2. Generate a new API key in NOWPayments dashboard
|
|
204
|
+
3. Check you're using production key for production API (not sandbox)
|
|
205
|
+
|
|
206
|
+
### "Network error: Unable to reach NOWPayments API"
|
|
207
|
+
|
|
208
|
+
**Problem:** Network connectivity issues.
|
|
209
|
+
|
|
210
|
+
**Solutions:**
|
|
211
|
+
1. Check internet connection
|
|
212
|
+
2. Verify firewall settings
|
|
213
|
+
3. Try with `--debug` flag for more details
|
|
214
|
+
4. Check NOWPayments API status: https://status.nowpayments.io
|
|
215
|
+
|
|
216
|
+
### "Command not found: nowpayments"
|
|
217
|
+
|
|
218
|
+
**Problem:** CLI not in PATH.
|
|
219
|
+
|
|
220
|
+
**Solutions:**
|
|
221
|
+
1. Run `npm link` in CLI directory
|
|
222
|
+
2. Install globally: `npm install -g .`
|
|
223
|
+
3. Use full path: `node /path/to/bin/nowpayments.js`
|
|
224
|
+
|
|
225
|
+
### Permission Denied
|
|
226
|
+
|
|
227
|
+
**Problem:** Binary not executable.
|
|
228
|
+
|
|
229
|
+
**Solution:**
|
|
230
|
+
```bash
|
|
231
|
+
chmod +x bin/nowpayments.js
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Advanced Configuration
|
|
235
|
+
|
|
236
|
+
### Custom Config Location
|
|
237
|
+
|
|
238
|
+
You can use a custom config file:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# The CLI looks for config at:
|
|
242
|
+
~/.nowpayments/config.json
|
|
243
|
+
|
|
244
|
+
# Example config structure:
|
|
245
|
+
{
|
|
246
|
+
"apiKey": "your_key",
|
|
247
|
+
"sandbox": false,
|
|
248
|
+
"defaultCurrency": "USD",
|
|
249
|
+
"defaultPayCurrency": "BTC"
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Debug Mode
|
|
254
|
+
|
|
255
|
+
Enable debug logging to see detailed API requests and responses:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
nowpayments --debug payment create --price 10 --currency USD --pay-currency BTC
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Output includes:
|
|
262
|
+
- API endpoints being called
|
|
263
|
+
- Request payloads
|
|
264
|
+
- Response data
|
|
265
|
+
- HTTP status codes
|
|
266
|
+
|
|
267
|
+
### JSON Output Mode
|
|
268
|
+
|
|
269
|
+
For scripting and automation, use JSON output:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# All commands support --json flag
|
|
273
|
+
nowpayments --json status
|
|
274
|
+
nowpayments --json payment list
|
|
275
|
+
nowpayments --json currencies list --available
|
|
276
|
+
|
|
277
|
+
# Parse with jq
|
|
278
|
+
nowpayments --json payment get <id> | jq '.payment_status'
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Integration Patterns
|
|
282
|
+
|
|
283
|
+
### Shell Scripts
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
#!/bin/bash
|
|
287
|
+
# create-payment.sh
|
|
288
|
+
|
|
289
|
+
PRICE=$1
|
|
290
|
+
CURRENCY=$2
|
|
291
|
+
|
|
292
|
+
if [ -z "$PRICE" ] || [ -z "$CURRENCY" ]; then
|
|
293
|
+
echo "Usage: ./create-payment.sh <price> <currency>"
|
|
294
|
+
exit 1
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
result=$(nowpayments --json payment create \
|
|
298
|
+
--price "$PRICE" \
|
|
299
|
+
--currency USD \
|
|
300
|
+
--pay-currency "$CURRENCY")
|
|
301
|
+
|
|
302
|
+
payment_id=$(echo "$result" | jq -r '.payment_id')
|
|
303
|
+
pay_address=$(echo "$result" | jq -r '.pay_address')
|
|
304
|
+
|
|
305
|
+
echo "Payment created!"
|
|
306
|
+
echo "ID: $payment_id"
|
|
307
|
+
echo "Address: $pay_address"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Node.js
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
const { exec } = require('child_process');
|
|
314
|
+
const util = require('util');
|
|
315
|
+
|
|
316
|
+
const execPromise = util.promisify(exec);
|
|
317
|
+
|
|
318
|
+
async function createPayment(amount, currency) {
|
|
319
|
+
const result = await execPromise(
|
|
320
|
+
`nowpayments --json payment create --price ${amount} --currency USD --pay-currency ${currency}`
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
return JSON.parse(result.stdout);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
createPayment(100, 'BTC').then(payment => {
|
|
327
|
+
console.log('Payment created:', payment.payment_id);
|
|
328
|
+
});
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Python
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
import subprocess
|
|
335
|
+
import json
|
|
336
|
+
|
|
337
|
+
def create_payment(amount, currency):
|
|
338
|
+
result = subprocess.run([
|
|
339
|
+
'nowpayments', '--json', 'payment', 'create',
|
|
340
|
+
'--price', str(amount),
|
|
341
|
+
'--currency', 'USD',
|
|
342
|
+
'--pay-currency', currency
|
|
343
|
+
], capture_output=True, text=True)
|
|
344
|
+
|
|
345
|
+
return json.loads(result.stdout)
|
|
346
|
+
|
|
347
|
+
payment = create_payment(100, 'BTC')
|
|
348
|
+
print(f"Payment created: {payment['payment_id']}")
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Next Steps
|
|
352
|
+
|
|
353
|
+
1. Read the [README.md](./README.md) for full command reference
|
|
354
|
+
2. Review [AGENT.md](./AGENT.md) for AI agent integration patterns
|
|
355
|
+
3. Check [OPENCLAW.md](./OPENCLAW.md) for OpenClaw framework integration
|
|
356
|
+
4. Explore example scripts in `examples/` directory
|
|
357
|
+
5. Review NOWPayments API documentation: https://documenter.getpostman.com/view/7907941/S1a32n38
|
|
358
|
+
|
|
359
|
+
## Getting Help
|
|
360
|
+
|
|
361
|
+
- CLI Help: `nowpayments --help`
|
|
362
|
+
- Command Help: `nowpayments <command> --help`
|
|
363
|
+
- NOWPayments Docs: https://nowpayments.io/help
|
|
364
|
+
- API Status: https://status.nowpayments.io
|
|
365
|
+
- Support: support@nowpayments.io
|
|
366
|
+
|
|
367
|
+
## Upgrading
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
# Global installation
|
|
371
|
+
npm update -g @ktmcp-cli/nowpayments
|
|
372
|
+
|
|
373
|
+
# Local installation
|
|
374
|
+
cd ktmcp-nowpayments-cli
|
|
375
|
+
git pull
|
|
376
|
+
npm install
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## Uninstalling
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Global installation
|
|
383
|
+
npm uninstall -g @ktmcp-cli/nowpayments
|
|
384
|
+
|
|
385
|
+
# Local installation
|
|
386
|
+
npm unlink
|
|
387
|
+
rm -rf ~/.nowpayments # Remove config (optional)
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
You're now ready to accept cryptocurrency payments from the command line!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 KTMCP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|