What This Guide Covers
This guide explains everything you need to integrate PayPal’s Cart API v1 into your e-commerce platform using the unified PayPalCart schema. By the end of this guide, you’ll understand:- How the PayPal Cart API fits into your checkout flow
- When to use each API endpoint and why
- How to handle complex scenarios (variants, discounts, age verification, gift cards)
- Common integration mistakes and how to avoid them
- Complete HTTP examples and implementation patterns you can adapt to your tech stack
Quick Overview
The Modern Commerce Architecture
PayPal’s Cart API enables agentic commerce - where AI agents handle shopping on behalf of customers through a sophisticated integration chain:- Customers interact naturally with AI agents using voice or chat
- AI Agents understand intent and make shopping decisions automatically
- PayPal Commerce Platform orchestrates the entire payment and cart flow
- PayPal Catalog provides catalog ingestion, product discovery, and validation - routing to the right merchant API based on product selection
- Your Merchant API handles inventory, pricing, and order fulfillment
The Complete Flow
1. Product Discovery
2. Cart Creation & Management
3. Seamless Checkout
Key Architecture Benefits
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
For Merchants:
- 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
For Developers:
- 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
Understanding Cart Status Fields
The PayPal Cart API uses three key status indicators that work together to tell PayPal what’s happening with a cart:The Three Status Fields Explained
1. status
- Business Outcome (Merchant Controlled)
What it means: What happened in your merchant system for this operation
Values:
CREATED
- Cart successfully created, ready for useINCOMPLETE
- Cart has issues that need resolutionREADY
- Cart is validated and ready for checkoutCOMPLETED
- Order has been finalized and payment captured
2. validation_status
- Item & Data Validation
What it means: Whether the cart contents and data are valid for checkout
Values:
VALID
- Ready for Checkout
- All items available with current pricing
- Required information complete (shipping address, customer data)
- No business rule violations
validation_issues
array is empty- Can proceed directly to checkout
INVALID
- Has Problems That Block Checkout
- Items out of stock, price changes, business rule violations
- Invalid or incomplete data that needs correction
validation_issues
array contains specific problems- Customer/AI agent must resolve issues before checkout
REQUIRES_ADDITIONAL_INFORMATION
- Needs More Data
- Missing optional but required fields (shipping address, checkout fields)
- Age verification, custom fields, delivery preferences needed
- Items and pricing are valid, just needs customer input
validation_issues
array indicates what information is needed
3. validation_issues
- Specific Problems with Type Classification
What it means: Detailed list of issues that need resolution with clear categorization
Structure:
MISSING_FIELD
- Required information missing (shipping address, checkout fields, etc.)INVALID_DATA
- Provided data is incorrect or invalidBUSINESS_RULE
- Business logic violations (out of stock, minimum order, etc.)
validation_status Decision Matrix
When to use each validation_status: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 |
REQUIRES_ADDITIONAL_INFORMATION
= “We need more input, but what you’ve provided is valid”INVALID
= “There’s a problem that must be fixed before we can proceed”
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
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
Real-World Scenario
Simple T-Shirt Store
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 Info
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
Key Points
- 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
How to Handle JWT Tokens:
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 Explained
Unified PayPalCart Schema
POST /merchant-cart - Create Cart
Basic Creation
Advanced Creation (Everything at Once)
PUT /merchant-cart/ - Update Cart
Note: PUT replaces the ENTIRE cart - any fields not included in your request will be removed/reset. This is a complete replacement operation, not a merge.WRONG: This will remove customer info, shipping address, checkout fields, etc. Result: Cart now ONLY has items field - everything else is gone!
POST /merchant-cart//checkout - Complete Checkout
PayPal Orders API Integration Pattern
Overview
When implementing the PayPal 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.Key Integration Points
1. Initial Cart Creation → CREATE Order
2. Cart Updates → PATCH Order
When to CREATE vs 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 |
Implementation Examples
Cart Creation with Order
Cart Update with Order PATCH
Error Handling Guide
Instead of handling dozens of specific error cases, focus on these 3 essential patterns:- Can you fix this automatically? → Fix it
- Can the customer fix this? → Show them how
Common Error Pattern
Inventory & Stock Management Errors
Out of Stock with Alternatives
Back-Order Scenario
Discontinued Product
Pricing & Financial Errors
Price Change During Checkout
Shipping & Address Errors
Invalid Shipping Address
PO Box Restrictions
Geographic & Legal Restrictions
Regional Sales Restrictions
System & Store Errors
Store Maintenance Mode
Error Handling Implementation Strategy
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/)
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: High priority = immediate action needed
- Context-rich: Enough information for intelligent decision making
- Resolution metadata: Helps AI choose best resolution path
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
Gift Card Advanced Features
Geographic Coordinates
Lat/Lng 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
Integration Checklist
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