Before you start
create a project-scoped client and vault. the examples below use thesekernel and vault variables.
Choose an oauth client
use KERNEL’s oauth client by default. if you bring your own client, complete the setup below before following the shared payment lifecycle.bring your own link oauth client
register a provider configuration once for your organization. configurations are shared across projects, so authenticate this step with an organization-scoped api key. project-scoped credentials can reference an existing configuration when creating a wallet, but can’t create, update, or delete configurations. keep the client credentials outside the agent’s accessible files. the SDK examples read them from backend environment variables. for the CLI, create a protected file readable only by its owner (for example, mode0600):
link-client.json
kernel client and vault from
Before you start. supply the access and refresh tokens from
the same grant, with a currently valid access token. CLI users should restore
their project-scoped KERNEL_API_KEY before running the wallet command and put
the grant in this protected file:
link-grant.json
connected wallet without a link_oauth action.
KERNEL takes over refresh-token rotation, so your backend must stop refreshing
that grant. continue with Select a payment method.
Lifecycle
- connect a wallet: use KERNEL’s client and present the returned
link_oauthaction, or complete oauth in your backend and import the grant with your provider configuration. - require the wallet to be
connected. - 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
this section shows the KERNEL-managed oauth path. if you imported a connected wallet with your own client above, continue with Select a payment method. 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.