@stripe/link-cli 0.11.0 → 0.13.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/README.md +43 -2
- package/dist/cli.js +1651 -556
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -124,6 +124,8 @@ The `--request-approval` flag triggers a push notification to the user for appro
|
|
|
124
124
|
|
|
125
125
|
Easily approve requests with the [Link app](https://link.com/download).
|
|
126
126
|
|
|
127
|
+
If the created spend request comes back with `status: "requires_action"`, no approval is needed yet — the payment method or account needs attention first. Check `status_details.requires_action.next_action` for `type`, `display_message`, `action_url`, and `resolution`. For 3D Secure (`resolution: "auto_resume"`), keep polling `spend-request retrieve` — the request resolves on its own once the challenge is completed. For any other resolution, complete the indicated action and create a new spend request.
|
|
128
|
+
|
|
127
129
|
#### Line items and totals
|
|
128
130
|
|
|
129
131
|
`--line-item` and `--total` use repeatable `key:value` format.
|
|
@@ -170,6 +172,36 @@ In MCP/agent mode, pass `metadata` as a structured `{ key: value }` object.
|
|
|
170
172
|
|
|
171
173
|
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"`.
|
|
172
174
|
|
|
175
|
+
#### Link Pay Token
|
|
176
|
+
|
|
177
|
+
Some Stripe checkout pages expose an AI-agent steering block that supports a
|
|
178
|
+
Link Pay Token (LPT). Inspect the checkout in a browser before creating the
|
|
179
|
+
SpendRequest: enable the agent checkbox, then verify that both
|
|
180
|
+
`input[name="link_pay_token"]` and
|
|
181
|
+
`data-stripe-merchant-account="acct_..."` are present in the same Stripe
|
|
182
|
+
frame.
|
|
183
|
+
|
|
184
|
+
Create an LPT-bound request with the DOM-derived account ID. Do not pass
|
|
185
|
+
`--merchant-name` or `--merchant-url`; Link resolves the canonical merchant
|
|
186
|
+
identity from the account ID for the approval screen.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
link-cli spend-request create \
|
|
190
|
+
--payment-method-id csmrpd_xxx \
|
|
191
|
+
--execution-method link_pay_token \
|
|
192
|
+
--merchant-account-id acct_... \
|
|
193
|
+
--context "Purchasing an item from the checkout the agent inspected. The user initiated this purchase through the shopping assistant." \
|
|
194
|
+
--amount 3500 \
|
|
195
|
+
--request-approval
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
LPT requests use the default `card` credential type and do not support
|
|
199
|
+
`--test`, `--network-id`, or `shared_payment_token`. After approval, retrieve
|
|
200
|
+
`--include link_pay_token` immediately before using it on the same checkout
|
|
201
|
+
surface. Each returned LPT is valid for up to 30 minutes, or until the
|
|
202
|
+
SpendRequest expires. If either DOM marker is absent, create a regular virtual
|
|
203
|
+
card SpendRequest instead; do not create an LPT request.
|
|
204
|
+
|
|
173
205
|
### Execute payment
|
|
174
206
|
|
|
175
207
|
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.
|
|
@@ -193,7 +225,7 @@ For agent polling, pass `--interval` and optionally `--max-attempts`:
|
|
|
193
225
|
link-cli spend-request retrieve lsrq_001 --interval 2 --max-attempts 300
|
|
194
226
|
```
|
|
195
227
|
|
|
196
|
-
Polling exits successfully only after the request reaches a terminal status such as `approved`, `denied`, `expired`, or `canceled`. If polling
|
|
228
|
+
Polling exits successfully only after the request reaches a terminal status such as `approved`, `denied`, `expired`, or `canceled`. If the status becomes `requires_action`, behavior depends on `next_action.resolution`: `auto_resume` (used for 3D Secure) means polling continues automatically — the request resolves on its own once the user completes the challenge. Any other resolution stops polling immediately and the command exits with the `next_action` details instead of waiting for a terminal status; the caller must have the user act, then create a new spend request. If `--timeout` is reached or `--max-attempts` is exhausted 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.
|
|
197
229
|
|
|
198
230
|
If the merchant supports MPP, use `link-cli mpp pay` instead:
|
|
199
231
|
|
|
@@ -211,6 +243,7 @@ link-cli mpp pay https://climate.stripe.dev/api/contribute \
|
|
|
211
243
|
```bash
|
|
212
244
|
link-cli auth login --client-name "Claude Code" # identify the connecting agent
|
|
213
245
|
link-cli auth login --client-name "Claude Code" --interval 5 --timeout 300 # login + poll in one call
|
|
246
|
+
link-cli auth upgrade --scope "userinfo:read spend_requests:approve" # widen access to a superset
|
|
214
247
|
link-cli auth status # check auth status
|
|
215
248
|
link-cli auth logout # disconnect
|
|
216
249
|
```
|
|
@@ -219,6 +252,8 @@ When you provide `--client-name`, the Link app displays it when you approve the
|
|
|
219
252
|
|
|
220
253
|
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.
|
|
221
254
|
|
|
255
|
+
`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.
|
|
256
|
+
|
|
222
257
|
`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:
|
|
223
258
|
|
|
224
259
|
```json
|
|
@@ -244,7 +279,13 @@ All commands accept `--auth <path>` to store auth credentials in a specific file
|
|
|
244
279
|
|
|
245
280
|
A spend request moves through: **create** → **request approval** → **approved** (with credentials).
|
|
246
281
|
|
|
247
|
-
**Required fields for create:** `merchant_name`, `merchant_url`,
|
|
282
|
+
**Required fields for a regular card create:** `merchant_name`, `merchant_url`,
|
|
283
|
+
`context`, and `amount`. `payment_method_id` is optional — if omitted,
|
|
284
|
+
your default payment method will be used, or the first eligible one if no
|
|
285
|
+
default is set. Shared Payment Token requests instead require `network_id`;
|
|
286
|
+
Link Pay Token requests require `execution_method=link_pay_token` and the
|
|
287
|
+
DOM-derived `merchant_account_id`, and Link supplies their canonical merchant
|
|
288
|
+
identity.
|
|
248
289
|
|
|
249
290
|
**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.
|
|
250
291
|
**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.
|