@ktmcp-cli/nowpayments 1.0.0 → 1.0.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.
@@ -1,305 +0,0 @@
1
- # NOWPayments CLI - Project Summary
2
-
3
- Production-ready Commander.js CLI for NOWPayments cryptocurrency payment processing API.
4
-
5
- ## Project Location
6
-
7
- ```
8
- /workspace/group/ktmcp/workspace/nowpayments/
9
- ```
10
-
11
- ## Project Structure
12
-
13
- ```
14
- nowpayments/
15
- ├── bin/
16
- │ └── nowpayments.js # CLI entry point
17
- ├── src/
18
- │ ├── commands/ # Command implementations
19
- │ │ ├── auth.js # API key management
20
- │ │ ├── status.js # API status check
21
- │ │ ├── currencies.js # Currency operations
22
- │ │ ├── estimate.js # Price estimation
23
- │ │ ├── payment.js # Payment management
24
- │ │ ├── invoice.js # Invoice management
25
- │ │ └── payout.js # Payout/withdrawal operations
26
- │ └── lib/ # Core libraries
27
- │ ├── api.js # API client with error handling
28
- │ ├── auth.js # Authentication utilities
29
- │ └── config.js # Configuration management
30
- ├── examples/ # Usage examples
31
- │ ├── basic-payment.js # Simple payment creation
32
- │ ├── monitor-payment.js # Payment status monitoring
33
- │ └── invoice-flow.js # Invoice workflow
34
- ├── README.md # Main documentation
35
- ├── AGENT.md # AI agent integration guide
36
- ├── OPENCLAW.md # OpenClaw framework integration
37
- ├── INSTALL.md # Installation and setup guide
38
- ├── package.json # NPM package configuration
39
- ├── openapi.json # NOWPayments API specification
40
- ├── .env.example # Environment configuration template
41
- ├── .gitignore # Git ignore rules
42
- ├── LICENSE # MIT license
43
- └── test.sh # Test suite
44
- ```
45
-
46
- ## Features Implemented
47
-
48
- ### Core Functionality
49
- - ✅ Full NOWPayments API coverage (payments, invoices, payouts, currencies, estimates)
50
- - ✅ Authentication management (API key storage and validation)
51
- - ✅ Rich terminal output with colors and tables
52
- - ✅ JSON output mode for scripting
53
- - ✅ Sandbox environment support
54
- - ✅ Global and command-specific options
55
- - ✅ Comprehensive error handling
56
- - ✅ Debug logging mode
57
-
58
- ### Commands Implemented
59
-
60
- 1. **auth** - API key management
61
- - `auth set` - Save API key
62
- - `auth show` - Display current key (masked)
63
- - `auth clear` - Remove API key
64
-
65
- 2. **status** - Check API availability
66
-
67
- 3. **currencies** - Cryptocurrency operations
68
- - `currencies list` - List all currencies
69
- - `currencies info` - Get currency details
70
-
71
- 4. **estimate** - Price calculations
72
- - `estimate convert` - Estimate cryptocurrency amount
73
- - `estimate min` - Get minimum payment amount
74
-
75
- 5. **payment** - Payment management
76
- - `payment create` - Create new payment
77
- - `payment get` - Get payment details
78
- - `payment list` - List all payments
79
- - `payment update-estimate` - Update price estimate
80
-
81
- 6. **invoice** - Invoice management
82
- - `invoice create` - Create new invoice
83
- - `invoice get` - Get invoice details
84
- - `invoice list` - List all invoices
85
-
86
- 7. **payout** - Withdrawal operations
87
- - `payout create` - Create new payout
88
- - `payout verify` - Verify payout with 2FA
89
- - `payout get` - Get payout details
90
- - `payout list` - List all payouts
91
-
92
- ### Documentation
93
-
94
- 1. **README.md** - Comprehensive user guide
95
- - "Why CLI > MCP" section explaining advantages
96
- - Full command reference
97
- - Usage examples
98
- - Payment flow documentation
99
- - Error handling guide
100
-
101
- 2. **AGENT.md** - AI agent integration patterns
102
- - JSON output mode usage
103
- - Error handling strategies
104
- - Common workflows
105
- - Polling patterns
106
- - Security considerations
107
-
108
- 3. **OPENCLAW.md** - OpenClaw framework integration
109
- - Skill definition
110
- - Event handling
111
- - Webhook integration
112
- - Multi-agent coordination
113
- - Advanced patterns
114
-
115
- 4. **INSTALL.md** - Installation and setup
116
- - Multiple installation methods
117
- - API key configuration
118
- - Troubleshooting guide
119
- - Integration examples
120
-
121
- ### Examples
122
-
123
- 1. **basic-payment.js** - Simple payment creation workflow
124
- 2. **monitor-payment.js** - Payment status monitoring with polling
125
- 3. **invoice-flow.js** - Complete invoice generation and management
126
-
127
- ## Technical Details
128
-
129
- ### Dependencies
130
- - **commander**: ^12.0.0 - CLI framework
131
- - **chalk**: ^4.1.2 - Terminal colors
132
- - **ora**: ^5.4.1 - Spinners
133
- - **dotenv**: ^16.4.1 - Environment variables
134
- - **node-fetch**: ^2.7.0 - HTTP requests
135
- - **cli-table3**: ^0.6.3 - Terminal tables
136
-
137
- ### Architecture
138
-
139
- - **Modular design**: Separate command files for maintainability
140
- - **Library abstraction**: Core functionality in reusable libraries
141
- - **Error handling**: Comprehensive error catching and user-friendly messages
142
- - **Exit codes**: Proper POSIX exit codes (0 = success, 1 = error)
143
- - **Configuration layers**: API key from config file, env var, or CLI flag
144
- - **JSON mode**: Structured output for scripting and automation
145
-
146
- ### Code Quality
147
-
148
- - ✅ JSDoc comments throughout
149
- - ✅ Consistent code style
150
- - ✅ Input validation
151
- - ✅ Proper error propagation
152
- - ✅ No hardcoded values
153
- - ✅ Environment-aware (sandbox/production)
154
-
155
- ## API Coverage
156
-
157
- Based on NOWPayments OpenAPI spec (v1.0.0):
158
-
159
- - ✅ GET /v1/status
160
- - ✅ GET /v1/currencies
161
- - ✅ GET /v1/merchant/coins
162
- - ✅ GET /v1/estimate
163
- - ✅ GET /v1/min-amount
164
- - ✅ POST /v1/payment
165
- - ✅ GET /v1/payment
166
- - ✅ GET /v1/payment/{payment_id}
167
- - ✅ POST /v1/payment/{id}/update-merchant-estimate
168
- - ✅ POST /v1/invoice
169
- - ✅ GET /v1/invoice
170
- - ✅ GET /v1/invoice/{invoice_id}
171
- - ✅ POST /v1/payout
172
- - ✅ GET /v1/payout/{payout_id}
173
- - ✅ POST /v1/payout/{payout_id}/verify
174
- - ✅ GET /v1/payout
175
-
176
- ## Installation Steps
177
-
178
- 1. **Install dependencies**:
179
- ```bash
180
- cd /workspace/group/ktmcp/workspace/nowpayments
181
- npm install
182
- ```
183
-
184
- 2. **Test the CLI**:
185
- ```bash
186
- ./test.sh
187
- ```
188
-
189
- 3. **Link for global use** (optional):
190
- ```bash
191
- npm link
192
- ```
193
-
194
- 4. **Configure API key**:
195
- ```bash
196
- nowpayments auth set YOUR_API_KEY
197
- ```
198
-
199
- 5. **Verify**:
200
- ```bash
201
- nowpayments status
202
- ```
203
-
204
- ## Usage Examples
205
-
206
- ### Basic Payment
207
- ```bash
208
- nowpayments payment create \
209
- --price 99.99 \
210
- --currency USD \
211
- --pay-currency BTC
212
- ```
213
-
214
- ### JSON Output for Scripting
215
- ```bash
216
- payment=$(nowpayments --json payment create --price 100 --currency USD --pay-currency BTC)
217
- payment_id=$(echo "$payment" | jq -r '.payment_id')
218
- echo "Created payment: $payment_id"
219
- ```
220
-
221
- ### List Currencies
222
- ```bash
223
- nowpayments currencies list --available
224
- ```
225
-
226
- ### Monitor Payment
227
- ```bash
228
- node examples/monitor-payment.js <payment_id>
229
- ```
230
-
231
- ## Testing
232
-
233
- Run the test suite:
234
- ```bash
235
- cd /workspace/group/ktmcp/workspace/nowpayments
236
- ./test.sh
237
- ```
238
-
239
- Tests verify:
240
- - CLI structure and entry points
241
- - All commands registered
242
- - Required dependencies
243
- - Documentation completeness
244
- - Example files
245
- - File permissions
246
-
247
- ## Why This Implementation is Superior
248
-
249
- ### 1. CLI vs MCP
250
- - **Universal compatibility**: Works with any tool or AI
251
- - **No server overhead**: Direct execution, no daemon
252
- - **Battle-tested pattern**: CLI is proven, reliable
253
- - **Simpler debugging**: Standard stdout/stderr
254
- - **Better for automation**: Shell scripts, cron jobs, CI/CD
255
-
256
- ### 2. Architecture Benefits
257
- - **Modular commands**: Each command is self-contained
258
- - **Shared libraries**: DRY principle with lib/
259
- - **Layered config**: Flexible API key sources
260
- - **Proper error handling**: User-friendly messages, correct exit codes
261
- - **Rich output**: Both human-readable and machine-parseable
262
-
263
- ### 3. Production Ready
264
- - ✅ Input validation
265
- - ✅ Error recovery
266
- - ✅ Debug mode
267
- - ✅ Environment detection (sandbox/production)
268
- - ✅ Comprehensive documentation
269
- - ✅ Working examples
270
- - ✅ Test suite
271
-
272
- ## Next Steps
273
-
274
- 1. **Publish to NPM** (optional):
275
- ```bash
276
- npm publish
277
- ```
278
-
279
- 2. **Add to AI agent tools**: Use patterns from AGENT.md
280
-
281
- 3. **Integrate with OpenClaw**: Follow OPENCLAW.md guide
282
-
283
- 4. **Extend functionality**:
284
- - Add webhook verification utility
285
- - Create payment monitoring daemon
286
- - Build subscription management
287
- - Add bulk operations
288
-
289
- ## Support
290
-
291
- - **API Docs**: https://documenter.getpostman.com/view/7907941/S1a32n38
292
- - **NOWPayments**: https://nowpayments.io
293
- - **CLI Help**: `nowpayments --help`
294
-
295
- ## License
296
-
297
- MIT License - See LICENSE file
298
-
299
- ---
300
-
301
- **Status**: ✅ Complete and production-ready
302
-
303
- **Created**: 2024
304
- **Package**: @ktmcp-cli/nowpayments
305
- **Version**: 1.0.0
package/banner.png DELETED
Binary file
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Basic Payment Example
5
- *
6
- * Demonstrates creating a simple cryptocurrency payment with NOWPayments CLI.
7
- */
8
-
9
- const { exec } = require('child_process');
10
- const util = require('util');
11
-
12
- const execPromise = util.promisify(exec);
13
-
14
- async function createBasicPayment() {
15
- console.log('Creating a basic payment...\n');
16
-
17
- try {
18
- // Step 1: Check API status
19
- console.log('1. Checking API status...');
20
- await execPromise('nowpayments status');
21
- console.log(' ✓ API is online\n');
22
-
23
- // Step 2: Get estimate
24
- console.log('2. Getting price estimate...');
25
- const estimateResult = await execPromise(
26
- 'nowpayments --json estimate convert --from USD --to BTC --amount 100'
27
- );
28
- const estimate = JSON.parse(estimateResult.stdout);
29
- console.log(` ✓ $100 USD ≈ ${estimate.estimated_amount} BTC\n`);
30
-
31
- // Step 3: Create payment
32
- console.log('3. Creating payment...');
33
- const paymentResult = await execPromise(`
34
- nowpayments --json payment create \
35
- --price 100 \
36
- --currency USD \
37
- --pay-currency BTC \
38
- --order-id "DEMO-${Date.now()}" \
39
- --order-description "Basic payment example"
40
- `);
41
- const payment = JSON.parse(paymentResult.stdout);
42
-
43
- console.log(' ✓ Payment created successfully!\n');
44
- console.log('Payment Details:');
45
- console.log(` Payment ID: ${payment.payment_id}`);
46
- console.log(` Status: ${payment.payment_status}`);
47
- console.log(` Pay Amount: ${payment.pay_amount} ${payment.pay_currency}`);
48
- console.log(` Pay Address: ${payment.pay_address}`);
49
- console.log(` Created: ${new Date(payment.created_at).toLocaleString()}\n`);
50
-
51
- // Step 4: Check payment status
52
- console.log('4. Checking payment status...');
53
- const statusResult = await execPromise(
54
- `nowpayments --json payment get ${payment.payment_id}`
55
- );
56
- const status = JSON.parse(statusResult.stdout);
57
- console.log(` Status: ${status.payment_status}`);
58
-
59
- } catch (error) {
60
- console.error('Error:', error.message);
61
- process.exit(1);
62
- }
63
- }
64
-
65
- // Run the example
66
- createBasicPayment();
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Invoice Flow Example
5
- *
6
- * Demonstrates creating and managing payment invoices.
7
- */
8
-
9
- const { exec } = require('child_process');
10
- const util = require('util');
11
-
12
- const execPromise = util.promisify(exec);
13
-
14
- async function createInvoiceFlow() {
15
- console.log('Creating payment invoice...\n');
16
-
17
- try {
18
- // Step 1: Create invoice
19
- console.log('1. Creating invoice...');
20
- const invoiceResult = await execPromise(`
21
- nowpayments --json invoice create \
22
- --price 49.99 \
23
- --currency USD \
24
- --order-id "INV-${Date.now()}" \
25
- --order-description "Premium subscription" \
26
- --success-url "https://example.com/success" \
27
- --cancel-url "https://example.com/cancel"
28
- `);
29
- const invoice = JSON.parse(invoiceResult.stdout);
30
-
31
- console.log(' ✓ Invoice created!\n');
32
- console.log('Invoice Details:');
33
- console.log(` Invoice ID: ${invoice.id}`);
34
- console.log(` Status: ${invoice.invoice_status}`);
35
- console.log(` Amount: $${invoice.price_amount} ${invoice.price_currency}`);
36
- console.log(` Invoice URL: ${invoice.invoice_url}`);
37
- console.log(` Created: ${new Date(invoice.created_at).toLocaleString()}\n`);
38
-
39
- console.log('Share this URL with your customer:');
40
- console.log(` ${invoice.invoice_url}\n`);
41
-
42
- // Step 2: Check invoice status
43
- console.log('2. Checking invoice status...');
44
- const statusResult = await execPromise(
45
- `nowpayments --json invoice get ${invoice.id}`
46
- );
47
- const status = JSON.parse(statusResult.stdout);
48
-
49
- console.log(` Status: ${status.invoice_status}`);
50
-
51
- if (status.payment_id) {
52
- console.log(` Payment ID: ${status.payment_id}`);
53
- }
54
-
55
- // Step 3: List recent invoices
56
- console.log('\n3. Listing recent invoices...');
57
- const listResult = await execPromise(
58
- 'nowpayments --json invoice list --limit 5'
59
- );
60
- const list = JSON.parse(listResult.stdout);
61
-
62
- console.log(` Found ${list.data.length} invoices:\n`);
63
- list.data.forEach((inv, i) => {
64
- console.log(` ${i + 1}. ${inv.id}`);
65
- console.log(` Status: ${inv.invoice_status}`);
66
- console.log(` Amount: $${inv.price_amount}`);
67
- console.log(` Created: ${new Date(inv.created_at).toLocaleString()}`);
68
- console.log('');
69
- });
70
-
71
- } catch (error) {
72
- console.error('Error:', error.message);
73
- process.exit(1);
74
- }
75
- }
76
-
77
- // Run the example
78
- createInvoiceFlow();
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Payment Monitoring Example
5
- *
6
- * Demonstrates monitoring a payment until completion or timeout.
7
- */
8
-
9
- const { exec } = require('child_process');
10
- const util = require('util');
11
-
12
- const execPromise = util.promisify(exec);
13
-
14
- // Configuration
15
- const CHECK_INTERVAL = 30000; // 30 seconds
16
- const MAX_DURATION = 30 * 60 * 1000; // 30 minutes
17
-
18
- async function monitorPayment(paymentId) {
19
- const startTime = Date.now();
20
-
21
- console.log(`Monitoring payment: ${paymentId}`);
22
- console.log(`Check interval: ${CHECK_INTERVAL / 1000}s`);
23
- console.log(`Max duration: ${MAX_DURATION / 60000} minutes\n`);
24
-
25
- while (Date.now() - startTime < MAX_DURATION) {
26
- try {
27
- // Check payment status
28
- const result = await execPromise(
29
- `nowpayments --json payment get ${paymentId}`
30
- );
31
- const payment = JSON.parse(result.stdout);
32
-
33
- const elapsed = Math.round((Date.now() - startTime) / 1000);
34
- console.log(`[${elapsed}s] Status: ${payment.payment_status}`);
35
-
36
- // Check for terminal states
37
- switch (payment.payment_status) {
38
- case 'finished':
39
- console.log('\n✓ Payment completed successfully!');
40
- console.log(` Amount paid: ${payment.actually_paid} ${payment.pay_currency}`);
41
- console.log(` Outcome: ${payment.outcome_amount} ${payment.outcome_currency}`);
42
- return { success: true, payment };
43
-
44
- case 'failed':
45
- console.log('\n✗ Payment failed');
46
- return { success: false, reason: 'failed', payment };
47
-
48
- case 'expired':
49
- console.log('\n✗ Payment expired');
50
- return { success: false, reason: 'expired', payment };
51
-
52
- case 'partially_paid':
53
- console.log(`\n⚠ Partially paid: ${payment.actually_paid}/${payment.pay_amount} ${payment.pay_currency}`);
54
- // Continue monitoring
55
- break;
56
-
57
- case 'waiting':
58
- case 'confirming':
59
- case 'confirmed':
60
- case 'sending':
61
- // Still processing, continue monitoring
62
- break;
63
- }
64
-
65
- // Wait before next check
66
- await new Promise(resolve => setTimeout(resolve, CHECK_INTERVAL));
67
-
68
- } catch (error) {
69
- console.error(`Error checking payment: ${error.message}`);
70
- await new Promise(resolve => setTimeout(resolve, CHECK_INTERVAL));
71
- }
72
- }
73
-
74
- console.log('\n⏱ Monitoring timeout reached');
75
- return { success: false, reason: 'timeout' };
76
- }
77
-
78
- // Get payment ID from command line
79
- const paymentId = process.argv[2];
80
-
81
- if (!paymentId) {
82
- console.error('Usage: node monitor-payment.js <payment_id>');
83
- process.exit(1);
84
- }
85
-
86
- // Run monitoring
87
- monitorPayment(paymentId)
88
- .then(result => {
89
- process.exit(result.success ? 0 : 1);
90
- })
91
- .catch(error => {
92
- console.error('Fatal error:', error);
93
- process.exit(1);
94
- });
package/logo.png DELETED
Binary file