@stripe/link-cli 0.4.2 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +86 -39
  2. package/dist/cli.js +1723 -851
  3. package/package.json +8 -6
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Link CLI
2
2
 
3
- Link CLI lets agents get secure, one-time-use payment credentials from a Link wallet so they can complete purchases on your behalf without ever storing your real card details.
3
+ Link CLI lets agents get secure, one-time-use payment credentials from a Link wallet to complete purchases on your behalf without storing your real card details.
4
+
5
+ The CLI can produce one of two credential types:
6
+
7
+ - A virtual card (PAN) for use with a standard web checkout form. The issued card works anywhere, and is not restricted to Link-enabled sellers or sellers that use Stripe.
8
+ - A [Shared Payment Token](https://docs.stripe.com/agentic-commerce/concepts/shared-payment-tokens) (SPT) when the seller accepts programmatic payments through [Machine Payment Protocols](https://mpp.dev) (MPP)
9
+
10
+ For now, this is only available to US Link accounts.
4
11
 
5
12
  ## Installation
6
13
 
@@ -14,11 +21,31 @@ Or run directly with `npx`:
14
21
  npx @stripe/link-cli
15
22
  ```
16
23
 
17
- You can install the skill via `npx skills add stripe/link-cli`.
24
+ ### Use with agents
25
+
26
+ Install the skill:
27
+
28
+ ```bash
29
+ npx skills add stripe/link-cli
30
+ ```
31
+
32
+ By default when called from an agent (non-TTY), all commands use `toon` output — a compact, LLM-friendly text format. All commands accept `--format [format]` for structured output. Other formats: `json`, `yaml`, `md`, `jsonl`.
33
+
34
+ List available commands:
35
+
36
+ ```bash
37
+ link-cli --llms-full
38
+ ```
39
+
40
+ Get a command's full schema with `--schema`. Example:
18
41
 
19
- ### MCP Server
42
+ ```bash
43
+ link-cli spend-request create --schema
44
+ ```
45
+
46
+ #### MCP Server
20
47
 
21
- Link CLI can also run as a local MCP server. Add the following to your MCP client config (`.mcp.json`, etc.)
48
+ Link CLI can run as a local MCP server. Add the following to your MCP client config (`.mcp.json`, etc.)
22
49
 
23
50
  ```json
24
51
  {
@@ -33,6 +60,12 @@ Link CLI can also run as a local MCP server. Add the following to your MCP clien
33
60
 
34
61
  ## Quickstart
35
62
 
63
+ Run a guided onboarding and demo flow:
64
+
65
+ ```bash
66
+ link-cli onboard
67
+ ```
68
+
36
69
  ### Login
37
70
 
38
71
  The `link-cli` requires a Link account. You can log in to your existing one or [register online](https://app.link.com).
@@ -41,7 +74,7 @@ The `link-cli` requires a Link account. You can log in to your existing one or [
41
74
  link-cli auth login
42
75
  ```
43
76
 
44
- You'll receive a verification URL and a short phrase. Visit the URL, log in to your Link account, and enter the phrase to approve the connection.
77
+ You receive a verification URL and a short phrase. Visit the URL, log in to your Link account, and enter the phrase to approve the connection.
45
78
 
46
79
  ### List payment methods
47
80
 
@@ -49,11 +82,19 @@ You'll receive a verification URL and a short phrase. Visit the URL, log in to y
49
82
  link-cli payment-methods list
50
83
  ```
51
84
 
52
- Returns the cards and bank accounts saved to your Link account. Use the `id` field as `payment_method_id` in the next step. If you have no payment methods, you can [add new ones in Link](https://app.link.com/wallet).
85
+ Returns the cards and bank accounts saved to your Link account. Use the `id` field as `payment_method_id` in the next step. If you have no payment methods, [add new ones in Link](https://app.link.com/wallet).
86
+
87
+ ### List shipping addresses
88
+
89
+ ```bash
90
+ link-cli shipping-address list
91
+ ```
92
+
93
+ Returns the shipping addresses saved to your Link account. The response preserves nullable `nickname`, `address`, and address fields exactly as returned by the API.
53
94
 
54
95
  ### Create a spend request
55
96
 
56
- To request a secure, one-time payment credential from your Link wallet, you create a spend request. You specify a payment method in your account, as well as some merchant details, line items, and amounts.
97
+ Create a spend request with a payment method, merchant details, line items, and amounts:
57
98
 
58
99
  ```bash
59
100
  link-cli spend-request create \
@@ -67,9 +108,9 @@ link-cli spend-request create \
67
108
  --request-approval
68
109
  ```
69
110
 
70
- The `--request-approval` flag triggers a push notification (or email) to the user for approval, then polls until the request is approved or denied.
111
+ The `--request-approval` flag triggers a push notification to the user for approval, then polls until the request is approved or denied.
71
112
 
72
- Users can easily approve requests with the [Link app](https://link.com/download).
113
+ Easily approve requests with the [Link app](https://link.com/download).
73
114
 
74
115
  #### Line items and totals
75
116
 
@@ -81,7 +122,7 @@ Users can easily approve requests with the [Link app](https://link.com/download)
81
122
  --line-item "name:Running Shoes,unit_amount:12000,quantity:1,description:Trail runners"
82
123
  ```
83
124
 
84
- **`--total` keys:** `type` (required), `display_text` (required), `amount` (required)
125
+ **`--total` keys:** `type` (required; one of: `subtotal`, `tax`, `total`, `items_base_amount`, `items_discount`, `discount`, `fulfillment`, `shipping`, `fee`, `gift_wrap`, `tip`, `store_credit`), `display_text` (required), `amount` (required)
85
126
 
86
127
  ```bash
87
128
  --total "type:subtotal,display_text:Subtotal,amount:12000" \
@@ -90,24 +131,32 @@ Users can easily approve requests with the [Link app](https://link.com/download)
90
131
 
91
132
  #### Credential types
92
133
 
93
- By default, a spend request provisions a virtual card. For merchants that support the [Machine Payments Protocol](https://mpp.dev) (HTTP 402) and the Stripe payment method, you can instead include `--credential-type "shared_payment_token"`.
134
+ By default, a spend request provisions a virtual card. For merchants that support the [Machine Payments Protocol](https://mpp.dev) (HTTP 402) and the Stripe payment method, instead pass `--credential-type "shared_payment_token"`.
94
135
 
95
136
  ### Execute payment
96
137
 
97
138
  The approved spend request includes a `card` object with `number`, `cvc`, `exp_month`, `exp_year`, `billing_address`, and `valid_until`. Enter these into the merchant's checkout form.
98
139
 
99
140
  ```bash
100
- link-cli spend-request retrieve lsrq_001 --format json
141
+ link-cli spend-request retrieve lsrq_001
142
+ ```
143
+ By default, retrieving a spend request doesn't include card details. Pass `--include card` to see unmasked card details.
144
+
145
+ To avoid leaking card credentials into agent transcripts or logs, use `--output-file` to write the full card to a secure local file while stdout shows only redacted data (brand, last4, expiry):
146
+
147
+ ```bash
148
+ link-cli spend-request retrieve lsrq_001 --include card --output-file /tmp/link-card.json --format json
101
149
  ```
102
- By default, retrieving a spend request will not include card details. Use the `--include=card` to see unmasked card details.
150
+
151
+ The file is created with `0600` permissions. If the file already exists, the command fails unless `--force` is passed. When `--output-file` is set, the JSON output replaces the `card` object with redacted fields and adds a `card_output_file` path.
103
152
 
104
153
  For agent polling, pass `--interval` and optionally `--max-attempts`:
105
154
 
106
155
  ```bash
107
- link-cli spend-request retrieve lsrq_001 --interval 2 --max-attempts 150 --format json
156
+ link-cli spend-request retrieve lsrq_001 --interval 2 --max-attempts 300
108
157
  ```
109
158
 
110
- Polling exits successfully only after the request reaches a terminal status such as `approved`, `denied`, or `expired`. If polling reaches `--timeout` or exhausts `--max-attempts` while the request is still non-terminal, the command exits non-zero with `code: "POLLING_TIMEOUT"` so callers do not treat a still-pending request as complete.
159
+ Polling exits successfully only after the request reaches a terminal status such as `approved`, `denied`, `expired`, or `canceled`. If polling reaches `--timeout` or exhausts `--max-attempts` while the request is still non-terminal, the command exits non-zero with `code: "POLLING_TIMEOUT"` so callers do not treat a still-pending request as complete.
111
160
 
112
161
  If the merchant supports MPP, use `link-cli mpp pay` instead:
113
162
 
@@ -115,8 +164,7 @@ If the merchant supports MPP, use `link-cli mpp pay` instead:
115
164
  link-cli mpp pay https://climate.stripe.dev/api/contribute \
116
165
  --spend-request-id lsrq_001 \
117
166
  --method POST \
118
- --data '{"amount":100}' \
119
- --format json
167
+ --data '{"amount":100}'
120
168
  ```
121
169
 
122
170
  ## Advanced
@@ -124,14 +172,14 @@ link-cli mpp pay https://climate.stripe.dev/api/contribute \
124
172
  ### Authentication
125
173
 
126
174
  ```bash
127
- link-cli auth login --client-name "Claude Code" --format json # identify the connecting agent
128
- link-cli auth status --format json # check auth status
129
- link-cli auth logout --format json # disconnect
175
+ link-cli auth login --client-name "Claude Code" # identify the connecting agent
176
+ link-cli auth status # check auth status
177
+ link-cli auth logout # disconnect
130
178
  ```
131
179
 
132
- When `--client-name` is provided, the name is shown in the Link app when the user approves the connection — e.g. `Claude Code on my-macbook` instead of `link-cli on my-macbook`.
180
+ When you provide `--client-name`, the Link app displays it when you approve the connection — for example, `Claude Code on my-macbook` instead of `link-cli on my-macbook`.
133
181
 
134
- `auth status --format json` includes an `update` field when a newer version is available:
182
+ `auth status` includes an `update` field when a newer version is available:
135
183
 
136
184
  ```json
137
185
  {
@@ -144,7 +192,9 @@ When `--client-name` is provided, the name is shown in the Link app when the use
144
192
  }
145
193
  ```
146
194
 
147
- Set `NO_UPDATE_NOTIFIER=1` to suppress update checks (e.g. in CI).
195
+ Set `NO_UPDATE_NOTIFIER=1` to suppress update checks (for example, in CI).
196
+
197
+ All commands accept `--auth <path>` to store auth credentials in a specific file instead of the default location. `auth login` writes to this file; all other commands read from it. Useful for running multiple sessions with separate identities.
148
198
 
149
199
  ### Spend request lifecycle
150
200
 
@@ -153,57 +203,54 @@ A spend request moves through: **create** → **request approval** → **approve
153
203
  **Required fields for create:** `payment_method_id`, `merchant_name`, `merchant_url`, `context`, `amount`
154
204
 
155
205
  **Constraints:** `context` must be at least 100 characters; `amount` must not exceed 50000 (cents); `currency` must be a 3-letter ISO code.
156
- **Test mode:** Pass `--test` to create testmode credentials (uses test card `4242424242424242`). Useful for development and integration testing without using real payment methods.
206
+ **Test mode:** Pass `--test` to create testmode credentials (uses test card `4242424242424242`), useful for development and integration testing without real payment methods.
157
207
 
158
208
  ```bash
159
209
  # Update before approval
160
210
  link-cli spend-request update lsrq_001 \
161
- --merchant-url https://press.stripe.com/working-in-public \
162
- --format json
211
+ --merchant-url https://press.stripe.com/working-in-public
163
212
 
164
213
  # Request approval separately (alternative to create --request-approval)
165
- link-cli spend-request request-approval lsrq_001 --format json
166
-
167
- # Retrieve at any time (includes card credentials once approved)
168
- link-cli spend-request retrieve lsrq_001 --format json
169
- ```
214
+ link-cli spend-request request-approval lsrq_001
170
215
 
171
- ### Output formats
216
+ # Retrieve at any time (includes card credentials after approval)
217
+ link-cli spend-request retrieve lsrq_001
172
218
 
173
- All commands accept `--format json` for structured JSON output. Other formats: `yaml`, `md`, `jsonl`, `toon` (default). Errors are returned as JSON with `code` and `message` fields, with exit code 1.
219
+ # Cancel a spend request (from created, pending_approval, or approved state)
220
+ link-cli spend-request cancel lsrq_001
221
+ ```
174
222
 
175
223
  ### MPP
176
224
 
177
- Use `mpp pay` to complete purchases on merchants that use the [Machine Payments Protocol](https://mpp.dev). The spend request must use `credential_type: "shared_payment_token"` and be approved. The SPT is one-time-use — if payment fails, create a new spend request.
225
+ Use `mpp pay` to complete purchases on merchants that use the [Machine Payments Protocol](https://mpp.dev). The spend request must use `credential_type: "shared_payment_token"` and you must approve it before paying. The SPT is one-time-use — if payment fails, create a new spend request.
178
226
 
179
227
  ```bash
180
228
  link-cli mpp pay https://climate.stripe.dev/api/contribute \
181
229
  --spend-request-id lsrq_001 \
182
230
  --method POST \
183
231
  --data '{"amount":100}' \
184
- --header "X-Custom: value" \
185
- --format json
232
+ --header "X-Custom: value"
186
233
  ```
187
234
 
188
235
  Use `mpp decode` to validate a raw `WWW-Authenticate` header and extract the `network_id` needed for `shared_payment_token` spend requests:
189
236
 
190
237
  ```bash
191
238
  link-cli mpp decode \
192
- --challenge 'Payment id="ch_001", realm="merchant.example", method="stripe", intent="charge", request="..."' \
193
- --format json
239
+ --challenge 'Payment id="ch_001", realm="merchant.example", method="stripe", intent="charge", request="..."'
194
240
  ```
195
241
 
196
242
  ### Environment variables
197
243
 
198
244
  | Variable | Effect |
199
245
  |----------|--------|
246
+ | `LINK_AUTH_FILE` | Same as `--auth` — override the auth credential file path (flag takes precedence) |
200
247
  | `LINK_API_BASE_URL` | Override the API base URL |
201
248
  | `LINK_AUTH_BASE_URL` | Override the auth base URL |
202
249
  | `LINK_HTTP_PROXY` | Route all requests through an HTTP proxy (requires `undici`) |
203
250
 
204
251
  ## Onboard
205
252
 
206
- Run the guided setup flow — authenticates, checks payment methods, shows the app download QR, and walks through both demo flows:
253
+ Run the guided setup flow — authenticates, checks payment methods, shows the app download QR, and runs both demo flows:
207
254
 
208
255
  ```bash
209
256
  link-cli onboard