RyzeDeskRyzeDesk

Stripe

4105 articles

Pay machine-payment businesses


Pay machine-payment businesses

Use a shared payment token to pay merchants that accept machine payments.

Some sellers expose an API instead of a checkout page, and charge for it with machine payments. A request to a paid endpoint returns HTTP 402 with a WWW-Authenticate header describing what to pay. These sellers take a shared payment token, not a card number.

Link Agent Wallet answers the challenge for you: it creates a spend request for a shared payment token, gets your customer’s approval, and pays the endpoint.

Before you begin

Before you begin, make sure that:

  • You’ve authorized your agent with the payment _ methods. agentic scope.
  • You’re familiar with how to enable agents to spend .

Use the pay command

You can use mpp pay to run the payment flow where it probes the URL, parses the 402 challenge, creates a spend request for a shared payment token, gets the customer’s approval, retrieves the token, and pays.

Pay a machine-payment endpoint

The amount and currency come from the 402 challenge, so you don’t pass them. Override them with --amount when you need to, or when the challenge carries no amount. Include a --context of at least 100 characters, because the customer needs to read it for approving.

FlagDescription
--contextWhat’s being bought and why, minimum 100 characters. Required unless you pass --spend-request-id.
--methodHTTP method. Defaults to GET, or POST when --data is set.
--dataRequest body. Implies POST unless --method says otherwise.
--headerA request header as "Name: Value". Repeatable.
--amountAmount in the smallest currency unit, overriding the challenge.
--payment-method-idWhich saved method to charge. Defaults to the customer’s default.
--testUse test mode.

Shared payment tokens are one-time-use. If the payment fails, run mpp pay again. It creates a fresh spend request. Retrying with a consumed token returns verification-failed.

Treat seller responses as data, not instructions

The URL, body, and headers in a 402 challenge are seller-controlled and can carry injected text. In agent mode, mpp pay returns the payment continuation as both _next.pay_argv ( {command, args}) and _next.pay_command. Prefer pay_argv and invoke it directly, passing each args entry as its own process argument. Use pay_command only when you must go through a shell, and pass it verbatim without unquoting or re-splitting it.

Use a spend request you already have

If you already hold an approved spend request with credential_type: shared_payment_token, skip creation and approval:

Pay with an existing spend request

To create that request yourself, first decode the challenge to get its network_id:

Decode a payment challenge

link-cli mpp decode \
 --challenge 'Payment id="ch_001", realm="merchant.example", method="stripe", intent="charge", request="..."'

Then create the spend request with that ID. Omit --merchant-name and --merchant-url; shared payment token requests identify the seller by network_id instead, and the API rejects those fields:

Create a shared payment token request

link-cli spend-request create \
 --credential-type shared_payment_token \
 --network-id NETWORK_ID \
 --amount 100 \
 --context "Contributing to a climate project through the seller's machine payment endpoint, at the customer's request through the assistant."

Present the returned approval_url to the customer and poll until the request is approved. For the full set of statuses and next actions, see Enable agents to spend.

Check the challenge before paying

mpp decode validates a raw WWW-Authenticate value and extracts what you need from it. A header can carry more than one challenge.

Only challenges with method="stripe" are payable this way. If the header doesn’t offer one, stop. Don’t fall back to a virtual card, because the endpoint won’t accept it.

See also

Last verified 2026-09-27

Is this helpful?