Pay machine-payment merchants
Use a shared payment token to pay merchants that accept machine payments over HTTP 402.
Accepting machine payments requires a shared payment token instead of a card number. Use this flow when a request returns HTTP 402 with a WWW-Authenticate header.
Before you begin
Before you begin, make sure that:
- You’ve set up OAuth , including the payment _ methods. agentic scope.
- You’re familiar with retrieving payment credentials with spend requests .
Decode the payment challenge
Decode the WWW-Authenticate header to get the network_id you need for the spend request:
Decode a payment challenge
link-cli mpp decode \
--challenge 'Payment id="ch_001", realm="merchant.example", method="stripe", intent="charge", request="..."'
Create a shared payment token request
Create a spend request for a shared payment token, passing the network_id from the previous step:
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 merchant's machine payment endpoint, requested by the customer."
Present the approval_url to the customer, then poll until the request is approved. For the full set of statuses and next actions, see Retrieve payment credentials with spend requests.
Complete the payment
After the customer approves the request, complete the payment:
Pay with a shared payment token
The shared payment token is one-time-use. If the payment fails, create a new spend request rather than retrying with the same token.
