Proposed spec addition for bill/basket support in v2 #683
+290
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed spec addition for bill/basket support in v2
Description
This PR introduces the
basketfield as an optional protocol extension to x402 v2, enabling structured, machine-readable representations of itemized line items in payment requests. This allows clients to render detailed invoices, receipts, and shopping carts without custom parsing logic.Motivation
Currently, x402 v2 uses the
extrafield for additional payment information, but this is an unstructured object that requires custom client-side parsing. Thebasketfield provides a standardized schema for common use cases like:This aligns x402 with modern payment APIs (Stripe, Square, PayPal) that expose structured line items.
Key Features
idfield for inventory tracking, refunds, and correlation (follows Stripe ACP pattern)metadatafield for custom item data (UPCs, categories, etc.)extrafield, doesn't replace itExample
{ "scheme": "exact", "network": "base", "maxAmountRequired": "27130000", "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "payTo": "0x...", "extra": "Grocery purchase (3 items)", "basket": [ { "id": "item_bananas_001", "name": "Organic Bananas (lb)", "price": "1990000", "quantity": 3, "metadata": {"upc": "4011"} }, { "id": "item_milk_002", "name": "Milk - Whole (1 gal)", "price": "4990000", "quantity": 2, "tax": "350000", "metadata": {"upc": "041303001264"} }, { "id": "item_coffee_003", "name": "Coffee Beans - Ethiopia (12oz)", "price": "14990000", "quantity": 1, "discount": "2000000", "metadata": {"member_discount": true} } ] }Design Rationale
Why strings for price/tax/discount?
MAX_SAFE_INTEGER(1 ETH = 10^18 wei)uint256representationbase_amountformatamountfieldsTests
Schema Validation
python3 -m json.tool)Documentation
PaymentRequirementsFile Organization
Follows the standard x402 scheme proposal structure (per PR #537):
Checklist
Additional Context
Real-World Usage
Latinum.ai is piloting basket support with Shuppa, a grocery delivery service in Dublin, as one of the first real-world grocery payment deployments on x402 v2 (https://latinumai.substack.com/p/what-did-we-learn-from-running-the). While still early-stage, this pilot has validated the schema's practical design for retail scenarios:
As x402 adoption grows beyond memecoin transfers, structured basket data will be essential for enabling real commerce use cases like grocery delivery, e-commerce, and SaaS billing.
Stripe Agentic Commerce Protocol (ACP) Compatibility
https://github.com/agentic-commerce-protocol/agentic-commerce-protocol/blob/main/spec/json-schema/schema.agentic_checkout.json
The basket schema is ~90% compatible with Stripe's Agentic Commerce Protocol:
Compatible elements:
idfield)price↔base_amount)x402 enhancements:
itemobject)discountfield (ACP lacks per-item discounts)Merchants can easily convert between formats with simple field mapping, enabling interoperability between x402 and ACP-based systems.
Open Questions