Skip to main content
agentcard collects a user’s card in a hosted enrollment flow and authorizes each browser checkout against that enrolled payment method. the card number and cvc stay with agentcard. your agent receives non-secret aliases. agentcard is the credential provider, not the merchant’s payment processor. at the browser form layer, it works with any web checkout that accepts standard card details, and the merchant’s processor doesn’t need to be stripe. end-to-end handoff also requires the outgoing request to match a native processor adapter. KERNEL currently has adapters for request formats used by stripe, shopify, square, recurly, and razorpay. KERNEL’s native handoff aims to support the same processors supported by agentcard’s direct SDK. email support@kernel.sh if you need another processor so we can prioritize its adapter and validate a real checkout.

Before you start

create a project-scoped client and vault. the examples below use these kernel and vault variables.
the vault api does not expose whether the configured agentcard credential is sandbox or live. AGENTCARD_MODE is an application-owned assertion, not a value read from KERNEL. set it from the deployment configuration that owns the agentcard credential, show the mode in internal checkout controls, and fail closed when it is missing or does not match the environment you intend to use. set AGENTCARD_MODE=sandbox instead only when that deployment uses a sandbox credential.

Lifecycle

  1. create a wallet item and open the returned card_enrollment action for the user.
  2. wait for the wallet to become connected.
  3. create a reusable card item with the merchant, amount, and currency.
  4. attach the vault to a browser and give state.aliases to the agent.
  5. when the browser submits a recognized processor request containing the aliases, KERNEL holds the request and starts agentcard authorization.
  6. show the returned approval action to the user while the checkout remains in progress.
  7. agentcard executes the approved request, and KERNEL replays the processor response to the browser.
the card item returns to ready after an authorization settles and can be used for another separately approved purchase. only one authorization can be pending on an item at a time.

Enroll a card

before showing an agentcard enrollment option, list the vault’s items. if an agentcard 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 agentcard wallet per vault. the examples use presentProviderAction, 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. the browser payment guide defines the authenticated redirect and expiry contract for this helper.
open the enrollment url in a trusted user-facing surface. don’t give it to the agent or open it in the agent-controlled checkout browser. run cli --open only from a trusted, human-operated terminal because the command output can contain the action url.
spec.user_id can reuse a user who was already enrolled through another wallet in your organization. it cannot reference an arbitrary agentcard user.

Create a card item

amount uses minor currency units, so 2306 means 23.06 usd. omitting card_id lets the cardholder select an enrolled card on the approval screen. to pin a card, request the wallet’s advertised payment_methods expansion and set a returned id as spec.card_id.

Reuse a card item for a new purchase

upsert can retrieve an identical item, but it cannot replace the purchase specification at an existing key. for a later purchase, retrieve the reusable agentcard item and use update with the complete new specification:
the api accepts an agentcard card update only while the item is requested or ready. if it is pending_approval, finish and reconcile that authorization before preparing another purchase. if it is degraded, retrieve it to allow recovery and stop if it remains degraded. update replaces the full spec, so include card_id again when you want to keep the card pinned. never update an item to retry a failed, timed-out, or indeterminate checkout. agentcard has no per-item test, merchant_url, or domain allowlist. merchant is the name shown on the approval screen, not an enforced browsing origin. sandbox or live behavior comes from the agentcard credential configured for the integration and must match your application-owned AGENTCARD_MODE assertion before you use the aliases.

Complete the first checkout

use this sequence for an agentcard checkout:
  1. require exactly one agentcard wallet in the vault and wait for it to become connected.
  2. create a headful browser with the vault attached, surface browser_live_view_url through your trusted application, and navigate to the checkout. keep this same browser for verification and submission so location-dependent pricing cannot change between the confirmed purchase and the outgoing request.
  3. independently verify the merchant, items, active presentment amount, and active presentment currency from the merchant’s trusted order or cart backend. if one isn’t available, use documented structured checkout data or deterministic extraction for that checkout. for a stripe payment link specifically, prefer account_settings.display_name, line_item_group.total, line_item_group.currency, and line_item_group.line_items from the structured payment-link response. use dom text and test ids only as supplemental checks because stripe can duplicate or omit them across layouts.
  4. collect merchant-required fields such as email, billing name, and postal code from the end user. identify checkout-specific agent disclosures and instruct the agent to answer them truthfully in the normal form.
  5. show the verified purchase to the end user. after confirmation, create or update the card item from that same frozen object and require it to be ready. the vault attachment covers items created later in the same vault.
  6. start the card and event observer before checkout submission. keep it running concurrently while the browser request is held.
  7. give the browser agent the aliases, separately collected customer fields, and any required disclosure answer. submit the merchant form once and never retry submission.
  8. publish the approval action through the authenticated, expiring application flow. never send it to the checkout browser or agent.
  9. after the authorization settles, reconcile authorization state, item events, the checkout page, and the merchant order record. don’t prepare the next purchase until this attempt is terminal or explicitly classified as indeterminate.

Surface the live view

presentLiveView represents an application-owned route. store the url server-side with the authenticated end user and browser session binding, and render or embed it only after checking that session. retain the same binding through confirmation and approval pauses. remove it when the browser is deleted or times out, and don’t put it in logs or model context. see live view for iframe and csp requirements.

Run checkout and observation concurrently

start the observer before calling the browser agent. the application-owned functions below represent the observer, your existing agent loop, your order backend, and your reconciliation policy:
the observer must have its own terminal-state loop and application deadline. cancel it after the merchant reaches a terminal state or the deadline expires. if the deadline expires, retain the vault id, card key, browser id, and last event id, classify the attempt as indeterminate, and don’t resubmit checkout.

Handle checkout approval

agentcard doesn’t advertise the authorize operation. authorization begins only after an attached browser submits a recognized processor request containing the aliases. while the request is held, retrieve the card and send action.url through the same authenticated, expiring user-action flow used for enrollment. stop serving the url when it disappears, changes, expires, or the authorization settles. state.authorization describes the pending or most recent authorization, including its status, browser_id, expected and actual amounts when available, charge result, and replay result.
CLI
each --wait performs one bounded observation. repeat the relevant command to continue observing an existing checkout; don’t use it as evidence that a payment succeeded or failed. run --open only in a trusted, human-operated terminal and never pass its output to an agent. declines, expirations, and provider failures can return a processor-shaped failure response to the browser. the exact response depends on the native adapter. the reusable item can still return to ready, so item status alone doesn’t prove that the purchase succeeded or failed. your reconciliation policy must return succeeded only when the merchant order record confirms a paid order whose merchant, items, amount, and currency match the frozen purchase object. treat state.authorization, charged_kind, replay_delivered, item events, and the checkout page as supporting evidence. merchant success text is page-specific: Thanks for your payment can appear for one stripe checkout, but no generic success-text matcher proves that the merchant created the expected order. return indeterminate when the sources disagree or the merchant record is unavailable, and don’t retry automatically. pass the aliases to the browser agent payments guide and observe item events while the checkout runs.