@integraledger/lcp/ap2
AP2 v0.2 checkouts and closed Checkout Mandates, and the `ap2/checkout-mandate` pairing: the ATR hash as the `legalContext` member of the merchant-signed `checkout_jwt` payload, which the buyer's closed Checkout Mandate commits to through `checkout_hash`.
For AI agents: this page as Markdown, and llms.txt, the index of every page.
AP2 v0.2 checkouts and closed Checkout Mandates, and the ap2/checkout-mandate pairing: the ATR hash as the
legalContext member of the merchant-signed checkout_jwt payload, which the buyer's closed Checkout Mandate
commits to through checkout_hash.
The hash is read back from the checkout JWT presented beside the mandate. The mandate is presented alone, or last in
AP2's chain after the open mandate. In AP2's push funding, where the payer's side sends the funds, the presentation
also carries the confirmation of funds sent, payment_receipt. Nothing here verifies a signature, a cnf delegation
or a link between hops.
Interfaces
Ap2Offer
The offer read gives, and the buyer's input to build: the merchant's checkout_jwt (checkoutJwt), its decoded
payload, and the checkout's own id (checkout).
Properties
| Property | Type |
|---|---|
checkout | string |
checkoutJwt | string |
payload | Payload |
MandateContent
Properties
| Property | Type |
|---|---|
checkout_hash | string |
checkout_jwt? | string |
Presented
Extended by
Properties
| Property | Type | Description |
|---|---|---|
checkout_jwt | string | The checkout JWT presented beside the mandate. For AP2's latest-checkout check, the seller passes the one it last sent for this checkout; the buyer's copy shows only that the mandate and that JWT agree. |
checkout_mandate | string | The closed Checkout Mandate as presented: one SD-JWT, or AP2's chain of the open mandate's SD-JWT and the closed mandate's, joined by ~~. |
payment_receipt? | object | Present only in AP2's push funding, where the payment method pushes funds to the merchant and the merchant receives confirmation of funds sent instead of a payment credential: that confirmation, AP2's Payment Receipt as the payer's side gives it, a JSON object carried whole and read by nothing here. Absent where the merchant initiates the charge. |
Unsigned
Properties
| Property | Type |
|---|---|
content | object |
content.checkout_hash | string |
content.checkout_jwt | string |
content.vct | "mandate.checkout.1" |
Methods
complete()
complete(
checkout_mandate):Presented
Parameters
| Parameter | Type |
|---|---|
checkout_mandate | string |
Returns
X402Authorization
The EIP-3009 TransferWithAuthorization AP2's x402 credential carries, its numbers as decimal strings.
Properties
| Property | Type | Description |
|---|---|---|
from | string | - |
nonce | string | keccak-256 of the payment mandate chain's UTF-8 text, as 64 hex digits, with or without 0x. |
to | string | - |
validAfter | string | - |
validBefore | string | - |
value | string | - |
X402Bundle
AP2's x402 payment credential: the payment mandate chain, its nonce, and the signed EIP-3009 authorization.
Properties
| Property | Type |
|---|---|
eip_3009_payload | object |
eip_3009_payload.authorization | X402Authorization |
eip_3009_payload.signature | string |
payment_mandate_chain | string |
payment_nonce | string |
X402Method
AP2's x402 payment method, as the merchant names it in the checkout's accepted_payment_methods, with the token the
authorization moves, which AP2's method does not name.
Indexable
[
k:string]:Json
Properties
| Property | Type | Description |
|---|---|---|
address | string | The account the payment pays. |
asset | string | The token under whose EIP-712 domain the authorization is signed, a 20-byte address: the merchant's own configuration of the method, as x402's option names it asset. |
network | string | The network: an eip155:<chain id> CAIP-2 id, or an x402 v1 EVM network name as AP2 writes it (base-sepolia). |
type | "x402" | - |
X402Presented
The checkout mandate as ap2/checkout-mandate takes it, with the x402 credential the merchant received.
Extends
Properties
| Property | Type | Description | Inherited from |
|---|---|---|---|
checkout_jwt | string | The checkout JWT presented beside the mandate. For AP2's latest-checkout check, the seller passes the one it last sent for this checkout; the buyer's copy shows only that the mandate and that JWT agree. | Presented.checkout_jwt |
checkout_mandate | string | The closed Checkout Mandate as presented: one SD-JWT, or AP2's chain of the open mandate's SD-JWT and the closed mandate's, joined by ~~. | Presented.checkout_mandate |
payment | X402Bundle | - | - |
payment_receipt? | object | Present only in AP2's push funding, where the payment method pushes funds to the merchant and the merchant receives confirmation of funds sent instead of a payment credential: that confirmation, AP2's Payment Receipt as the payer's side gives it, a JSON object carried whole and read by nothing here. Absent where the merchant initiates the charge. | Presented.payment_receipt |
Type Aliases
CheckoutOption
CheckoutOption =
object
The checkout's own id, 1–256 characters.
Properties
| Property | Type |
|---|---|
checkout | string |
EvmMark
EvmMark =
"latest"|"safe"|"finalized"
The marks of an EVM read, from the lowest: the block at the head, at or below safe, at or below finalized.
EvmQuery
EvmQuery<
Ref> =StatusQuery<Ref,bigint,EvmMark>
What an EVM status takes beside the reference and the reader.
Type Parameters
| Type Parameter |
|---|
Ref |
Jws
Jws =
string
A compact JWS: three base64url segments joined by ".".
Payload
Payload =
object
The checkout_jwt payload: the commerce object.
Index Signature
[k: string]: Json
X402Ref
X402Ref =
Eip3009Ref&Omit<EvmRef,"network"|"payee"|"transaction"> &object
The read keys of the x402 credential: the keys of x402/exact/eip155/eip3009's reference, the authorization's own
nonce standing where that pairing's reference has H, so that the carried pairing's status reads the payment; and
the authorization's members as presented. The authorization's nonce is its single-use value.
Type Declaration
| Name | Type |
|---|---|
authorization | PullAuthorization |
from | string |
idDigest | Hex |
nonce | string |
to | string |
transferLog | TransferLog |
validAfter | string |
validBefore | string |
value | string |
Variables
CHECKOUT_VCT
constCHECKOUT_VCT:"mandate.checkout.1"="mandate.checkout.1"
checkoutMandate
constcheckoutMandate:Readonly<{advertise: (payload,h,link,offer,agreementUrl?) =>Refusal|Payload;bound: (presented) =>Promise<Refusal|`0x${string}`>;broadcaster: (presented) =>Promise<Refusal|Broadcaster>;build: (offer,h) =>Promise<Refusal|Unsigned>;claims:boolean;data:PairingData;id:"ap2/checkout-mandate";pattern:LcpPattern;read: (doc) =>Refusal| {agreement?:string;h:`0x${string}`;link:string;offer:Ap2Offer; };tie: (options) => ["ap2", {options: readonlyCheckoutOption[]; }];unplaced: (option) =>Refusal|CheckoutOption; }>
ap2/checkout-mandate. Where the merchant initiates the charge, the payee broadcasts (broadcaster answers
"payee"): the seller's payment processor executes the payment the closed Checkout Mandate authorizes. In AP2's
push funding the presentation carries payment_receipt and the payer broadcasts ("payer"): its side sent the funds
before the merchant saw them. Nothing here reads the payment. A value outside bound's shape gate gets the refusal
bound gives it.
checkoutMandateX402
constcheckoutMandateX402:Readonly<{advertise: (payload,h,link,offer,agreementUrl?) =>Refusal|Payload;bound: (presented) =>Promise<Refusal|`0x${string}`>;broadcaster: (presented) =>Promise<Refusal|Broadcaster>;build: (offer,h) =>Promise<Refusal|Unsigned>;claims:boolean;data:PairingData;id:"ap2/checkout-mandate/x402";pattern:LcpPattern;read: (doc) =>Refusal| {agreement?:string;h:`0x${string}`;link:string;offer:Ap2Offer; };reference: (presented,option) =>Promise<Refusal|X402Ref>;status: (ref,reader,query) =>Promise<StatusAnswer<bigint,EvmMark>>;tie: (options) => ["ap2", {options: readonlyCheckoutOption[]; }];unplaced: (option) =>Refusal|CheckoutOption; }>
ap2/checkout-mandate/x402. The payee broadcasts (broadcaster answers "payee"): the merchant forwards AP2's x402
credential to its payment processor, which submits the authorization. status reads it by this pairing's
reference as x402/exact/eip155/eip3009's read does, at coverage none, the authorization's own nonce standing
where that pairing has H. A value that is not a JSON object gets ap2/mandate-malformed, as bound refuses it.
issuedDigest
constissuedDigest: typeofdigestJson=digestJson
The option digest the issuer keeps: SHA-256 over the RFC 8785 form.
Functions
checkoutBinding()
checkoutBinding(
p):Promise<Refusal| {payload:Payload; }>
AP2's merchant check: the mandate's checkout_hash is the hash of the presented checkout_jwt, and a disclosed
checkout_jwt is that JWT. Returns that JWT's payload. It checks that the mandate commits to the latest checkout
when the seller presents the checkout_jwt it last sent for this checkout; with the buyer's copy, it checks only
that the mandate and that JWT agree.
Parameters
| Parameter | Type |
|---|---|
p | unknown |
Returns
Promise<Refusal | { payload: Payload; }>
checkoutJwtOf()
checkoutJwtOf(
m):Promise<string|Refusal>
The checkout_jwt the mandate discloses.
Parameters
| Parameter | Type |
|---|---|
m | string |
Returns
Promise<string | Refusal>
jwsPayload()
The payload of a compact JWS, decoded as one JSON object. Each segment is base64url without padding in its canonical
form (RFC 7515 §2, RFC 4648 §3.5); a JWS with a segment in another form is ap2/jws-malformed. The signature is
never verified.
Parameters
| Parameter | Type |
|---|---|
j | string |
Returns
readMandate()
readMandate(
m):Promise<Refusal|MandateContent>
The closed Checkout Mandate in a presentation, one SD-JWT or AP2's chain of the open and closed mandates joined by
~~ (at most these two hops, each an SD-JWT): exactly one resolved object of the last SD-JWT whose vct is
mandate.checkout.1, its checkout_hash, and its checkout_jwt when disclosed. No signature is verified, nor the
open mandate's cnf delegation to the closed mandate's signer, nor the closed mandate's sd_hash or
issuer_jwt_hash link to the open one; the open mandate's constraints are not read. Each segment of each hop's
issuer-signed JWT and each disclosure is base64url without padding in its canonical form (RFC 4648 §3.5), or the
mandate is ap2/mandate-malformed; the last hop's Key Binding JWT is not read. A hop whose payload, with each
disclosed value where its reference sits, nests more than 64 levels is ap2/too-large.
Parameters
| Parameter | Type |
|---|---|
m | unknown |
Returns
Promise<Refusal | MandateContent>
tie()
tie(
options): ["ap2", {options: readonlyCheckoutOption[]; }]
The binding slot: the checkouts this ATR was minted for, each by its own id.
Parameters
| Parameter | Type |
|---|---|
options | readonly CheckoutOption[] |
Returns
["ap2", { options: readonly CheckoutOption[]; }]
x402MethodNetwork()
x402MethodNetwork(
network):`eip155:${string}`|undefined
The CAIP-2 id of the network an AP2 x402 method names, as AP2's merchant and x402 credential provider write it
(base-sepolia, merchant_agent_mcp/server.py:763 and x402_credentials_provider_mcp/server.py:264 at AP2
e1ea56d): an eip155:<chain id> id as given, or an x402 v1 EVM network name as eip155: and the chain id
@x402/evm 2.31.0's v1 table maps it to; undefined for any other value. ap2/checkout-mandate/x402's reference
names the method's network so.
Parameters
| Parameter | Type |
|---|---|
network | unknown |
Returns
`eip155:${string}` | undefined
References
Broadcaster
Re-exports Broadcaster
Last updated on
@integraledger/lcp/acp
ACP checkout sessions and delegate-payment allowances, and the pairings `acp/checkout/delegated` and `acp/checkout/undelegated`: the ATR hash as the checkout session's `id`.
@integraledger/lcp/aptos
Aptos, and the `x402/exact/aptos` pairing, served at the seller-tied level: no field of a standard Aptos transfer carries the ATR hash, so the hash is advertised in the challenge and tied to the payment by the seller's claim.