Skip to content
Integra Protocol
API

@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

PropertyType
checkoutstring
checkoutJwtstring
payloadPayload

MandateContent

Properties

PropertyType
checkout_hashstring
checkout_jwt?string

Presented

Extended by

Properties

PropertyTypeDescription
checkout_jwtstringThe 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_mandatestringThe 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?objectPresent 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

PropertyType
contentobject
content.checkout_hashstring
content.checkout_jwtstring
content.vct"mandate.checkout.1"

Methods

complete()

complete(checkout_mandate): Presented

Parameters
ParameterType
checkout_mandatestring
Returns

Presented


X402Authorization

The EIP-3009 TransferWithAuthorization AP2's x402 credential carries, its numbers as decimal strings.

Properties

PropertyTypeDescription
fromstring-
noncestringkeccak-256 of the payment mandate chain's UTF-8 text, as 64 hex digits, with or without 0x.
tostring-
validAfterstring-
validBeforestring-
valuestring-

X402Bundle

AP2's x402 payment credential: the payment mandate chain, its nonce, and the signed EIP-3009 authorization.

Properties

PropertyType
eip_3009_payloadobject
eip_3009_payload.authorizationX402Authorization
eip_3009_payload.signaturestring
payment_mandate_chainstring
payment_noncestring

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

PropertyTypeDescription
addressstringThe account the payment pays.
assetstringThe 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.
networkstringThe 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

PropertyTypeDescriptionInherited from
checkout_jwtstringThe 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_mandatestringThe 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
paymentX402Bundle--
payment_receipt?objectPresent 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

PropertyType
checkoutstring

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

NameType
authorizationPullAuthorization
fromstring
idDigestHex
noncestring
tostring
transferLogTransferLog
validAfterstring
validBeforestring
valuestring

Variables

CHECKOUT_VCT

const CHECKOUT_VCT: "mandate.checkout.1" = "mandate.checkout.1"


checkoutMandate

const checkoutMandate: 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: readonly CheckoutOption[]; }]; 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

const checkoutMandateX402: 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: readonly CheckoutOption[]; }]; 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

const issuedDigest: typeof digestJson = 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

ParameterType
punknown

Returns

Promise<Refusal | { payload: Payload; }>


checkoutJwtOf()

checkoutJwtOf(m): Promise<string | Refusal>

The checkout_jwt the mandate discloses.

Parameters

ParameterType
mstring

Returns

Promise<string | Refusal>


jwsPayload()

jwsPayload(j): Refusal | Payload

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

ParameterType
jstring

Returns

Refusal | Payload


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

ParameterType
munknown

Returns

Promise<Refusal | MandateContent>


tie()

tie(options): ["ap2", { options: readonly CheckoutOption[]; }]

The binding slot: the checkouts this ATR was minted for, each by its own id.

Parameters

ParameterType
optionsreadonly 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

ParameterType
networkunknown

Returns

`eip155:${string}` | undefined

References

Broadcaster

Re-exports Broadcaster

Last updated on

On this page