What You’ll Build
An API that integrates with PayPal’s Shopping Cart service for AI-powered commerce- Receive cart requests from PayPal Commerce Platform to validate products, calculate taxes & shipping
- Handle updates to the cart like shipping options and line items
- Complete orders by processing PayPal payments and fulfilling shipments
30-Second Overview
PayPal Cart API enables agentic commerce - AI agents shopping on behalf of customers:What this means for you as a merchant on PayPal’s Commerce Platform
- Customers interact with AI agents in natural language
- AI agents understand intent and search for products via PayPal’s Commerce Platform
- PayPal Commerce Platform validates requests and routes to your merchant API
- Your API validates products, calculates pricing, handles inventory and orders
Your merchant API endpoints:
POST /merchant-cart
- create a new cartPUT /merchant-cart/{id}
- make updates to a cart (complete replacement)POST /merchant-cart/{id}/checkout
- complete the cart and fulfill the order
System Flow Diagram
Quick Start Integration
Step 1: Handle Incoming Cart Creation from PayPal Commerce Platform
When a customer interacts with an AI agent to buy something, PayPal Commerce Platform will call your API endpoint like this:id
- Cart identifier for GET/PUT/PATCH/checkout operationsec_token
- PayPal payment token (required for checkout completion)status
- Cart state (CREATED/INCOMPLETE/READY/COMPLETED)validation_issues
- Array of problems that need fixing (empty = good)
ec_token
enables PayPal payment for the customer.
Step 2: PayPal Handles Payment with Customer
What happens next:- PayPal Commerce Platform presents the cart to customer for approval
- Customer approves payment via PayPal’s Agentic Checkout APIs
- PayPal returns payment approval details to complete the checkout
- Your API receives the checkout completion request (Step 3)
Step 3: Handle Order Completion Request
After customer approves payment, PayPal Commerce Platform calls your API to complete the order:token
- Theec_token
returned during cart creationtype
- Currently “paypal” for PayPal payments
Developer Quick Reference
HTTP Status Patterns
Status | Meaning | Response Content | Action |
---|---|---|---|
201 Created | Cart created successfully | Full cart + ec_token | Proceed to payment |
200 OK | Operation successful | Full cart object | Check status field |
200 OK + validation_issues | Business logic issues | Full cart + problems | Fix issues shown |
400 Bad Request | Invalid request | Error object | Fix request format |
404 Not Found | Cart doesn’t exist | Error object | Use valid cart ID |
500 Server Error | System problem | Error object | Retry or contact support |
Cart Status Values
CREATED
- Cart successfully created with ec_token, ready for immediate paymentINCOMPLETE
- Has validation issues that need fixing (check validation_issues)READY
- Previously incomplete cart now resolved, ready for paymentCOMPLETED
- Order finished, payment captured
Common Status Combinations
Scenario | HTTP Status | Cart Status | validation_issues | Next Step |
---|---|---|---|---|
✅ Cart Created | 201 Created | CREATED | [] | Proceed to payment |
⏳ Needs Info | 200 OK | INCOMPLETE | [{...}] | Fix validation issues |
🚀 Ready | 200 OK | READY | [] | Complete checkout |
✅ Completed | 200 OK | COMPLETED | [] | Order fulfilled |
Common validation_issues
Simple validation error (minimal fields):Error Categories
INVENTORY_ISSUE
- Stock, availability, back-orders, discontinued itemsPRICING_ERROR
- Price changes, discounts, tax calculation, currency issuesSHIPPING_ERROR
- Address validation, delivery restrictions, shipping zonesPAYMENT_ERROR
- Payment limits, currency support, processor issuesDATA_ERROR
- Field validation, format issues, required fieldsBUSINESS_RULE_ERROR
- Account restrictions, compliance, regional limits
Types
MISSING_FIELD
- Need more info (address, checkout fields)INVALID_DATA
- Data validation failedBUSINESS_RULE
- Business logic violation (out of stock, etc.)
Customer Information Availability
- Initial cart creation - Customer info may be absent (anonymous shopping)
- After PayPal approval - Customer info available in checkout completion request
- Returning customers - Customer info may be available from start