Build and verify a Google AP2 Cart Mandate chain so a merchant can confirm item, price, and shipping are cryptographically locked before accepting payment
Install the AP2 Python SDK (pip install ap2-sdk) or use the TypeScript reference from the github.com/google-agentic-commerce/AP2 repo; the canonical models live under ap2/models/ as Pydantic classes.
When an agent presents a cart, call the merchant's UCP endpoint and receive the returned CartMandate JSON object containing item list, total price, shipping details, and the merchant's ECDSA cryptographic signature.
Verify the merchant signature on the CartMandate using the SDK's verify_cart_mandate() helper, which checks the ECDSA signature against the merchant's published public key.
Construct a PaymentMandate referencing the CartMandate ID, attach the user's authorization token or cryptographic signature, and submit to the credential provider (e.g., PayPal or Mastercard via their AP2 extension).
The merchant receives both mandates, re-verifies its own CartMandate signature and the user's PaymentMandate signature before capturing payment; the SDK's verify_payment_mandate() performs both checks.
Log the full mandate chain (IntentMandate → CartMandate → PaymentMandate) to your audit store; AP2 mandates are W3C Verifiable Credentials and serve as the dispute evidence record.
Known gotchas
AP2 v0.2.0 (shipped April 2026) introduced breaking changes to the PaymentMandate schema; check the CHANGELOG before upgrading from v0.1.x.
The CartMandate is immutable once signed — price or item changes require issuing a new CartMandate; agents must not re-use a stale mandate for a modified cart.
ECDSA key rotation is the merchant's responsibility; publish your public keys in a well-known directory and invalidate old keys promptly, or mandate verification will fail for all in-flight transactions.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp