Skip to content

Commit 37d5e9c

Browse files
feat: Add processor-bound AgentCard preparation contracts
Stainless-Generated-From: 1b2956dd517385b95316303d9f6b5e962f8d2a40
1 parent 76dee03 commit 37d5e9c

10 files changed

Lines changed: 90 additions & 34 deletions

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ Types:
526526
from kernel.types.vaults import (
527527
AgentcardCheckoutAuthorization,
528528
AgentcardCheckoutPreparation,
529+
AgentcardPreparedProcessor,
529530
AuthorizeVaultItemOperationRequest,
530531
CardVaultItemSpec,
531532
CardVaultItemState,

src/kernel/resources/vaults/items.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,11 @@ def perform_operation(
511511
leave the outcome unknown; do not automatically retry.
512512
513513
Args:
514-
checkout: Required when preparing an unused AgentCard card for Square. Consent is bound to
515-
this browser and declared merchant origin, not a tab. Wait for the item's
516-
ready_to_submit status before native Pay and submit within its readiness
517-
deadline. Unused preparations expire automatically; every preparation is
518-
single-use, including after failure or expiry.
514+
checkout: Required when preparing an unused AgentCard card for a supported tokenization
515+
processor. Consent is bound to this browser and declared merchant origin, not a
516+
tab. Wait for the item's ready_to_submit status before native Pay and submit
517+
within its readiness deadline. Unused preparations expire automatically; every
518+
preparation is single-use, including after failure or expiry.
519519
520520
extra_headers: Send extra headers
521521
@@ -1274,11 +1274,11 @@ async def perform_operation(
12741274
leave the outcome unknown; do not automatically retry.
12751275
12761276
Args:
1277-
checkout: Required when preparing an unused AgentCard card for Square. Consent is bound to
1278-
this browser and declared merchant origin, not a tab. Wait for the item's
1279-
ready_to_submit status before native Pay and submit within its readiness
1280-
deadline. Unused preparations expire automatically; every preparation is
1281-
single-use, including after failure or expiry.
1277+
checkout: Required when preparing an unused AgentCard card for a supported tokenization
1278+
processor. Consent is bound to this browser and declared merchant origin, not a
1279+
tab. Wait for the item's ready_to_submit status before native Pay and submit
1280+
within its readiness deadline. Unused preparations expire automatically; every
1281+
preparation is single-use, including after failure or expiry.
12821282
12831283
extra_headers: Send extra headers
12841284

src/kernel/types/vaults/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .credential_vault_item_spec import CredentialVaultItemSpec as CredentialVaultItemSpec
2525
from .credential_vault_field_type import CredentialVaultFieldType as CredentialVaultFieldType
2626
from .credential_vault_item_state import CredentialVaultItemState as CredentialVaultItemState
27+
from .agentcard_prepared_processor import AgentcardPreparedProcessor as AgentcardPreparedProcessor
2728
from .credential_collection_action import CredentialCollectionAction as CredentialCollectionAction
2829
from .credential_vault_field_state import CredentialVaultFieldState as CredentialVaultFieldState
2930
from .vault_checkout_context_param import VaultCheckoutContextParam as VaultCheckoutContextParam

src/kernel/types/vaults/agentcard_checkout_preparation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
from typing_extensions import Literal
66

77
from ..._models import BaseModel
8+
from .agentcard_prepared_processor import AgentcardPreparedProcessor
89

910
__all__ = ["AgentcardCheckoutPreparation"]
1011

1112

1213
class AgentcardCheckoutPreparation(BaseModel):
13-
"""One-use Square checkout preparation.
14+
"""One-use processor-bound checkout preparation.
1415
1516
Keep the approval page open through token handoff. The amount is display-only and does not constrain the merchant's eventual charge.
1617
"""
@@ -19,10 +20,12 @@ class AgentcardCheckoutPreparation(BaseModel):
1920

2021
created_at: datetime
2122

22-
environment: Literal["production", "sandbox"]
23+
environment: Literal["production", "sandbox", "shared"]
2324

2425
merchant_origin: str
2526

27+
psp: AgentcardPreparedProcessor
28+
2629
status: Literal["creating", "awaiting_approval", "ready", "consumed", "cancelled", "expired", "unknown"]
2730
"""
2831
Preparation consumed means egress claimed the preparation and it cannot be
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal, TypeAlias
4+
5+
__all__ = ["AgentcardPreparedProcessor"]
6+
7+
AgentcardPreparedProcessor: TypeAlias = Literal["square", "braintree", "worldpay", "bambora", "mercado_pago"]

src/kernel/types/vaults/card_vault_item_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class AgentCardCardState(BaseModel):
112112
masks: Optional[AgentCardCardStateMasks] = None
113113

114114
preparation: Optional[AgentcardCheckoutPreparation] = None
115-
"""One-use Square checkout preparation.
115+
"""One-use processor-bound checkout preparation.
116116
117117
Keep the approval page open through token handoff. The amount is display-only
118118
and does not constrain the merchant's eventual charge.

src/kernel/types/vaults/item_perform_operation_params.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class PrepareCheckoutVaultItemOperationRequest(TypedDict, total=False):
3333
id_or_name: Required[str]
3434

3535
checkout: Required[VaultCheckoutContextParam]
36-
"""Required when preparing an unused AgentCard card for Square.
37-
38-
Consent is bound to this browser and declared merchant origin, not a tab. Wait
39-
for the item's ready_to_submit status before native Pay and submit within its
40-
readiness deadline. Unused preparations expire automatically; every preparation
41-
is single-use, including after failure or expiry.
36+
"""
37+
Required when preparing an unused AgentCard card for a supported tokenization
38+
processor. Consent is bound to this browser and declared merchant origin, not a
39+
tab. Wait for the item's ready_to_submit status before native Pay and submit
40+
within its readiness deadline. Unused preparations expire automatically; every
41+
preparation is single-use, including after failure or expiry.
4242
"""
4343

4444
type: Required[Literal["prepare_checkout"]]

src/kernel/types/vaults/prepare_checkout_vault_item_operation_request_param.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010

1111

1212
class PrepareCheckoutVaultItemOperationRequestParam(TypedDict, total=False):
13-
"""Prepare an unused AgentCard card for Square checkout.
13+
"""Prepare an unused AgentCard card for a supported tokenization checkout.
1414
1515
Deliver the returned approval URL and keep the approval page open. Poll the item until ready_to_submit, then submit native Pay before preparation.expires_at. Readiness lasts at most 30 seconds. Unused preparations expire automatically. Preparations are single-use even after failure or expiry; do not automatically retry and reconcile uncertain outcomes with the merchant.
1616
"""
1717

1818
checkout: Required[VaultCheckoutContextParam]
19-
"""Required when preparing an unused AgentCard card for Square.
20-
21-
Consent is bound to this browser and declared merchant origin, not a tab. Wait
22-
for the item's ready_to_submit status before native Pay and submit within its
23-
readiness deadline. Unused preparations expire automatically; every preparation
24-
is single-use, including after failure or expiry.
19+
"""
20+
Required when preparing an unused AgentCard card for a supported tokenization
21+
processor. Consent is bound to this browser and declared merchant origin, not a
22+
tab. Wait for the item's ready_to_submit status before native Pay and submit
23+
within its readiness deadline. Unused preparations expire automatically; every
24+
preparation is single-use, including after failure or expiry.
2525
"""
2626

2727
type: Required[Literal["prepare_checkout"]]

src/kernel/types/vaults/vault_checkout_context_param.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,36 @@
44

55
from typing_extensions import Literal, Required, TypedDict
66

7+
from .agentcard_prepared_processor import AgentcardPreparedProcessor
8+
79
__all__ = ["VaultCheckoutContextParam"]
810

911

1012
class VaultCheckoutContextParam(TypedDict, total=False):
11-
"""Required when preparing an unused AgentCard card for Square.
12-
13-
Consent is bound to this browser and declared merchant origin, not a tab. Wait for the item's ready_to_submit status before native Pay and submit within its readiness deadline. Unused preparations expire automatically; every preparation is single-use, including after failure or expiry.
13+
"""
14+
Required when preparing an unused AgentCard card for a supported tokenization processor. Consent is bound to this browser and declared merchant origin, not a tab. Wait for the item's ready_to_submit status before native Pay and submit within its readiness deadline. Unused preparations expire automatically; every preparation is single-use, including after failure or expiry.
1415
"""
1516

1617
browser_id: Required[str]
1718
"""Active browser session with this vault bound to it."""
1819

19-
environment: Required[Literal["production", "sandbox"]]
20-
"""Square environment, independent of the AgentCard credential mode."""
20+
environment: Required[Literal["production", "sandbox", "shared"]]
21+
"""
22+
Use production or sandbox for Square, Braintree and Worldpay; shared for Bambora
23+
and Mercado Pago. Shared endpoints do not establish test mode. Merchant
24+
credentials/configuration determine processor test mode, independently of the
25+
AgentCard credential mode.
26+
"""
2127

2228
merchant_origin: Required[str]
23-
"""Canonical HTTPS origin of the top-level merchant document, not the Square
24-
iframe.
29+
"""
30+
Canonical HTTPS origin of the top-level merchant document, not a processor
31+
iframe. HTTP localhost is accepted for tests.
32+
"""
33+
34+
psp: AgentcardPreparedProcessor
35+
"""Tokenization processor.
2536
26-
HTTP localhost is accepted for tests.
37+
Omit for Square compatibility. Non-Square processors require multi-processor
38+
preparation enablement.
2739
"""

tests/api_resources/vaults/test_items.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,22 @@ def test_method_perform_operation_overload_3(self, client: Kernel) -> None:
604604
)
605605
assert_matches_type(VaultItemOperationResponse, item, path=["response"])
606606

607+
@pytest.mark.skip(reason="Mock server tests are disabled")
608+
@parametrize
609+
def test_method_perform_operation_with_all_params_overload_3(self, client: Kernel) -> None:
610+
item = client.vaults.items.perform_operation(
611+
key="key",
612+
id_or_name="id_or_name",
613+
checkout={
614+
"browser_id": "browser_id",
615+
"environment": "production",
616+
"merchant_origin": "merchant_origin",
617+
"psp": "square",
618+
},
619+
type="prepare_checkout",
620+
)
621+
assert_matches_type(VaultItemOperationResponse, item, path=["response"])
622+
607623
@pytest.mark.skip(reason="Mock server tests are disabled")
608624
@parametrize
609625
def test_raw_response_perform_operation_overload_3(self, client: Kernel) -> None:
@@ -1793,6 +1809,22 @@ async def test_method_perform_operation_overload_3(self, async_client: AsyncKern
17931809
)
17941810
assert_matches_type(VaultItemOperationResponse, item, path=["response"])
17951811

1812+
@pytest.mark.skip(reason="Mock server tests are disabled")
1813+
@parametrize
1814+
async def test_method_perform_operation_with_all_params_overload_3(self, async_client: AsyncKernel) -> None:
1815+
item = await async_client.vaults.items.perform_operation(
1816+
key="key",
1817+
id_or_name="id_or_name",
1818+
checkout={
1819+
"browser_id": "browser_id",
1820+
"environment": "production",
1821+
"merchant_origin": "merchant_origin",
1822+
"psp": "square",
1823+
},
1824+
type="prepare_checkout",
1825+
)
1826+
assert_matches_type(VaultItemOperationResponse, item, path=["response"])
1827+
17961828
@pytest.mark.skip(reason="Mock server tests are disabled")
17971829
@parametrize
17981830
async def test_raw_response_perform_operation_overload_3(self, async_client: AsyncKernel) -> None:

0 commit comments

Comments
 (0)