@profullstack/coinpay 0.6.11 → 0.9.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/CHANGELOG.md CHANGED
@@ -5,6 +5,45 @@ All notable changes to `@profullstack/coinpay` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.9.0] - 2026-09-05
9
+
10
+ ### Added
11
+ - `coinpay finances` (aliases `coinpay money`, `coinpay tui`): a live terminal
12
+ dashboard built on `@profullstack/hqtui`. Seven screens — Overview, Bank &
13
+ Cards, Ledger, Crypto, Cards, Invoices & Escrow, Debt & Income — showing
14
+ gross volume, commission
15
+ paid, processor fees, refunds, net earnings, bank assets and liabilities,
16
+ cashflow, credit-card balances from the SimpleFIN/Plaid feeds, the ledger,
17
+ crypto and card payment tables, invoices outstanding/overdue and escrow held.
18
+ Refreshes on a timer and subscribes to the payments SSE stream so crypto
19
+ payment events appear live. `s` syncs the bank feed on demand.
20
+ - **Debt & Income** screen (`7`), and `coinpay finances position` (aliases
21
+ `debt`, `income`) as text. Income against spending per month, credits against
22
+ debits, total owed split into revolving and instalment, months to clear each
23
+ balance at its current payment rate, debt-to-income, debt-service ratio,
24
+ months of cover, card utilisation, detected recurring bills with their next
25
+ due date, and a business-versus-personal split of all of it — so the same
26
+ feed reads for a company or a person.
27
+ Transfers and card payments are excluded from both income and spending: a
28
+ feed holding both a checking account and the card it pays counts every card
29
+ payment twice otherwise. The raw sides remain visible as gross credits and
30
+ gross debits.
31
+ Built from about six months of history rather than the dashboard window,
32
+ because a monthly charge is invisible in thirty days of rows, and averaged
33
+ over the history that exists rather than the history requested.
34
+ - Plain-text `coinpay finances summary|accounts|ledger|connections|sync`
35
+ (`--json` on all of them) for scripts and for Node older than 22.6.
36
+ - SDK `finances` module, also importable as `@profullstack/coinpay/finances`:
37
+ `getFinanceSummary`, `listFinanceAccounts`, `listFinanceTransactions`,
38
+ `listFinanceConnections`, `syncFinances`, `getDashboardStats`,
39
+ `getFinanceAnalytics`, `listCryptoPayments`, `listCardTransactions`,
40
+ `listCardPayouts`, the pure `buildFinanceSnapshot()`, `collectFinanceSnapshot()`
41
+ and `subscribeToPayments()` (SSE with reconnect).
42
+
43
+ ### Changed
44
+ - New dependency `@profullstack/hqtui` (zero runtime deps of its own). The
45
+ dashboard needs Node 22.6+; every other command still runs on Node 20.
46
+
8
47
  ## [0.6.11] - 2026-03-19
9
48
 
10
49
  ### Added
