UCP + Payment Primitives
UCP defines standard checkout flows that work with any payment provider.
Checkout Flow
Step 1: Cart Creation
AI agent creates a cart with selected products:
{
"items": [
{
"product_id": "prod_123",
"variant_id": "var_123_1",
"quantity": 1
}
]
}
Step 2: Shipping Address
AI agent provides shipping address:
{
"shipping_address": {
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94102",
"country": "US"
}
}
Step 3: Shipping Options
Your endpoint returns available shipping options:
{
"shipping_options": [
{
"id": "standard",
"name": "Standard Shipping",
"cost": {
"amount": 599,
"currency": "USD"
},
"estimated_days": 5
}
]
}
Step 4: Payment Method Selection
AI agent selects payment method (handled by your payment provider):
{
"payment_method": {
"type": "card",
"token": "payment_token_from_provider"
}
}
Step 5: Order Confirmation
Your endpoint processes payment and returns order confirmation:
{
"order_id": "order_123",
"status": "confirmed",
"estimated_delivery": "2026-02-10"
}
Payment Integration
Payment Provider Integration
UCP works with any payment provider:
- Stripe: Use Stripe Payment Intents
- PayPal: Use PayPal Orders API
- Square: Use Square Payments API
- Custom: Implement your own payment processing
Security Considerations
- Never store full payment details
- Use tokenized payment methods
- Implement PCI-DSS compliance
- Require authentication for sensitive operations
Error Handling
Payment Failures
Return clear error messages:
{
"error": {
"code": "payment_failed",
"message": "Payment method declined",
"retryable": true
}
}
Inventory Issues
Handle out-of-stock items:
{
"error": {
"code": "out_of_stock",
"message": "Product no longer available",
"items": ["prod_123"]
}
}
Best Practices
1. Validate Before Processing
- Verify inventory availability
- Validate shipping address
- Confirm payment method
2. Provide Clear Errors
- Use standard error codes
- Include actionable messages
- Indicate if retry is possible
3. Handle Edge Cases
- Concurrent purchases
- Price changes during checkout
- Inventory depletion
Next Steps