@stripe/link-cli 0.10.1 → 0.12.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 +57 -2
  2. package/dist/cli.js +1343 -529
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -154,10 +154,52 @@ link-cli spend-request create ... \
154
154
 
155
155
  In MCP/agent mode, pass as a structured object.
156
156
 
157
+ #### Metadata
158
+
159
+ Attach arbitrary string data to a spend request with the repeatable `--metadata` flag (`key:value` format). Max 50 keys, key ≤ 40 chars, value ≤ 500 chars.
160
+
161
+ ```bash
162
+ link-cli spend-request create ... \
163
+ --metadata "order_id:ord_123" \
164
+ --metadata "team:growth"
165
+ ```
166
+
167
+ In MCP/agent mode, pass `metadata` as a structured `{ key: value }` object.
168
+
157
169
  #### Credential types
158
170
 
159
171
  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"`.
160
172
 
173
+ #### Link Pay Token
174
+
175
+ Some Stripe checkout pages expose an AI-agent steering block that supports a
176
+ Link Pay Token (LPT). Inspect the checkout in a browser before creating the
177
+ SpendRequest: enable the agent checkbox, then verify that both
178
+ `input[name="link_pay_token"]` and
179
+ `data-stripe-merchant-account="acct_..."` are present in the same Stripe
180
+ frame.
181
+
182
+ Create an LPT-bound request with the DOM-derived account ID. Do not pass
183
+ `--merchant-name` or `--merchant-url`; Link resolves the canonical merchant
184
+ identity from the account ID for the approval screen.
185
+
186
+ ```bash
187
+ link-cli spend-request create \
188
+ --payment-method-id csmrpd_xxx \
189
+ --execution-method link_pay_token \
190
+ --merchant-account-id acct_... \
191
+ --context "Purchasing an item from the checkout the agent inspected. The user initiated this purchase through the shopping assistant." \
192
+ --amount 3500 \
193
+ --request-approval
194
+ ```
195
+
196
+ LPT requests use the default `card` credential type and do not support
197
+ `--test`, `--network-id`, or `shared_payment_token`. After approval, retrieve
198
+ `--include link_pay_token` immediately before using it on the same checkout
199
+ surface. Each returned LPT is valid for up to 30 minutes, or until the
200
+ SpendRequest expires. If either DOM marker is absent, create a regular virtual
201
+ card SpendRequest instead; do not create an LPT request.
202
+
161
203
  ### Execute payment
162
204
 
163
205
  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.
@@ -199,6 +241,7 @@ link-cli mpp pay https://climate.stripe.dev/api/contribute \
199
241
  ```bash
200
242
  link-cli auth login --client-name "Claude Code" # identify the connecting agent
201
243
  link-cli auth login --client-name "Claude Code" --interval 5 --timeout 300 # login + poll in one call
244
+ link-cli auth upgrade --scope "userinfo:read spend_requests:approve" # widen access to a superset
202
245
  link-cli auth status # check auth status
203
246
  link-cli auth logout # disconnect
204
247
  ```
@@ -207,11 +250,15 @@ When you provide `--client-name`, the Link app displays it when you approve the
207
250
 
208
251
  With `--interval`, the login command yields the verification code immediately and then polls inline until authenticated or timed out — no separate `auth status` call needed. This is recommended for agents that cannot relay the code while a separate polling command blocks their I/O channel.
209
252
 
210
- `auth status` includes an `update` field when a newer version is available:
253
+ `auth upgrade` takes the same flags as `auth login` but is meant for widening access when you're already logged in. Unlike `auth login` — which stops with an "already logged in" message when a valid session exists — `auth upgrade` merges the flags you pass with your currently granted `scope` and `authorization_details` and starts a new approval for the **superset**, so you never accidentally drop access. If there's no valid session, it prints a warning and continues with just the access you requested. Your current session stays valid throughout the approval and is only replaced (and the old grant revoked) once you approve the new one — so abandoning the approval leaves your existing session untouched.
254
+
255
+ `auth status` reports the `scope` and `authorization_details` the current session was granted (echoed by the token endpoint at login/refresh and stored in the credential file), and includes an `update` field when a newer version is available:
211
256
 
212
257
  ```json
213
258
  {
214
259
  "authenticated": true,
260
+ "scope": "userinfo:read payment_methods.agentic",
261
+ "authorization_details": [{ "type": "source", "actions": ["read"] }],
215
262
  "update": {
216
263
  "current_version": "0.1.2",
217
264
  "latest_version": "0.2.0",
@@ -220,6 +267,8 @@ With `--interval`, the login command yields the verification code immediately an
220
267
  }
221
268
  ```
222
269
 
270
+ `scope` and `authorization_details` are only present when the token endpoint returned them.
271
+
223
272
  Set `NO_UPDATE_NOTIFIER=1` to suppress update checks (for example, in CI).
224
273
 
225
274
  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.
@@ -228,7 +277,13 @@ All commands accept `--auth <path>` to store auth credentials in a specific file
228
277
 
229
278
  A spend request moves through: **create** → **request approval** → **approved** (with credentials).
230
279
 
231
- **Required fields for create:** `merchant_name`, `merchant_url`, `context`, `amount`. `payment_method_id` is optional — if omitted, your default payment method will be used, or the first eligible one if no default is set.
280
+ **Required fields for a regular card create:** `merchant_name`, `merchant_url`,
281
+ `context`, and `amount`. `payment_method_id` is optional — if omitted,
282
+ your default payment method will be used, or the first eligible one if no
283
+ default is set. Shared Payment Token requests instead require `network_id`;
284
+ Link Pay Token requests require `execution_method=link_pay_token` and the
285
+ DOM-derived `merchant_account_id`, and Link supplies their canonical merchant
286
+ identity.
232
287
 
233
288
  **Constraints:** `context` must be at least 100 characters; `amount` must not exceed 500000 (cents); `currency` must be a 3-letter ISO code. The user has 10 minutes from when approval is requested to approve. Approved credentials (card or SPT) are valid for 12 hours from spend request creation.
234
289
  **Test mode:** Pass `--test` to create a testmode SpendRequest. A testmode SpendRequest will return test payment credentials (e.g test card `4000009990001984`) rather than a real payment credential. Testmode SpendRequests will not charge the underlying payment method of the SpendRequest. This is useful for development and integration testing without real payment methods.