package/README.md CHANGED
@@ -240,6 +240,30 @@ const { payment, usage } = await client.createPayment({
240
240
  }
241
241
  ```
242
242
 
243
+ #### `client.getTokens(params?)`
244
+
245
+ List checkout-ready tokens for a business. Use this instead of hard-coding a coin list. Business wallets take priority; merchant global wallets are used as fallback.
246
+
247
+ ```javascript
248
+ const { tokens } = await client.getTokens({
249
+ businessId: 'biz_123',
250
+ activeOnly: true,
251
+ });
252
+
253
+ for (const token of tokens) {
254
+ console.log(token.code); // "btc", "usdc_pol", ...
255
+ }
256
+ ```
257
+
258
+ | Param | Type | Required | Description |
259
+ |-------|------|----------|-------------|
260
+ | `businessId` | `string` | JWT only | Optional with a business API key; if set, it must match the key scope |
261
+ | `activeOnly` | `boolean` | — | Return active wallets only |
262
+
263
+ #### `client.getSupportedCoins(params?)`
264
+
265
+ Returns the lower-level `/api/supported-coins` shape with `coins` instead of token-picker `code` fields.
266
+
243
267
  ---
244
268
 
245
269
  #### `client.getPayment(paymentId)`
@@ -562,10 +586,87 @@ coinpay payment get pay_abc123
562
586
  # List payments
563
587
  coinpay payment list --business-id biz_123 --status pending --limit 10
564
588
 
589
+ # List checkout tokens
590
+ coinpay tokens list --business-id biz_123 --active-only
591
+
565
592
  # Get QR code
566
593
  coinpay payment qr pay_abc123
567
594
  ```
568
595
 
596
+ ### Invoices
597
+
598
+ Invoice creation is draft-only. It does not send the invoice or move funds.
599
+ Drafts do not have a public payment link. Publish the draft to create payment
600
+ details for manual sharing, or send it to create payment details and email the
601
+ client.
602
+ When using a business-scoped API key, --business-id may be omitted.
603
+
604
+ ```bash
605
+ # Create a draft invoice
606
+ coinpay invoice create \
607
+ --amount 250 \
608
+ --currency USD \
609
+ --client-id cli_001 \
610
+ --crypto-currency USDC \
611
+ --due-date 2026-09-01 \
612
+ --notes "August development"
613
+
614
+ # Route eventual settlement through a saved wallet or a direct address
615
+ coinpay invoice create --amount 250 --wallet-id wal_001
616
+ coinpay invoice create --amount 250 --merchant-wallet-address 0xabc123
617
+
618
+ # Get invoice details
619
+ coinpay invoice get inv_abc123
620
+
621
+ # Update editable fields on a draft. Use --notes= to clear existing notes.
622
+ coinpay invoice update inv_abc123 \
623
+ --amount 275 \
624
+ --due-date 2026-09-15 \
625
+ --notes "Updated scope"
626
+
627
+ # Publish creates real payment details without emailing the client. It asks for
628
+ # confirmation and prints a live /now/{invoiceId} link for manual chat sharing.
629
+ coinpay invoice publish inv_abc123
630
+
631
+ # Non-interactive publish requires explicit confirmation.
632
+ coinpay invoice publish inv_abc123 --yes --json
633
+
634
+ # Send creates real payment details and emails the client. The command asks for
635
+ # confirmation and prints the same /now/{invoiceId} link for manual chat sharing.
636
+ coinpay invoice send inv_abc123
637
+
638
+ # Non-interactive send requires explicit confirmation. JSON stays on stdout.
639
+ coinpay invoice send inv_abc123 --yes --json
640
+
641
+ # Permanently delete a draft invoice (also asks for confirmation).
642
+ coinpay invoice delete inv_abc123
643
+
644
+ # List invoices. Date filters apply to created_at and --date-to includes that day.
645
+ coinpay invoice list \
646
+ --business-id biz_123 \
647
+ --status sent \
648
+ --client-id cli_001 \
649
+ --date-from 2026-08-01 \
650
+ --date-to 2026-08-31
651
+
652
+ # Use --json with any invoice command for machine-readable output
653
+ coinpay invoice list --status paid --json
654
+ ```
655
+
656
+ Only draft invoices can be updated or deleted. Draft and overdue invoices can
657
+ be sent; sending an overdue invoice issues new payment details and emails the
658
+ client again. Only drafts can be published. `--yes` skips the confirmation for
659
+ publish/send/delete, and is required when any of those commands runs without a
660
+ terminal or with `--json`.
661
+
662
+ `--wallet-id` updates the invoice's stored wallet reference. To change the
663
+ actual settlement destination, use `--merchant-wallet-address` (or change the
664
+ crypto currency and let the server resolve the configured payee).
665
+
666
+ The CLI does not post invoice links to `/chat` automatically. Copy the printed
667
+ share link into chat manually. Treat `COINPAY_API_KEY` and `~/.coinpay.json` as
668
+ sensitive: either credential can authorize invoice updates, sends, and deletes.
669
+
569
670
  ### Businesses
570
671
 
571
672
  ```bash
@@ -589,6 +690,59 @@ coinpay webhook logs biz_123
589
690
  coinpay webhook test biz_123 --event payment.completed
590
691
  ```
591
692
 
693
+ ### Finances — your money in one place
694
+
695
+ ```bash
696
+ coinpay finances # live dashboard (needs `coinpay login`)
697
+ coinpay finances --days 90 # window for earnings / cashflow: 7, 30, 90, 365
698
+ coinpay finances summary # plain text, --json for machines
699
+ coinpay finances position # debt vs income, credits vs debits (also: debt)
700
+ coinpay finances accounts # linked bank & credit-card accounts (SimpleFIN / Plaid)
701
+ coinpay finances ledger --search anthropic --limit 20
702
+ coinpay finances connections # institutions and their last sync
703
+ coinpay finances sync # pull fresh balances (rate-limited by the bank bridge)
704
+ ```
705
+
706
+ The dashboard has seven screens (`1`–`7`, `Tab`): **Overview** (gross volume, crypto vs
707
+ cards, commission paid, processor fees, refunds, net earnings, bank position, cashflow,
708
+ invoices, escrow, payouts, a volume-vs-commission graph and a live feed), **Bank &
709
+ Cards**, **Ledger**, **Crypto**, **Cards**, **Invoices & Escrow**, **Debt & Income**.
710
+ `r` refreshes, `s`
711
+ syncs the bank feed, `w` cycles the window, `p` pauses, `?` shows help, `q` quits. It
712
+ refreshes every 30 seconds (`--interval`) and listens to the payments event stream, so
713
+ a crypto payment shows up the moment it is detected.
714
+
715
+ **Debt & Income** is the basic-accounting view, and it reads the same for a company or
716
+ a person: income against spending per month, total owed split into revolving and
717
+ instalment, months to clear each balance at its current payment rate, debt-to-income,
718
+ debt-service ratio, months of cover, card utilisation, the recurring bills it found with
719
+ their next due date, and a business-versus-personal split of all of it.
720
+
721
+ Two things about those numbers. Transfers and card payments are excluded from both
722
+ income and spending — a feed holding both a checking account and the card it pays
723
+ contains every card payment twice, so counting raw credits as income inflates both
724
+ sides by the whole card-payment volume. The untouched totals stay on screen as gross
725
+ credits and gross debits, so the netting is auditable. And the figures come from about
726
+ six months of history rather than the dashboard window (`w` does not move them), because
727
+ a monthly charge cannot be seen in thirty days of rows; the per-month averages divide by
728
+ the history that actually exists, which for a recently linked feed is much less than six
729
+ months.
730
+
731
+ It is built on [@profullstack/hqtui](https://hqtui.com) and needs Node 22.6+; the
732
+ plain-text subcommands work on Node 20. Bank data needs the merchant session from
733
+ `coinpay login` (business API keys are refused on purpose).
734
+
735
+ From the SDK:
736
+
737
+ ```js
738
+ import { CoinPayClient } from '@profullstack/coinpay';
739
+ import { collectFinanceSnapshot } from '@profullstack/coinpay/finances';
740
+
741
+ const client = new CoinPayClient({ apiKey: sessionToken });
742
+ const snapshot = await collectFinanceSnapshot(client, { days: 30 });
743
+ console.log(snapshot.earnings.netUsd, snapshot.bank.liabilities, snapshot.invoices.totals.overdue);
744
+ ```
745
+
592
746
  ---
593
747
 
594
748
  ## Webhook Integration
@@ -913,6 +1067,41 @@ Tests use [Vitest](https://vitest.dev/) with mocked `fetch` — no API key neede
913
1067
 
914
1068
  ---
915
1069
 
1070
+
1071
+ ## TaskMarket delegation (x402 v2)
1072
+
1073
+ `@profullstack/coinpay/taskmarket` lets an agent or user create and fund a
1074
+ [TaskMarket](https://taskmarket.dev) task from inside a CoinPay-powered app,
1075
+ using the standard x402 v2 transfer-authorization flow this SDK already speaks.
1076
+
1077
+ ```js
1078
+ import { createTask, discoverTasks, getTask, listSubmissions } from '@profullstack/coinpay/taskmarket';
1079
+
1080
+ // Browse open work (public endpoint)
1081
+ const open = await discoverTasks({ status: 'open', limit: 25, mode: 'bounty' });
1082
+
1083
+ // Create + fund a task. The wallet signs the EIP-712 transfer authorization
1084
+ // itself; this module never sees a private key.
1085
+ const { taskId } = await createTask(
1086
+ { title: 'Fix my parser bug', description: 'Repro + expected output attached in the linked issue.', reward: 2500000 },
1087
+ {
1088
+ signer: myWalletSigner, // { address, signTypedData({domain, types, primaryType, message}) }
1089
+ capabilities: ['eip155:8453'],
1090
+ spendingLimitUsd: 10, // hard cap; refuses anything above
1091
+ authorize: async (d) => confirm(`Send ${d.amount} ${d.asset} to ${d.payTo}?`),
1092
+ }
1093
+ );
1094
+
1095
+ // Track it and present submissions for human review (never auto-accept)
1096
+ const live = await getTask(taskId);
1097
+ const submissions = await listSubmissions(taskId);
1098
+ ```
1099
+
1100
+ Safety: no keys ever enter the module; every payment needs fresh `authorize()`
1101
+ consent; `spendingLimitUsd` is enforced against the quoted amount in base
1102
+ units; after a payment with unknown settlement the caller is told to verify
1103
+ with `getTask` instead of retrying blindly.
1104
+
916
1105
  ## License
917
1106
 
918
1107
  [MIT](./LICENSE) © Profullstack, Inc.