PayPalCart schema.
Important: To access and use store sync, including cart orchestration, merchants must complete this form to contact the AI team at PayPal and request access.This guide explains:
- How PayPal’s Cart API fits into your checkout flow
- When to use each API endpoint and why
- How to handle complex scenarios, including variants, discounts, age verification, and gift cards
- Common integration mistakes and how to avoid them
Modern commerce architecture
PayPal’s Cart API enables agentic commerce, where AI agents handle shopping on behalf of customers through a sophisticated integration chain. This architecture connects customers, AI agents, and merchant systems seamlessly, creating a new paradigm for online shopping.- Customers interact naturally with AI agents using voice or chat.
- AI agents assess intent and make shopping decisions for customers.
- PayPal’s Commerce Platform orchestrates the entire payment and cart flow.
- PayPal Catalog provides catalog ingestion, product discovery, and validation. It uses product selections to route orders to the correct merchant API.
- The merchant’s API handles inventory, pricing, and order fulfillment.
1. Product discovery
The shopping journey begins when customers express their needs in natural language. The AI agent interprets this intent and searches PayPal’s ingested catalog to find matching products across multiple merchants.2. Cart creation and management
After a customer selects products, the AI agent creates and manages the shopping cart through PayPal’s Commerce Platform. This process validates product availability, pricing, and shipping options in real-time with your merchant API.3. Seamless checkout
The final step completes the purchase without requiring customers to leave the conversation. PayPal’s Smart Wallet handles payment authentication and processing while the AI agent confirms order details.Benefits
This integration delivers value across all stakeholders in the commerce ecosystem. Here’s how each party benefits from the agentic commerce approach. For customers:- Natural conversation - No complex navigation or forms
- Intelligent assistance - AI understands preferences and context
- Seamless payments - PayPal smart wallet integration
- Proactive updates - AI handles tracking and delivery information
- Automated orders - AI agents create perfect carts without human intervention
- Reduced friction - Customers never leave the conversation
- Higher conversion - AI optimizes for successful purchases
- Future-ready - Built for the next generation of commerce
- Simple integration - Just implement the merchant API endpoints using unified PayPalCart schema
- Honey handles discovery - Catalog ingestion and product routing intelligence
- Real-time inventory - Your API provides live pricing and availability
- Rich error handling - Clear validation and resolution options
Cart status fields
The PayPal Cart API uses three key status indicators that work together to communicate cart state and validation issues. Understanding these fields is crucial for proper error handling and cart lifecycle management.1. status - Business outcome (merchant controlled)
Indicates what happened to the cart
| Value | Description |
|---|---|
CREATED | Cart was successfully created and is ready for use |
INCOMPLETE | Cart has issues that need resolution |
READY | Cart is validated and ready for checkout |
COMPLETED | Order is finalized and payment was captured |
2. validation_status - Item and data validation
Indicates whether the cart contents and data are valid for checkout:
- All items are available with current pricing.
- Required information is complete (shipping address, customer data).
- No business rule violations exist.
- The
validation_issuesarray is empty. - Transaction can proceed to checkout.
| Value | Description |
|---|---|
VALID | Ready for checkout |
INVALID | Has problems that block checkout |
| Needs more data to proceed |
REQUIRES_ADDITIONAL_INFORMATION, the validation_issues array indicates what information is needed, for example:
- Required fields are missing (shipping address, checkout fields).
- Items and pricing are valid but require additional customer input.
3. validation_issues - Specific problems with type classification
Detailed list of issues that need resolution with clear categorization
| Field | Description |
|---|---|
MISSING_FIELD | Required information missing (shipping address, checkout fields, etc.) |
INVALID_DATA | Provided data is incorrect or invalid |
BUSINESS_RULE | Business logic violations (out of stock, minimum order, etc.) |
validation_status decision matrix
Available statuses can be one of the following options.
| Status | Description |
|---|---|
VALID | Everything is in order for checkout |
REQUIRES_ADDITIONAL_INFORMATION | Value is valid, but more data is needed to proceed |
INVALID | Intervention is necessary before the transaction can continue |
| Situation | validation_status | validation_issues | Action Required |
|---|---|---|---|
| All good, ready for checkout | VALID | [] (empty) | Proceed to checkout |
| Missing shipping address | REQUIRES_ADDITIONAL_INFORMATION | [{code: "DATA_ERROR", type: "MISSING_FIELD", context: {specific_issue: "MISSING_SHIPPING_ADDRESS"}}] | Collect shipping address |
| Age verification needed | REQUIRES_ADDITIONAL_INFORMATION | [{code: "DATA_ERROR", type: "MISSING_FIELD", context: {specific_issue: "MISSING_CHECKOUT_FIELDS"}}] | Complete age verification |
| Item out of stock | INVALID | [{code: "INVENTORY_ISSUE", type: "BUSINESS_RULE"}] | Remove item or suggest alternatives |
| Price changed | INVALID | [{code: "PRICING_ERROR", type: "BUSINESS_RULE"}] | Customer must accept new price |
| Invalid postal code | INVALID | [{code: "SHIPPING_ERROR", type: "INVALID_DATA"}] | Correct address format |
| Payment declined | INVALID | [{code: "PAYMENT_ERROR", type: "BUSINESS_RULE"}] | Try different payment method |
Common Status Combinations
| Scenario | HTTP Status | Cart status | validation_status | validation_issues |
|---|---|---|---|---|
| Cart Created Successfully | 201 Created | CREATED | VALID | [] |
| Item Out of Stock | 200 OK | INCOMPLETE | INVALID | [{code: "INVENTORY_ISSUE", type: "BUSINESS_RULE", context: {specific_issue: "ITEM_OUT_OF_STOCK"}}] |
| Missing Shipping | 200 OK | INCOMPLETE | REQUIRES_ADDITIONAL_INFORMATION | [{code: "DATA_ERROR", type: "MISSING_FIELD", context: {specific_issue: "MISSING_SHIPPING_ADDRESS"}}] |
| Ready for Checkout | 200 OK | READY | VALID | [] |
| Order Completed | 200 OK | COMPLETED | VALID | [] |
HTTP status code strategy
The PayPal Cart API uses a combination of HTTP status codes and cart status fields to communicate the outcome of requests.Business logic issues → 200 OK + validation_issues
Use200 OK for business scenarios that AI agents can understand and potentially resolve:
- Cart validation issues (out of stock, price changes)
- Missing required information (shipping address, checkout fields)
- Payment processing issues (declined payments, business rules)
Technical issues → HTTP error codes
Use proper HTTP error codes for technical problems:400 Bad Request- Invalid request format, missing required parameters404 Not Found- Cart ID doesn’t exist500 Internal Server Error- System failures, service unavailable
Scenario
Imagine a simple customer interaction where an AI agent helps a customer find and purchase a blue t-shirt.Customer: “I need a medium blue t-shirt” AI Agent: processes intent and searches inventory AI Agent: creates cart via PayPal Commerce Platform, orchestrating with the Merchant API
AI agent: “Found perfect blue t-shirt in medium! $25 total. Ready to checkout?”
PayPal Cart API returns cart information
AI completes checkout
AI Agent: “Ready to checkout with PayPal?” Customer: “Yes, proceed” AI Agent: seamlessly handles PayPal smart wallet approval (no redirect needed)
AI Agent: “Order confirmed! Your t-shirt will arrive Tuesday.”
Authentication - PayPal-supplied JWT tokens
- PayPal-issued - Tokens are generated and managed by PayPal, not merchants.
- Request authentication - Included in Authorization header for every API call.
- Merchant identification - Token contains merchant ID and permissions.
- Security verification - Verify token signature using PayPal’s public keys.
1. Receive token in authorization header
2. Verify token
- Parse Authorization header: “Bearer <token>”
- Verify token signature using PayPal public keys
- Validate token expiration
- Check required scopes (e.g., “cart”, “complete”)
API endpoints
The Cart API provides 3 core endpoints that handle the complete cart lifecycle. Each endpoint serves a specific purpose in the shopping flow.Unified PayPalCart schema
POST /merchant-cart - Create cart
Creates a new shopping cart with specified items, customer info, shipping address, and payment method.
Basic creation
Advanced creation (everything at once)
PUT /merchant-cart/{id} - Update cart
Updates an existing cart by replacing its contents with the provided data. Use this endpoint to add or remove items, change quantities, update shipping address, apply discounts, and so on.
Note: PUT replaces the ENTIRE cart. Any fields that you do not include in your request will be removed or reset. This is a complete replacement operation, not a merge.Include ALL current cart data when making changes, as shown in the following example.
POST /merchant-cart/{id}/checkout - Complete checkout
PayPal Orders API Integration Pattern
Behind the scenes, the PayPal Cart API integrates with PayPal’s Orders API v2 to manage payment tokens and process transactions. Understanding this relationship helps you implement proper payment handling. When implementing the Cart API, merchants must integrate with PayPal Orders API v2 to handle payment tokens and order updates. This section clarifies when to CREATE vs PATCH orders based on cart lifecycle.1. Initial cart creation → CREATE order
2. Cart updates → PATCH order
When to CREATE or PATCH
| Scenario | PayPal Orders Action | Reason |
|---|---|---|
| Initial cart creation | POST /v2/orders | Create new payment context |
| Add/remove items | PATCH /v2/orders/{id} | Update totals |
| Apply/remove coupons | PATCH /v2/orders/{id} | Update totals |
| Update shipping address | PATCH /v2/orders/{id} | Update shipping + tax |
| Change quantities | PATCH /v2/orders/{id} | Update totals |
| Payment token expired | POST /v2/orders | Create fresh payment context |
| New cart after checkout | POST /v2/orders | New transaction |
Examples
The following code snippets illustrate how to implement cart creation and updates.Cart creation with order
Cart update with order PATCH
Error handling guide
Effective error handling is critical for maintaining a smooth shopping experience. The API provides rich error context that enables AI agents to resolve issues automatically or guide customers to resolution. Instead of handling dozens of specific error cases, focus on these essential patterns:- Can you fix this automatically? → Fix it
- Can the customer fix this? → Show them how
Common error pattern
Inventory and stock management errors
Inventory issues are among the most common errors in e-commerce. These examples show how to handle out-of-stock scenarios, back-orders, and discontinued products gracefully.Out of stock with alternatives
Back-order scenario
Discontinued product
Pricing and financial Errors
Price changes can occur between cart creation and checkout. These error patterns help you handle pricing discrepancies transparently while maintaining customer trust.Price change during checkout
Shipping and address errors
Address validation ensures successful delivery while preventing fraud. These examples demonstrate handling invalid addresses, PO Box restrictions, and shipping limitations.Invalid shipping address
PO box destrictions
Geographic and legal restrictions
Some products or merchants have regional restrictions due to regulations or business policies. These errors help communicate limitations clearly to customers.Regional sales restrictions
System and store errors
Temporary system issues require special handling to maintain customer relationships. These patterns show how to communicate maintenance windows and system unavailability.Store maintenance mode
Error handling implementation strategy
When implementing error handling for the PayPal Cart API, use the following guidelines to determine appropriate HTTP status codes and error responses.200 OK + validation_issues
- Inventory changes (out of stock, back-ordered)
- Price changes during checkout
- Payment processing issues that can be resolved
- Geographic restrictions
- Discount validation failures
- Customer account issues
- Address validation problems
422 Unprocessable entity
This should be used when encountering anyvalidation_issue that would prevent you from creating a cart. For instance, if you do not create a cart for an OUT_OF_STOCK issue, you would send back a 422 Unprocessable Entity error with details about the error in the body.
Refer to the API Spec for how Errors should be formatted
400 Bad request
- Invalid JSON format
- Missing required fields (items array)
- Invalid field types or formats
- Malformed request structure
- Invalid cart ID format (e.g., doesn’t match expected pattern like “CART-[A-Z0-9]+“)
404 not found
- Cart ID doesn’t exist in merchant’s system (well-formed ID but not found)
- Invalid endpoint paths
Cart retrieval error handling (GET /merchant-cart/{cartId})
Example 1: Invalid cart ID format (400 response)
500 internal server error
- System failures
- Database connectivity issues
- Payment processor unavailable
- Unexpected server errors
Error context best practices
- Provide Rich Context: Include all relevant information for smart resolution.
- Customer-Friendly Messages: Write user_message for end customers.
- Technical Details: Include technical message for developers.
- Resolution Guidance: Always provide actionable next steps.
- Cost Impact: Show financial implications of resolution options.
- Time Estimates: Provide realistic timeframes for resolutions.
AI agent considerations
Errors are designed for AI agents to handle autonomously:- Auto-applicable actions: AI can resolve without human intervention.
- Priority guidance: Immediate action is required.
- Context-rich: The system has enough information for intelligent decision making.
- Resolution metadata: The system helps AI choose best resolution.
Resolution action types
| Action | Use Case | Auto-applicable |
|---|---|---|
ACCEPT_NEW_PRICE | Price increases | No |
ACCEPT_BACK_ORDER | Inventory delays | Depends on customer preference |
SUGGEST_ALTERNATIVE | Out of stock items | Yes |
UPDATE_ADDRESS | Address validation | Yes (if correction available) |
REMOVE_ITEM | Restriction violations | Depends on item importance |
SPLIT_ORDER | Payment limits | Yes |
CONTACT_SUPPORT | Complex issues | No |
RETRY_LATER | Temporary failures | Yes |
Advanced use cases
Beyond basic cart operations, the API supports sophisticated scenarios like gift cards and location-based services. These examples demonstrate advanced integration capabilities.Gift cards
Geographic coordinates
Some merchants offer location-based services that require precise geographic positioning beyond standard postal addresses. The Cart API supports optional latitude/longitude coordinates to enable features like local inventory checking, distance-based pricing, delivery radius validation, and enhanced shipping calculations. This geographic data operates independently from shipping addresses, allowing you to provide location-aware commerce experiences while maintaining clean separation between postal and coordinate data.Latitute and longitude support strategy
Geographic coordinates are optional. It is designed for merchants who can provide enhanced location services. Geographic coordinates are provided in a separategeo_coordinates field, distinct from the shipping_address object. This clean separation allows:
- Postal addresses to remain focused on standard shipping data
- Geographic coordinates to provide precise location enhancement
- Independent handling of address vs. coordinate data
- Graceful degradation when coordinates aren’t supported
Geographic fields
latitude&longitude: Precise WGS84 coordinates in decimal degreessubdivision: Administrative division (state, province, region) using ISO 3166-2 formatcountry_code: ISO 3166-1 alpha-2 country code for the coordinate location
- US:
subdivision: "CA"(California),country_code: "US" - Canada:
subdivision: "ON"(Ontario),country_code: "CA" - UK:
subdivision: "ENG"(England),country_code: "GB"
Testing your integration
Comprehensive testing ensures your integration handles all scenarios correctly. Use this checklist and test scenarios to validate your implementation before going live.Integration checklist
Before you launch your integration, verify that your implementation handles all critical scenarios correctly. This checklist covers the essential functionality, error states, and edge cases that ensure a robust commerce experience. Work through each item systematically to confirm your integration can handle real-world usage patterns and recover gracefully from common issues.Basic Functionality
- Can create cart with simple items
- Can handle PayPal payment (smart wallet)
- Can handle successful payment return
- Can complete checkout and get order confirmation
- Can handle payment cancellation
Cart Updates
- Can update shipping address via PUT
- Can add/remove items via PUT
- Can apply and remove coupon codes
- Can handle cart validation errors
- Can update checkout field values
Error Handling
- Out of stock items are handled gracefully
- Invalid addresses are caught and corrected
- Network errors don’t break the flow
- Payment failures are handled properly