Before you start
create a project-scoped client and vault. the examples below use thesekernel and vault variables.
Lifecycle
- create a
walletitem with the link oauth specification. - open the returned
link_oauthaction for the user and wait for the wallet to becomeconnected. - request the advertised
payment_methodsexpansion and let the user choose an eligible method. - create a
carditem with the purchase details. - retrieve the card, verify that it advertises
authorize, and perform that operation after explicit user approval. - complete the returned
spend_approvalorpush_approvalaction and wait forstate.statusto becomeready. - use
state.aliasesin an attached browser. the first native handoff changes the item toconsumed.
Connect a wallet
before showing a link connection option, list the vault’s items. if a link wallet already exists in any state, reuse it and do not let the user add another. show its existing action or status instead. the api makes item keys unique but does not currently enforce one wallet per provider, so the ui must enforce a maximum of one link wallet per vault. the examples usepresentProviderAction, an application-owned function that
publishes the action to an authenticated session for the end user who owns the
vault. bind the action to that user, vault, and item; apply a short application
ttl capped by wallet.expires_at when present; and stop serving it when the
action changes or disappears. derive authenticatedUser from the server-side
session, not a request field. do not log the url or put it in model context.
Select a payment method
requestpayment_methods only when available_expansions advertises it. the expansion comes from link at request time and is not persisted in the vault item.
LINK_PAYMENT_METHOD_ID. missing capability metadata means eligibility is unknown. only eligible: false is an explicit negative result.
Create and authorize a card item
amount uses minor currency units, so 2306 means 23.06 usd. link accepts values from 1 to 500000. context must contain at least 100 characters. card creation is live-only, and spec.test is not supported.
merchant_url supplies provider context. KERNEL derives its registrable domain into state.domains when authorization starts, but state.domains is metadata rather than an enforced browser-origin allowlist.
Use the aliases
after the user completes the approval action, retrieve the card withwait: 60 until it becomes ready. pass state.aliases to the browser agent payments guide.
the first recognized processor request that contains the aliases consumes the
item and clears its encrypted card value. consumed means the credential was
substituted, not that the processor accepted the payment or the merchant created
an order.
don’t repeat authorize or create a replacement item to retry an unknown purchase. inspect item events and the merchant’s order state first.
bring-your-own link oauth client
prefer KERNEL’s oauth client for the flow above. with your own client, your backend must construct the human-facing authorization url, manage state and pkce, and handle the redirect. register your backend’s callback with stripe, validate the returned state, and exchange the code using the original pkce verifier and client credentials. keep the client secret, verifier, and tokens out of agent context, browser code, urls, and logs. register a provider configuration with organization-scoped authentication.link-client.json must contain client_id
and client_secret. keep credential and token files readable only by their
owner (for example, mode 0600) and outside the agent’s accessible files.
CLI
link-grant.json must contain access_token and refresh_token from
the same grant, with a currently valid access token. run this from your trusted
backend or a human-operated terminal, not the agent:
CLI
connected wallet; continue with payment-method
selection. KERNEL takes over refresh-token rotation, so your backend must stop
refreshing that grant.