diff --git a/browsers/enable-payments-in-browser-agent.mdx b/browsers/enable-payments-in-browser-agent.mdx
index 1b4ee28a..ec69b29d 100644
--- a/browsers/enable-payments-in-browser-agent.mdx
+++ b/browsers/enable-payments-in-browser-agent.mdx
@@ -98,7 +98,7 @@ remove-and-replace flow instead of adding a second wallet.
1. let the user select a provider that doesn't already have a wallet in the vault.
2. create the wallet item through your controller, following the [pay with card setup](/integrations/wallets/pay-with-card#connect-a-card), [link setup](/integrations/wallets/stripe-link), or [agentcard setup](/integrations/wallets/agentcard).
-3. present the returned action using the authenticated flow below. the user connects or enrolls their real payment method with the provider. a KERNEL wallet is `connected` as soon as you create it and returns no action; invoke [`add_payment_method`](/integrations/wallets/pay-with-multiple-cards#add-a-card) and present the payment method's `card_enrollment` action instead.
+3. present the returned action using the authenticated flow below. the user connects or enrolls their real payment method with the provider. a KERNEL wallet is `connected` as soon as you create it and returns no action; invoke [`add_payment_method`](/integrations/wallets/pay-with-card#connect-a-card) and present the payment method's `card_enrollment` action instead.
4. wait for the wallet's status to become `connected` before preparing a purchase. for a KERNEL wallet, wait until the card's payment method is `active` and eligible to pay.
### Present hosted actions in your application
@@ -225,7 +225,7 @@ a purchase using the user's own card is approved before checkout, so `authorize`
browser or page parameters. authorize once the agent reaches the final checkout
page: the one-time security code expires shortly after it's issued.
-1. [create a `card` item](/integrations/wallets/pay-with-card#make-a-purchase) named `notebook-order` from the verified purchase. set `payment_method_id` to the `id` of an `active`, eligible card from the wallet's [`payment_methods` expansion](/integrations/wallets/pay-with-multiple-cards#list-payment-methods). set `merchant_url` to the top-level checkout page's url. `fill` writes only on that url's exact origin, so a checkout hosted on another domain needs that domain's url. visa cards also require `merchant_country`. `card` items with `provider: "kernel"` can't be updated; to change the purchase, delete the item and create a new one.
+1. [create a `card` item](/integrations/wallets/pay-with-card#make-a-purchase) named `notebook-order` from the verified purchase. set `payment_method_id` to the `id` of an `active`, eligible card from the wallet's [`payment_methods` expansion](/integrations/wallets/pay-with-card#list-payment-methods). set `merchant_url` to the top-level checkout page's url. `fill` writes only on that url's exact origin, so a checkout hosted on another domain needs that domain's url. visa cards also require `merchant_country`. `card` items with `provider: "kernel"` can't be updated; to change the purchase, delete the item and create a new one.
2. require `authorize` in `available_operations` and invoke it, then present any returned `spend_approval` action through your controller. visa cards use it for the cardholder's approval, and [cards without network tokens](/integrations/wallets/pay-with-card#make-a-purchase) use it to collect a fresh security code. supported mastercard cards return no action.
3. wait for the card to become `ready`. a `wait` read holds for at most 60 seconds, so keep retrieving while it's `pending_authorization`; the cardholder has up to 30 minutes to use the approval link.
diff --git a/browsers/payments.mdx b/browsers/payments.mdx
index 91d37863..357e8ae5 100644
--- a/browsers/payments.mdx
+++ b/browsers/payments.mdx
@@ -55,8 +55,7 @@ your application must independently verify the merchant, items, amount, and curr
## Get started
- [choose a wallet integration](/integrations/wallets/overview) for payment-method connection, approval, and reuse options.
-- [pay with card](/integrations/wallets/pay-with-card) to collect a user's card directly, with hosted or embedded enrollment.
-- [pay with multiple cards](/integrations/wallets/pay-with-multiple-cards) to hold several cards in one KERNEL wallet and choose which card pays.
+- [pay with card](/integrations/wallets/pay-with-card) to collect a user's cards directly, with hosted or embedded enrollment, and choose which card pays.
- [fill single-use cards](/integrations/wallets/single-use-cards) to fill a card your backend or card issuer already has, such as a single-use virtual card.
- [enable payments in a browser agent](/browsers/enable-payments-in-browser-agent) for the controller, agent, and checkout walkthrough.
- [fill browser fields](/vaults/fill) for KERNEL's injection api, field selection, and outcome contract.
diff --git a/docs.json b/docs.json
index f3cf3561..7c98d3df 100644
--- a/docs.json
+++ b/docs.json
@@ -62,8 +62,10 @@
{ "source": "/integrations/payments/overview.md", "destination": "/integrations/wallets/overview.md" },
{ "source": "/integrations/wallets/kernel", "destination": "/integrations/wallets/pay-with-card" },
{ "source": "/integrations/wallets/kernel.md", "destination": "/integrations/wallets/pay-with-card.md" },
- { "source": "/integrations/wallets/kernel-payment-methods", "destination": "/integrations/wallets/pay-with-multiple-cards" },
- { "source": "/integrations/wallets/kernel-payment-methods.md", "destination": "/integrations/wallets/pay-with-multiple-cards.md" },
+ { "source": "/integrations/wallets/kernel-payment-methods", "destination": "/integrations/wallets/pay-with-card" },
+ { "source": "/integrations/wallets/pay-with-multiple-cards", "destination": "/integrations/wallets/pay-with-card" },
+ { "source": "/integrations/wallets/kernel-payment-methods.md", "destination": "/integrations/wallets/pay-with-card.md" },
+ { "source": "/integrations/wallets/pay-with-multiple-cards.md", "destination": "/integrations/wallets/pay-with-card.md" },
{ "source": "/integrations/payments/stripe-link", "destination": "/integrations/wallets/stripe-link" },
{ "source": "/integrations/payments/stripe-link.md", "destination": "/integrations/wallets/stripe-link.md" },
{ "source": "/integrations/payments/agentcard", "destination": "/integrations/wallets/agentcard" },
@@ -219,7 +221,6 @@
"browsers/payments",
"integrations/wallets/overview",
"integrations/wallets/pay-with-card",
- "integrations/wallets/pay-with-multiple-cards",
"integrations/wallets/push-cards",
"integrations/wallets/single-use-cards",
"integrations/wallets/stripe-link",
diff --git a/integrations/wallets/embedded-card-capture.mdx b/integrations/wallets/embedded-card-capture.mdx
index 141fc19a..b9bb06f5 100644
--- a/integrations/wallets/embedded-card-capture.mdx
+++ b/integrations/wallets/embedded-card-capture.mdx
@@ -37,7 +37,7 @@ the package requires react 18 or later and ships no styles. use 0.5.0 or later:
read `capture_token` from a `card_enrollment` action in your authenticated backend. the token is a secret capability for one card enrollment, not an api key.
-a new KERNEL wallet is `connected` with no card and no action. invoke [`add_payment_method`](/integrations/wallets/pay-with-multiple-cards#add-a-card) for each card, then read `payment_method.action.capture_token` from the result.
+a new KERNEL wallet is `connected` with no card and no action. invoke [`add_payment_method`](/integrations/wallets/pay-with-card#connect-a-card) for each card, then read `payment_method.action.capture_token` from the result.
@@ -88,7 +88,7 @@ if added.type == "add_payment_method" and added.payment_method.action is not Non
the new payment method starts in `pending_enrollment`. after the cardholder adds a card, it becomes `active`.
-a wallet created before cards were payment methods might still have a default card, `card`, waiting for enrollment. its `card_enrollment` action, with its `capture_token`, is on that method in the wallet's [`payment_methods` expansion](/integrations/wallets/pay-with-multiple-cards#list-payment-methods), not on the wallet.
+a wallet created before cards were payment methods might still have a default card, `card`, waiting for enrollment. its `card_enrollment` action, with its `capture_token`, is on that method in the wallet's [`payment_methods` expansion](/integrations/wallets/pay-with-card#list-payment-methods), not on the wallet.
## Render the component
diff --git a/integrations/wallets/overview.mdx b/integrations/wallets/overview.mdx
index 93d3e529..15f74c28 100644
--- a/integrations/wallets/overview.mdx
+++ b/integrations/wallets/overview.mdx
@@ -19,7 +19,7 @@ see [how payments work on KERNEL](/browsers/payments#how-payments-work) for the
| payment source | use it to | environment |
| --- | --- | --- |
-| [pay with card](/integrations/wallets/pay-with-card) | collect a user's cards directly through hosted or embedded enrollment, then [choose which card pays](/integrations/wallets/pay-with-multiple-cards) | live only |
+| [pay with card](/integrations/wallets/pay-with-card) | collect a user's cards directly through hosted or embedded enrollment, then [choose which card pays](/integrations/wallets/pay-with-card#choose-a-card-for-a-purchase) | live only |
| [single-use cards](/integrations/wallets/single-use-cards) | fill a card your backend or card issuer already has, such as a single-use virtual card, without passing its details to the agent | set by the card you supply |
| [link by stripe](/integrations/wallets/stripe-link) | use payment methods from the user's link wallet; requires a us phone number | live only |
| [shop pay](/integrations/wallets/shop-pay) | use cards saved to the user's shop account, approved in shop for each purchase; usd only | live only |
@@ -80,7 +80,7 @@ supports the same operations. KERNEL payment requests must set
`payment_method_id`. agentcard, shop pay, and vgs purchases and KERNEL single-use cards stay `card` items. updates to a
`payment_request` item must set `type: "payment_request"`.
-for behavior specific to each payment source, see [pay with card](/integrations/wallets/pay-with-card), [pay with multiple cards](/integrations/wallets/pay-with-multiple-cards), [single-use cards](/integrations/wallets/single-use-cards), [link](/integrations/wallets/stripe-link#item-reference), [shop pay](/integrations/wallets/shop-pay#item-reference), [agentcard](/integrations/wallets/agentcard#item-reference), or [bring your own vgs vault](/integrations/wallets/bring-your-own-vgs-vault#make-a-purchase).
+for behavior specific to each payment source, see [pay with card](/integrations/wallets/pay-with-card), [single-use cards](/integrations/wallets/single-use-cards), [link](/integrations/wallets/stripe-link#item-reference), [shop pay](/integrations/wallets/shop-pay#item-reference), [agentcard](/integrations/wallets/agentcard#item-reference), or [bring your own vgs vault](/integrations/wallets/bring-your-own-vgs-vault#make-a-purchase).
## Payment actions and recovery
diff --git a/integrations/wallets/pay-with-card.mdx b/integrations/wallets/pay-with-card.mdx
index 79698d07..1a31608d 100644
--- a/integrations/wallets/pay-with-card.mdx
+++ b/integrations/wallets/pay-with-card.mdx
@@ -75,14 +75,119 @@ kernel vaults wallets payment-methods user-12345 card-wallet
-a wallet can hold several cards. to add more, list them, or remove one, see [pay with multiple cards](/integrations/wallets/pay-with-multiple-cards).
+a connected wallet advertises `add_payment_method` and, once it holds a card, `remove_payment_method` in `available_operations`. invoke them only when they're advertised.
+
+share `action.url` privately with the cardholder, for example on an authenticated page in your application. the url is a capability for this one enrollment: don't send it to the agent, log it, or share it with anyone else. if enrollment fails, the link accepts another card until it expires. an expired link doesn't affect the wallet's other cards; call `add_payment_method` again for a new link.
card details go directly to KERNEL's card vaulting provider through secure hosted fields. KERNEL receives a card reference and metadata rather than the original card number. request security and compliance artifacts through [KERNEL's trust center](/info/trust-center).
+## Manage cards
+
+a wallet can hold several cards. each card is a payment method scoped to its wallet: call `add_payment_method` once per card, as in [connect a card](#connect-a-card). each call creates a separate enrollment link for one card.
+
+a wallet holds at most 10 payment methods, including pending ones, and at most 3 open enrollment links. at either limit, the wallet stops advertising `add_payment_method`, and invoking it returns `409` with the reason. remove a card or let an open link expire before adding another.
+
+### List payment methods
+
+retrieve the wallet with the `payment_methods` expansion to list its cards in creation order. each method includes `id`, `status`, `is_default`, `display`, and `capabilities.single_use_card`, with `eligible` and `reasons`. a pending method also includes its `action` and `expires_at`.
+
+
+
+```typescript TypeScript
+const current = await kernel.vaults.items.retrieve("card-wallet", {
+ id_or_name: vault.id,
+ expand: ["payment_methods"],
+});
+if (current.type !== "wallet") {
+ throw new Error("unexpected item type");
+}
+
+const methods = current.expanded?.payment_methods ?? [];
+for (const method of methods) {
+ console.log(
+ method.id,
+ method.status,
+ method.display.last4,
+ method.capabilities.single_use_card?.eligible,
+ );
+}
+```
+
+```python Python
+current = kernel.vaults.items.retrieve(
+ "card-wallet",
+ id_or_name=vault.id,
+ expand=["payment_methods"],
+)
+if current.type != "wallet":
+ raise RuntimeError("unexpected item type")
+
+methods = (current.expanded.payment_methods or []) if current.expanded else []
+for method in methods:
+ single_use_card = method.capabilities.single_use_card
+ print(
+ method.id,
+ method.status,
+ method.display.last4,
+ single_use_card.eligible if single_use_card else None,
+ )
+```
+
+
+
+| status | meaning | what to do |
+| --- | --- | --- |
+| `pending_enrollment` | an enrollment link is open | wait for the cardholder, or let the link expire |
+| `active` | the card is stored | pay with it when `capabilities.single_use_card.eligible` is `true` |
+| `removal_pending` | removal started but its outcome is unknown | retry `remove_payment_method` later |
+| `recovery_required` | the enrollment outcome is unknown, or the stored card can't be read | check `status_reason`: remove a method with an unknown enrollment outcome; [contact support](/info/support) for a card that can't be read, since removal returns `409` |
+
+a method that isn't `active` is never eligible to pay. `is_default` is `true` only for the default card `card`; new wallets have no default card.
+
+a wallet created before cards were payment methods keeps its first card as the default payment method, with the id `card`, and can add more cards. if that card's enrollment is still pending, its `card_enrollment` action is on the method in the `payment_methods` expansion, not on the wallet.
+
+### Remove a card
+
+`remove_payment_method` deletes the stored card and blocks new purchases, fills, and confirmations funded by it. the wallet's other cards aren't affected, and the wallet stays `connected` even with no cards left.
+
+
+
+```typescript TypeScript
+const removed = await kernel.vaults.items.performOperation("card-wallet", {
+ id_or_name: vault.id,
+ type: "remove_payment_method",
+ payment_method_id: "zk3o8w2h0a5n4e9q1x7c6v2b",
+});
+if (removed.type === "remove_payment_method") {
+ console.log(removed.payment_method_id, removed.status); // "removed"
+}
+```
+
+```python Python
+removed = kernel.vaults.items.perform_operation(
+ "card-wallet",
+ id_or_name=vault.id,
+ type="remove_payment_method",
+ payment_method_id="zk3o8w2h0a5n4e9q1x7c6v2b",
+)
+if removed.type == "remove_payment_method":
+ print(removed.payment_method_id, removed.status) # "removed"
+```
+
+
+
+| response | meaning | what to do |
+| --- | --- | --- |
+| `409` `purchase_unresolved` | a purchase funded by this card has an unresolved outcome | reconcile that purchase before removing the card |
+| `409` `provider_revocation_pending` | the card vault's deletion outcome is uncertain. the method stays `removal_pending` and refuses payments. | retry the removal later |
+| `429` `provider_rate_limited` | the payment provider is rate limiting requests | wait, then retry |
+
+removal isn't proof that a payment didn't happen. reconcile any purchase with the merchant's order record before treating it as unpaid.
+
## Make a purchase
1. attach the vault when you [create the browser](/vaults/overview#scope-and-attachment).
-2. create a `card` item for the purchase, referencing the wallet and the merchant, amount, and currency, and set `spec.payment_method_id` to the `id` of the card that pays. visa cards also require `merchant_country`, the merchant's two-letter country code. the purchase is bound to that card; see [choose a card for a purchase](/integrations/wallets/pay-with-multiple-cards#choose-a-card-for-a-purchase).
+2. create a `card` item for the purchase, referencing the wallet and the merchant, amount, and currency, and set `spec.payment_method_id` to the `id` of the card that pays. visa cards also require `merchant_country`, the merchant's two-letter country code. the purchase is bound to that card; see [choose a card for a purchase](#choose-a-card-for-a-purchase).
3. invoke the advertised `authorize` operation and complete any returned user action. keep action urls in your trusted user interface, outside the agent's context.
4. when `fill` appears in `available_operations`, [fill the checkout](/vaults/fill), submit once, and verify the merchant's order record. a completed fill isn't proof of payment.
@@ -172,8 +277,6 @@ for eligible cards, checkout receives a network token number, expiry, and one-ti
| visa | requires `spec.merchant_country`; complete the returned `spend_approval` action, including any required verification |
| supported mastercard | no hosted purchase approval |
-the purchase's `state.payment_method_id` names the card it's bound to, and `state.funding_status` reports whether that card can still pay. see [check the card funding a purchase](/integrations/wallets/pay-with-multiple-cards#check-the-card-funding-a-purchase).
-
there's no general standing approval or spending-limit setting across these paths. your application must verify purchase details before authorization. complete any returned user action and fill before the purchase's `expires_at`.
@@ -184,9 +287,47 @@ there's no general standing approval or spending-limit setting across these path
the recorded amount and merchant details don't restrict outgoing payment requests. an expiry or payment window isn't a single-use guarantee. follow the returned actions and expiry; don't treat this path as a standing spending authorization.
+### Choose a card for a purchase
+
+pass the chosen method's `id` as `spec.payment_method_id` when you create a purchase. the purchase is bound to that card when it's created: later operations can't switch it to another card or wallet, and an update that changes either returns `409`. to pay with a different card, create a new purchase.
+
+on a `card` item, omitting `payment_method_id` selects the default card `card` and never falls back to another card. new wallets have no default card, so creation without the id returns `400`.
+
+a KERNEL purchase can also be a `payment_request` item where they're enabled for your organization; [contact support](/info/support) to enable them. a `payment_request` takes the same spec as a `card` item with `provider: "kernel"` and supports the same operations, including `authorize`, `fill`, and `confirm_transaction`. its `payment_method_id` is required and must name an `active` method that's eligible to pay. neither type is deprecated. updates to a `payment_request` item must set `type: "payment_request"`.
+
+### Check the card funding a purchase
+
+a KERNEL purchase reports the card it's bound to as `state.payment_method_id` and whether that card can still pay as `state.funding_status`:
+
+| `funding_status` | meaning |
+| --- | --- |
+| `available` | the card can fund this purchase |
+| `unavailable` | the card is being removed or awaits recovery. authorization, fill, and confirmation are refused until it recovers. |
+| `removed` | the card was removed from its wallet. this purchase can't be paid; create a new purchase with another card. |
+
+`funding_status` never changes the purchase's `status`, which still reports what already happened to the purchase. purchases created before cards could be selected report the default card `card`.
+
+## Permissions
+
+`add_payment_method` and `remove_payment_method` create and delete stored cards, so a [scoped api key](/info/api-key-permissions) needs `vaults:write` in addition to `vaults:use` on the vault. a key without `vaults:write` doesn't see either operation in `available_operations`, and invoking one returns `403` with `insufficient_scope`. other wallet and purchase operations need only `vaults:use`.
+
+## Events
+
+the wallet's [item events](/vaults/overview#api-behavior) record each card's lifecycle, with the card's id in `data.payment_method_id`:
+
+| event | recorded when |
+| --- | --- |
+| `payment_method_enrollment_started` | `add_payment_method` opens an enrollment link |
+| `payment_method_enrolled` | a card added with `add_payment_method` is stored |
+| `payment_method_removed` | removal finishes |
+| `payment_method_recovery_required` | the card needs recovery |
+
+each new purchase records `purchase_created` with `item_type`, `provider`, and `payment_method_id_present`.
+
## Reference
- [enable payments in a browser agent](/browsers/enable-payments-in-browser-agent): the controller, agent, fill, and checkout walkthrough.
- [vault items api](https://kernel.sh/docs/api-reference/vaults/create-or-retrieve-an-identical-vault-item-by-immutable-key): request fields, eligibility, operations, and expiry.
+- [embedded card capture](/integrations/wallets/embedded-card-capture): collect a card on your own page.
- [fill single-use cards](/integrations/wallets/single-use-cards): fill a card your backend or card issuer already has.
- [pricing](/info/pricing): vault limits and payment charges.
diff --git a/integrations/wallets/pay-with-multiple-cards.mdx b/integrations/wallets/pay-with-multiple-cards.mdx
deleted file mode 100644
index 48c2ef6a..00000000
--- a/integrations/wallets/pay-with-multiple-cards.mdx
+++ /dev/null
@@ -1,323 +0,0 @@
----
-title: "Pay with multiple cards"
-sidebarTitle: "Pay with multiple cards"
-description: "Hold several cards in one KERNEL wallet and choose which card pays"
----
-
-a [KERNEL wallet](/integrations/wallets/pay-with-card) can hold zero or more cards. each card is a payment method scoped to its wallet: you add cards with `add_payment_method`, list them with the `payment_methods` expansion, choose one per purchase with `payment_method_id`, and remove them with `remove_payment_method`.
-
-## Create an empty wallet
-
-creating a KERNEL wallet returns a `connected` wallet with no cards and no `action`. the wallet stays `connected` before its first card and after its last card is removed, so `connected` doesn't mean the wallet can pay. add a card, then check the card's status and eligibility.
-
-a connected wallet advertises `add_payment_method` and, once it holds a card, `remove_payment_method` in `available_operations`. invoke them only when they're advertised.
-
-
-
-```typescript TypeScript
-import Kernel from "@onkernel/sdk";
-
-const kernel = new Kernel({
- projectID: process.env.KERNEL_PROJECT_ID!,
- maxRetries: 0,
-});
-const vault = await kernel.vaults.upsert({ name: "user-12345" });
-
-const wallet = await kernel.vaults.items.upsert("card-wallet", {
- id_or_name: vault.id,
- type: "wallet",
- spec: { provider: "kernel" },
-});
-
-const canAddCard = wallet.available_operations.some(
- ({ type }) => type === "add_payment_method",
-);
-```
-
-```python Python
-import os
-
-from kernel import Kernel
-
-kernel = Kernel(project_id=os.environ["KERNEL_PROJECT_ID"], max_retries=0)
-vault = kernel.vaults.upsert(name="user-12345")
-
-wallet = kernel.vaults.items.upsert(
- "card-wallet",
- id_or_name=vault.id,
- type="wallet",
- spec={"provider": "kernel"},
-)
-
-can_add_card = any(
- operation.type == "add_payment_method" for operation in wallet.available_operations
-)
-```
-
-
-
-a wallet created before cards were payment methods keeps its first card as the default payment method, with the id `card`, and can add more cards. if that card's enrollment is still pending, its `card_enrollment` action is on the method in the [`payment_methods` expansion](#list-payment-methods), not on the wallet.
-
-## Add a card
-
-`add_payment_method` creates a payment method in `pending_enrollment` and returns it with a single-use `card_enrollment` action and an `expires_at` 30 minutes later. each call creates a separate link for one card.
-
-
-
-```typescript TypeScript
-const added = await kernel.vaults.items.performOperation("card-wallet", {
- id_or_name: vault.id,
- type: "add_payment_method",
-});
-if (added.type !== "add_payment_method") {
- throw new Error("unexpected operation response");
-}
-
-const paymentMethod = added.payment_method;
-// show paymentMethod.action.url to the cardholder in your trusted ui, not to the agent
-console.log(paymentMethod.id, paymentMethod.status, paymentMethod.expires_at);
-```
-
-```python Python
-added = kernel.vaults.items.perform_operation(
- "card-wallet",
- id_or_name=vault.id,
- type="add_payment_method",
-)
-if added.type != "add_payment_method":
- raise RuntimeError("unexpected operation response")
-
-payment_method = added.payment_method
-# show payment_method.action.url to the cardholder in your trusted ui, not to the agent
-print(payment_method.id, payment_method.status, payment_method.expires_at)
-```
-
-
-
-share `action.url` privately with the cardholder, for example on an authenticated page in your application. the url is a capability for this one enrollment: don't send it to the agent, log it, or share it with anyone else. to collect the card on your own page instead, pass `action.capture_token` to [embedded card capture](/integrations/wallets/embedded-card-capture).
-
-the card goes directly to the card vault; KERNEL never accepts card details through this api. if enrollment fails, the link accepts another card until it expires. an expired link doesn't affect the wallet's other cards; call `add_payment_method` again for a new link.
-
-a wallet holds at most 10 payment methods, including pending ones, and at most 3 open enrollment links. at either limit, the wallet stops advertising `add_payment_method`, and invoking it returns `409` with the reason. remove a card or let an open link expire before adding another.
-
-## List payment methods
-
-retrieve the wallet with the `payment_methods` expansion to list its cards in creation order. each method includes `id`, `status`, `is_default`, `display`, and `capabilities.single_use_card`, with `eligible` and `reasons`. a pending method also includes its `action` and `expires_at`.
-
-
-
-```typescript TypeScript
-const current = await kernel.vaults.items.retrieve("card-wallet", {
- id_or_name: vault.id,
- expand: ["payment_methods"],
-});
-if (current.type !== "wallet") {
- throw new Error("unexpected item type");
-}
-
-const methods = current.expanded?.payment_methods ?? [];
-for (const method of methods) {
- console.log(
- method.id,
- method.status,
- method.display.last4,
- method.capabilities.single_use_card?.eligible,
- );
-}
-```
-
-```python Python
-current = kernel.vaults.items.retrieve(
- "card-wallet",
- id_or_name=vault.id,
- expand=["payment_methods"],
-)
-if current.type != "wallet":
- raise RuntimeError("unexpected item type")
-
-methods = (current.expanded.payment_methods or []) if current.expanded else []
-for method in methods:
- single_use_card = method.capabilities.single_use_card
- print(
- method.id,
- method.status,
- method.display.last4,
- single_use_card.eligible if single_use_card else None,
- )
-```
-
-
-
-| status | meaning | what to do |
-| --- | --- | --- |
-| `pending_enrollment` | an enrollment link is open | wait for the cardholder, or let the link expire |
-| `active` | the card is stored | pay with it when `capabilities.single_use_card.eligible` is `true` |
-| `removal_pending` | removal started but its outcome is unknown | retry `remove_payment_method` later |
-| `recovery_required` | the enrollment outcome is unknown, or the stored card can't be read | check `status_reason`: remove a method with an unknown enrollment outcome; [contact support](/info/support) for a card that can't be read, since removal returns `409` |
-
-a method that isn't `active` is never eligible to pay. `is_default` is `true` only for the default card `card`; new wallets have no default card.
-
-## Choose a card for a purchase
-
-pass the chosen method's `id` as `spec.payment_method_id` when you create a purchase. the purchase is bound to that card when it's created: later operations can't switch it to another card or wallet, and an update that changes either returns `409`. to pay with a different card, create a new purchase.
-
-on a `card` item, omitting `payment_method_id` selects the default card `card` and never falls back to another card. new wallets have no default card, so creation without the id returns `400`.
-
-a KERNEL purchase can also be a `payment_request` item where they're enabled for your organization; [contact support](/info/support) to enable them. a `payment_request` takes the same spec as a `card` item with `provider: "kernel"` and supports the same operations, including `authorize`, `fill`, and `confirm_transaction`. its `payment_method_id` is required and must name an `active` method that's eligible to pay. neither type is deprecated. updates to a `payment_request` item must set `type: "payment_request"`.
-
-
-
-```typescript TypeScript
-const card = methods.find(
- (method) =>
- method.status === "active" &&
- method.capabilities.single_use_card?.eligible === true,
-);
-if (!card) {
- throw new Error("add an eligible card first");
-}
-
-let purchase = await kernel.vaults.items.upsert("notebook-order", {
- id_or_name: vault.id,
- type: "card",
- spec: {
- provider: "kernel",
- wallet: "card-wallet",
- payment_method_id: card.id,
- amount: 2306,
- currency: "usd",
- merchant_name: "example shop",
- merchant_url: "https://shop.example.com/checkout",
- merchant_country: "US",
- },
-});
-
-const authorized = await kernel.vaults.items.performOperation(purchase.key, {
- id_or_name: vault.id,
- type: "authorize",
-});
-if (authorized.type !== "card") {
- throw new Error("unexpected operation response");
-}
-// visa: show authorized.action.url (spend_approval) to the cardholder, then wait for ready
-purchase = await kernel.vaults.items.retrieve(purchase.key, {
- id_or_name: vault.id,
- wait: 60,
-});
-```
-
-```python Python
-card = next(
- (
- method
- for method in methods
- if method.status == "active"
- and method.capabilities.single_use_card is not None
- and method.capabilities.single_use_card.eligible
- ),
- None,
-)
-if card is None:
- raise RuntimeError("add an eligible card first")
-
-purchase = kernel.vaults.items.upsert(
- "notebook-order",
- id_or_name=vault.id,
- type="card",
- spec={
- "provider": "kernel",
- "wallet": "card-wallet",
- "payment_method_id": card.id,
- "amount": 2306,
- "currency": "usd",
- "merchant_name": "example shop",
- "merchant_url": "https://shop.example.com/checkout",
- "merchant_country": "US",
- },
-)
-
-authorized = kernel.vaults.items.perform_operation(
- purchase.key,
- id_or_name=vault.id,
- type="authorize",
-)
-# visa: show authorized.action.url (spend_approval) to the cardholder, then wait for ready
-purchase = kernel.vaults.items.retrieve(purchase.key, id_or_name=vault.id, wait=60)
-```
-
-
-
-approval, fill, and network-token behavior are the same as for a single card. see [make a purchase](/integrations/wallets/pay-with-card#make-a-purchase).
-
-## Check the card funding a purchase
-
-a KERNEL purchase reports the card it's bound to as `state.payment_method_id` and whether that card can still pay as `state.funding_status`:
-
-| `funding_status` | meaning |
-| --- | --- |
-| `available` | the card can fund this purchase |
-| `unavailable` | the card is being removed or awaits recovery. authorization, fill, and confirmation are refused until it recovers. |
-| `removed` | the card was removed from its wallet. this purchase can't be paid; create a new purchase with another card. |
-
-`funding_status` never changes the purchase's `status`, which still reports what already happened to the purchase. purchases created before cards could be selected report the default card `card`.
-
-## Remove a card
-
-`remove_payment_method` deletes the stored card and blocks new purchases, fills, and confirmations funded by it. the wallet's other cards aren't affected, and the wallet stays `connected` even with no cards left.
-
-
-
-```typescript TypeScript
-const removed = await kernel.vaults.items.performOperation("card-wallet", {
- id_or_name: vault.id,
- type: "remove_payment_method",
- payment_method_id: "zk3o8w2h0a5n4e9q1x7c6v2b",
-});
-if (removed.type === "remove_payment_method") {
- console.log(removed.payment_method_id, removed.status); // "removed"
-}
-```
-
-```python Python
-removed = kernel.vaults.items.perform_operation(
- "card-wallet",
- id_or_name=vault.id,
- type="remove_payment_method",
- payment_method_id="zk3o8w2h0a5n4e9q1x7c6v2b",
-)
-if removed.type == "remove_payment_method":
- print(removed.payment_method_id, removed.status) # "removed"
-```
-
-
-
-| response | meaning | what to do |
-| --- | --- | --- |
-| `409` `purchase_unresolved` | a purchase funded by this card has an unresolved outcome | reconcile that purchase before removing the card |
-| `409` `provider_revocation_pending` | the card vault's deletion outcome is uncertain. the method stays `removal_pending` and refuses payments. | retry the removal later |
-| `429` `provider_rate_limited` | the payment provider is rate limiting requests | wait, then retry |
-
-removal isn't proof that a payment didn't happen. reconcile any purchase with the merchant's order record before treating it as unpaid.
-
-## Permissions
-
-`add_payment_method` and `remove_payment_method` create and delete stored cards, so a [scoped api key](/info/api-key-permissions) needs `vaults:write` in addition to `vaults:use` on the vault. a key without `vaults:write` doesn't see either operation in `available_operations`, and invoking one returns `403` with `insufficient_scope`. other wallet and purchase operations need only `vaults:use`.
-
-## Events
-
-the wallet's [item events](/vaults/overview#api-behavior) record each card's lifecycle, with the card's id in `data.payment_method_id`:
-
-| event | recorded when |
-| --- | --- |
-| `payment_method_enrollment_started` | `add_payment_method` opens an enrollment link |
-| `payment_method_enrolled` | a card added with `add_payment_method` is stored |
-| `payment_method_removed` | removal finishes |
-| `payment_method_recovery_required` | the card needs recovery |
-
-each new purchase records `purchase_created` with `item_type`, `provider`, and `payment_method_id_present`.
-
-## Reference
-
-- [vault items api](https://kernel.sh/docs/api-reference/vaults/create-or-retrieve-an-identical-vault-item-by-immutable-key): request fields, operations, and expiry.
-- [pay with card](/integrations/wallets/pay-with-card): purchase approval, fill, and network tokens.
-- [embedded card capture](/integrations/wallets/embedded-card-capture): collect a card on your own page.
diff --git a/integrations/wallets/push-cards.mdx b/integrations/wallets/push-cards.mdx
index 0da62386..0180a3e4 100644
--- a/integrations/wallets/push-cards.mdx
+++ b/integrations/wallets/push-cards.mdx
@@ -4,7 +4,7 @@ sidebarTitle: "Push cards from your backend"
description: "Add a card to a KERNEL wallet server to server, from a card issuer or from your own card vault"
---
-you can add a card to a [KERNEL wallet](/integrations/wallets/pay-with-multiple-cards) from a backend instead of having the cardholder type it in. you start a server enrollment, KERNEL returns a single-use `card_ingest` url, and the card is posted to that url.
+you can add a card to a [KERNEL wallet](/integrations/wallets/pay-with-card) from a backend instead of having the cardholder type it in. you start a server enrollment, KERNEL returns a single-use `card_ingest` url, and the card is posted to that url.
the `card_ingest` url is served by KERNEL's PCI-compliant card vault, not by KERNEL's API. the card vault replaces the card number and CVC with aliases before the request reaches KERNEL, so KERNEL never handles raw card data. the agent's browser only ever sees aliases, which are swapped for the real values on the way to the merchant.
@@ -13,7 +13,7 @@ the request carries the raw card number and CVC, so it must come from an environ
- **from a card issuer.** a bank, card program, or payment provider creates a single-use card for one checkout and posts it from its own PCI-compliant backend. use this for virtual cards issued per purchase.
- **from your own card vault.** your cards already live in a third-party vault, such as VGS, Basis Theory, Skyflow, or Evervault. your backend sends the request with your vault's aliases through the vault's outbound proxy, which swaps in the real values on the way out. the raw card only exists between the two vaults, so your servers never handle it. see [push from your own card vault](#push-from-your-own-card-vault).
-for a card the cardholder enters themselves, use [hosted enrollment](/integrations/wallets/pay-with-multiple-cards#add-a-card) instead. if your cards are in your own VGS vault, you can also [let KERNEL read them from your vault](/integrations/wallets/bring-your-own-vgs-vault) instead of pushing each card.
+for a card the cardholder enters themselves, use [hosted enrollment](/integrations/wallets/pay-with-card#connect-a-card) instead. if your cards are in your own VGS vault, you can also [let KERNEL read them from your vault](/integrations/wallets/bring-your-own-vgs-vault) instead of pushing each card.
never post raw card data from servers that aren't allowed to handle it. if your backend isn't PCI-compliant, send the card through a card vault's proxy, as described below.
@@ -291,7 +291,7 @@ once the card's CVC has been used by a purchase or has expired, a retry returns
## Pay with the pushed card
-create a purchase with the pushed card's `id` as `spec.payment_method_id`, as in [choose a card for a purchase](/integrations/wallets/pay-with-multiple-cards#choose-a-card-for-a-purchase). because the CVC came with the card, `authorize` makes the purchase `ready` right away, with no cardholder approval page. the agent then [fills](/vaults/fill) the checkout as usual.
+create a purchase with the pushed card's `id` as `spec.payment_method_id`, as in [choose a card for a purchase](/integrations/wallets/pay-with-card#choose-a-card-for-a-purchase). because the CVC came with the card, `authorize` makes the purchase `ready` right away, with no cardholder approval page. the agent then [fills](/vaults/fill) the checkout as usual.