Skip to content

Implement a UCP API Bridge Module #1476

@muratcakir

Description

@muratcakir

The UCP API Bridge Module enables "Agentic Commerce" by providing a standardized interface for AI agents (like Google Gemini). It handles the discovery of shop capabilities, manages autonomous shopping sessions, and triggers the headless checkout process.


Conceptual Building Blocks

1. Discovery Endpoint (.well-known/ucp)

This is the "Hello World" of UCP. It tells the AI agent that this Smartstore instance is UCP-capable and where to find the API endpoints.

  • Purpose: Expose a static or dynamic JSON file.
  • Pseudo-Code:
GET /.well-known/ucp 
=> Return { version: "1.0", endpoints: { session_create, checkout_complete }, public_keys: [...] }

2. UCP Session Management

AI agents need "sticky" pricing and inventory data while they "think" or compare products.

  • Purpose: Map an AI request to a temporary Smartstore quote or shopping cart.
  • Logic:
  • Validate product availability.
  • Calculate real-time prices including taxes (via ITaxService).
  • Freeze the price for a specific duration (e.g., 15 minutes).
  • Return a session_id to the agent.

3. Headless Checkout Orchestration

The bridge between the AI agent and the IOrderProcessingService.

  • Purpose: Convert the agent's final intent into a Smartstore order.
  • Workflow:
  • Receive session_id, shipping address, and payment_token.
  • Initialize a ProcessPaymentRequest with IsUcpTransaction = true.
  • Pass the token into the UcpPaymentToken property.
  • Trigger PlaceOrderAsync.

4. Security & Signature Verification

To prevent fraud, every request from an AI agent must be cryptographically signed.

  • Purpose: Ensure the request actually comes from a verified AI provider (e.g., Google).
  • Logic: Implement an Action Filter that verifies the UCP-Signature header against the provider's public keys before any controller logic is executed.

Proposed Plugin Structure

Component Responsibility
DiscoveryController Handles the .well-known/ucp route.
SessionController Handles session_create and session_update.
CheckoutController Handles checkout_complete.
UcpSessionService Manages the lifecycle of agent sessions in the DB.
SignatureRequirement Middleware/Filter for cryptographic request validation.

Implementation Tasks

  • Routing: Register the standardized .well-known route in the RouteProvider.
  • Models: Create DTOs for UCP 1.0 (Request/Response schemas).
  • Price Calculation: Integrate with Smartstore’s IPriceCalculationService to provide "Agent-Guaranteed" pricing.
  • Checkout Bridge: Map UCP shipping and payment data to the enhanced ProcessPaymentRequest.
  • Testing: Create a mock tool to simulate an AI agent sending signed JSON payloads.

Summary

The UCP Bridge Plugin doesn't replace the Smartstore checkout; it provides a second, headless door to it. It leverages the Core's new ability to process tokenized payments while maintaining all existing business rules (taxes, shipping costs, stock management).

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions