Skip to content

Commit e5e6b25

Browse files
feat: Wire Shop Pay into the vault API
Stainless-Generated-From: aaafed9fc90df045849ad32557040ab8365e13e8
1 parent 3bbc604 commit e5e6b25

18 files changed

Lines changed: 305 additions & 25 deletions

‎api.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ from kernel.types.vaults import (
634634
RemovePaymentMethodVaultItemOperationRequest,
635635
RemovePaymentMethodVaultItemOperationResult,
636636
RestartVerificationVaultItemOperationRequest,
637+
ShopPayCardState,
638+
ShopPayCardVaultItemSpec,
639+
ShopPayWalletState,
640+
ShopPayWalletVaultItemSpec,
637641
VaultCardAliases,
638642
VaultCardFillField,
639643
VaultCheckoutContext,

‎src/kernel/resources/vaults/items.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ def delete(
386386
Unresolved payment operations normally block deletion, including operations on
387387
child cards of a wallet. Deleting a connected Kernel wallet first blocks new
388388
payments on it, then removes its enrolled card. If that fails, the wallet is
389-
kept and keeps refusing payments; retry the deletion. A Link or Kernel card in
390-
recovery_required for issuance, or an AgentCard card in recovery_required whose
391-
checkout create response returned no authorization ID, may be explicitly
392-
abandoned by deleting that card directly; deleting its wallet or vault remains
393-
blocked until the card is deleted. Deleting or recreating an item is not proof
394-
that a payment did not occur. Deleting a managed auth credential item leaves the
395-
connection and its saved credential unchanged.
389+
kept and keeps refusing payments; retry the deletion. A Link, Kernel or Shop Pay
390+
card in recovery_required for issuance, or an AgentCard card in
391+
recovery_required whose checkout create response returned no authorization ID,
392+
may be explicitly abandoned by deleting that card directly; deleting its wallet
393+
or vault remains blocked until the card is deleted. Deleting or recreating an
394+
item is not proof that a payment did not occur. Deleting a managed auth
395+
credential item leaves the connection and its saved credential unchanged.
396396
397397
Args:
398398
extra_headers: Send extra headers
@@ -2371,13 +2371,13 @@ async def delete(
23712371
Unresolved payment operations normally block deletion, including operations on
23722372
child cards of a wallet. Deleting a connected Kernel wallet first blocks new
23732373
payments on it, then removes its enrolled card. If that fails, the wallet is
2374-
kept and keeps refusing payments; retry the deletion. A Link or Kernel card in
2375-
recovery_required for issuance, or an AgentCard card in recovery_required whose
2376-
checkout create response returned no authorization ID, may be explicitly
2377-
abandoned by deleting that card directly; deleting its wallet or vault remains
2378-
blocked until the card is deleted. Deleting or recreating an item is not proof
2379-
that a payment did not occur. Deleting a managed auth credential item leaves the
2380-
connection and its saved credential unchanged.
2374+
kept and keeps refusing payments; retry the deletion. A Link, Kernel or Shop Pay
2375+
card in recovery_required for issuance, or an AgentCard card in
2376+
recovery_required whose checkout create response returned no authorization ID,
2377+
may be explicitly abandoned by deleting that card directly; deleting its wallet
2378+
or vault remains blocked until the card is deleted. Deleting or recreating an
2379+
item is not proof that a payment did not occur. Deleting a managed auth
2380+
credential item leaves the connection and its saved credential unchanged.
23812381
23822382
Args:
23832383
extra_headers: Send extra headers

‎src/kernel/types/vaults/__init__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
from .item_upsert_params import ItemUpsertParams as ItemUpsertParams
1414
from .vault_card_aliases import VaultCardAliases as VaultCardAliases
1515
from .kernel_wallet_state import KernelWalletState as KernelWalletState
16+
from .shop_pay_card_state import ShopPayCardState as ShopPayCardState
1617
from .card_vault_item_spec import CardVaultItemSpec as CardVaultItemSpec
1718
from .item_events_response import ItemEventsResponse as ItemEventsResponse
1819
from .item_retrieve_params import ItemRetrieveParams as ItemRetrieveParams
1920
from .vault_payment_method import VaultPaymentMethod as VaultPaymentMethod
2021
from .card_vault_item_state import CardVaultItemState as CardVaultItemState
2122
from .credential_vault_item import CredentialVaultItem as CredentialVaultItem
2223
from .link_shipping_address import LinkShippingAddress as LinkShippingAddress
24+
from .shop_pay_wallet_state import ShopPayWalletState as ShopPayWalletState
2325
from .vault_fill_field_param import VaultFillFieldParam as VaultFillFieldParam
2426
from .wallet_vault_item_spec import WalletVaultItemSpec as WalletVaultItemSpec
2527
from .vault_fill_field_result import VaultFillFieldResult as VaultFillFieldResult
@@ -39,9 +41,11 @@
3941
from .credential_account_vault_item import CredentialAccountVaultItem as CredentialAccountVaultItem
4042
from .item_perform_operation_params import ItemPerformOperationParams as ItemPerformOperationParams
4143
from .kernel_wallet_vault_item_spec import KernelWalletVaultItemSpec as KernelWalletVaultItemSpec
44+
from .shop_pay_card_vault_item_spec import ShopPayCardVaultItemSpec as ShopPayCardVaultItemSpec
4245
from .vault_item_operation_response import VaultItemOperationResponse as VaultItemOperationResponse
4346
from .agentcard_checkout_preparation import AgentcardCheckoutPreparation as AgentcardCheckoutPreparation
4447
from .payment_request_vault_item_spec import PaymentRequestVaultItemSpec as PaymentRequestVaultItemSpec
48+
from .shop_pay_wallet_vault_item_spec import ShopPayWalletVaultItemSpec as ShopPayWalletVaultItemSpec
4549
from .agentcard_checkout_authorization import AgentcardCheckoutAuthorization as AgentcardCheckoutAuthorization
4650
from .fill_vault_item_operation_result import FillVaultItemOperationResult as FillVaultItemOperationResult
4751
from .payment_request_vault_item_state import PaymentRequestVaultItemState as PaymentRequestVaultItemState
@@ -55,11 +59,13 @@
5559
from .kernel_wallet_vault_item_spec_param import KernelWalletVaultItemSpecParam as KernelWalletVaultItemSpecParam
5660
from .managed_auth_credential_vault_field import ManagedAuthCredentialVaultField as ManagedAuthCredentialVaultField
5761
from .passkey_vault_item_operation_result import PasskeyVaultItemOperationResult as PasskeyVaultItemOperationResult
62+
from .shop_pay_card_vault_item_spec_param import ShopPayCardVaultItemSpecParam as ShopPayCardVaultItemSpecParam
5863
from .one_password_credential_account_spec import OnePasswordCredentialAccountSpec as OnePasswordCredentialAccountSpec
5964
from .one_password_credential_account_state import (
6065
OnePasswordCredentialAccountState as OnePasswordCredentialAccountState,
6166
)
6267
from .payment_request_vault_item_spec_param import PaymentRequestVaultItemSpecParam as PaymentRequestVaultItemSpecParam
68+
from .shop_pay_wallet_vault_item_spec_param import ShopPayWalletVaultItemSpecParam as ShopPayWalletVaultItemSpecParam
6369
from .credential_vault_item_spec_input_param import (
6470
CredentialVaultItemSpecInputParam as CredentialVaultItemSpecInputParam,
6571
)

‎src/kernel/types/vaults/authorize_vault_item_operation_request_param.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99

1010
class AuthorizeVaultItemOperationRequestParam(TypedDict, total=False):
11-
"""Authorize a Link or Kernel card using its existing purchase specification.
12-
13-
Use only after explicit user approval and when the item advertises authorize; follow the advertised operation's description. For a Link card, pass browser_id and page_url together while the browser is on the final checkout page: Kernel inspects that checkout, chooses how the credential is delivered, and limits fill to that checkout's origin in any browser with this vault attached. Omitting both issues a virtual card that fills any page on the merchant origin. Once approval has been requested, browser_id and page_url are ignored and authorize only re-checks the request. Browser and checkout inspection errors occur before any provider request and can be retried once the browser is on the checkout page. Kernel cards do not accept browser_id or page_url.
11+
"""
12+
Authorize a Link, Kernel or Shop Pay card using its existing purchase specification. Use only after explicit user approval and when the item advertises authorize; follow the advertised operation's description. For a Link card, pass browser_id and page_url together while the browser is on the final checkout page: Kernel inspects that checkout, chooses how the credential is delivered, and limits fill to that checkout's origin in any browser with this vault attached. Omitting both issues a virtual card that fills any page on the merchant origin. Once approval has been requested, browser_id and page_url are ignored and authorize only re-checks the request. Browser and checkout inspection errors occur before any provider request and can be retried once the browser is on the checkout page. Kernel and Shop Pay cards do not accept browser_id or page_url.
1413
"""
1514

1615
type: Required[Literal["authorize"]]

‎src/kernel/types/vaults/card_vault_item_spec.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ..._utils import PropertyInfo
77
from ..._models import BaseModel
88
from .kernel_card_vault_item_spec import KernelCardVaultItemSpec
9+
from .shop_pay_card_vault_item_spec import ShopPayCardVaultItemSpec
910

1011
__all__ = [
1112
"CardVaultItemSpec",
@@ -161,6 +162,6 @@ class AgentCardCardVaultItemSpec(BaseModel):
161162

162163

163164
CardVaultItemSpec: TypeAlias = Annotated[
164-
Union[LinkCardVaultItemSpec, AgentCardCardVaultItemSpec, KernelCardVaultItemSpec],
165+
Union[LinkCardVaultItemSpec, AgentCardCardVaultItemSpec, KernelCardVaultItemSpec, ShopPayCardVaultItemSpec],
165166
PropertyInfo(discriminator="provider"),
166167
]

‎src/kernel/types/vaults/card_vault_item_spec_param.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

88
from .kernel_card_vault_item_spec_param import KernelCardVaultItemSpecParam
9+
from .shop_pay_card_vault_item_spec_param import ShopPayCardVaultItemSpecParam
910

1011
__all__ = [
1112
"CardVaultItemSpecParam",
@@ -161,5 +162,5 @@ class AgentCardCardVaultItemSpec(TypedDict, total=False):
161162

162163

163164
CardVaultItemSpecParam: TypeAlias = Union[
164-
LinkCardVaultItemSpec, AgentCardCardVaultItemSpec, KernelCardVaultItemSpecParam
165+
LinkCardVaultItemSpec, AgentCardCardVaultItemSpec, KernelCardVaultItemSpecParam, ShopPayCardVaultItemSpecParam
165166
]

‎src/kernel/types/vaults/card_vault_item_state.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ..._models import BaseModel
1010
from .kernel_card_state import KernelCardState
1111
from .vault_card_aliases import VaultCardAliases
12+
from .shop_pay_card_state import ShopPayCardState
1213
from .agentcard_checkout_preparation import AgentcardCheckoutPreparation
1314
from .agentcard_checkout_authorization import AgentcardCheckoutAuthorization
1415

@@ -134,5 +135,5 @@ class AgentCardCardState(BaseModel):
134135

135136

136137
CardVaultItemState: TypeAlias = Annotated[
137-
Union[LinkCardState, AgentCardCardState, KernelCardState], PropertyInfo(discriminator="provider")
138+
Union[LinkCardState, AgentCardCardState, KernelCardState, ShopPayCardState], PropertyInfo(discriminator="provider")
138139
]

‎src/kernel/types/vaults/confirm_transaction_vault_item_operation_request_param.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313

1414
class ConfirmTransactionVaultItemOperationRequestParam(TypedDict, total=False):
15-
"""Report a real merchant transaction outcome for an issued Kernel Visa credential.
16-
17-
Never infer success from filling checkout or receiving a credential. Supply the observed status, transaction type, actual amount, currency and timestamp. Unknown outcomes require manual reconciliation, not retry. Each purchase accepts one report.
15+
"""
16+
Report a real merchant transaction outcome for an issued Kernel Visa or Shop Pay credential. Shop Pay accepts PURCHASE, AUTHORIZATION and CAPTURE. Never infer success from filling checkout or receiving a credential. Supply the observed status, transaction type, actual amount, currency and timestamp. Unknown outcomes require manual reconciliation, not retry. Each purchase accepts one report.
1817
"""
1918

2019
amount: Required[int]

‎src/kernel/types/vaults/item_upsert_params.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .card_vault_item_spec_param import CardVaultItemSpecParam
99
from .kernel_wallet_vault_item_spec_param import KernelWalletVaultItemSpecParam
1010
from .payment_request_vault_item_spec_param import PaymentRequestVaultItemSpecParam
11+
from .shop_pay_wallet_vault_item_spec_param import ShopPayWalletVaultItemSpecParam
1112
from .credential_vault_item_spec_input_param import CredentialVaultItemSpecInputParam
1213
from .one_password_credential_account_spec_param import OnePasswordCredentialAccountSpecParam
1314

@@ -190,6 +191,7 @@ class WalletVaultItemRequestSpecAgentCardWalletVaultItemSpec(TypedDict, total=Fa
190191
WalletVaultItemRequestSpecLinkWalletVaultItemRequestSpec,
191192
WalletVaultItemRequestSpecAgentCardWalletVaultItemSpec,
192193
KernelWalletVaultItemSpecParam,
194+
ShopPayWalletVaultItemSpecParam,
193195
]
194196

195197

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import TYPE_CHECKING, Dict, List, Optional
4+
from typing_extensions import Literal
5+
6+
from pydantic import Field as FieldInfo
7+
8+
from ..._models import BaseModel
9+
10+
__all__ = ["ShopPayCardState", "Masks"]
11+
12+
13+
class Masks(BaseModel):
14+
brand: Optional[str] = None
15+
16+
last4: Optional[str] = None
17+
18+
token_last4: Optional[str] = None
19+
"""Last four digits of the network token presented to the merchant."""
20+
21+
if TYPE_CHECKING:
22+
# Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a
23+
# value to this field, so for compatibility we avoid doing it at runtime.
24+
__pydantic_extra__: Dict[str, str] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
25+
26+
# Stub to indicate that arbitrary properties are accepted.
27+
# To access properties that are not valid identifiers you can use `getattr`, e.g.
28+
# `getattr(obj, '$type')`
29+
def __getattr__(self, attr: str) -> str: ...
30+
else:
31+
__pydantic_extra__: Dict[str, str]
32+
33+
34+
class ShopPayCardState(BaseModel):
35+
"""Issued Shop Pay cards retain encrypted card material for the fill operation."""
36+
37+
provider: Literal["shop_pay"]
38+
39+
status: Literal[
40+
"requested", "pending_authorization", "ready", "consumed", "expired", "declined", "recovery_required"
41+
]
42+
"""declined covers a request the shopper declined or that was cancelled.
43+
44+
recovery_required means a provider operation has an unresolved outcome and the
45+
card cannot be used. When status_reason says the provider refused retrieval
46+
before acceptance, no card was issued and a later read retries. Otherwise follow
47+
status_reason: recovery for issuance can be abandoned by deleting the card and
48+
creating a new one, and the shopper approves the new purchase separately.
49+
Recovery while reporting a merchant transaction cannot be deleted and must be
50+
reconciled with support.
51+
"""
52+
53+
domains: Optional[List[str]] = None
54+
55+
masks: Optional[Masks] = None
56+
57+
status_reason: Optional[str] = None

0 commit comments

Comments
 (0)