∂ systems π payments ∇ AI / ML λ career

Building a UCP Middleware: Connecting Gemini AI to SFCC and Adyen

How I designed and built the Universal Checkout Protocol middleware at Tapestry — a Spring Boot service bridging Gemini AI agents, Salesforce Commerce Cloud, and Adyen payments.

Arindam Paria · · 2 min read

When Salesforce Commerce Cloud doesn’t speak to an AI agent natively, you build the interpreter yourself. This is that story.

The Problem Space

The challenge was bridging three systems that were not designed to talk to each other:

  • Gemini AI — the orchestration brain, issuing natural-language tool calls
  • SFCC (Storefront Reference Architecture) — a complex B2C commerce platform
  • Adyen — the payment processor requiring PCI-compliant token flows

Architecture Overview

Here is a look at the middleware in action. Notice how we decouple the intent from the execution:

checkout-handler.ts
export class UcpMiddleware {
async handleIntent(intent: CheckoutIntent) {
// 1. Verify token with Adyen
const token = await this.adyen.verifyToken(intent.paymentData);
// 2. Hydrate SFCC basket
const basket = await this.sfcc.hydrateBasket(intent.basketId);
if (!token.valid) {
throw new PaymentVerificationError("Token failed 3DSecure");
}
return this.sfcc.submitOrder(basket, token);
}
}
Definition — Universal Checkout Protocol (UCP)

A standard format for exchanging multi-stage, state-dependent transactional payloads between a non-deterministic agentic system and a deterministic legacy commerce engine.

State transition probability

P(St+1St,at)=k=1KP(st+1(k)parents(st+1(k)))P(S_{t+1} | S_t, a_t) = \prod_{k=1}^{K} P(s^{(k)}_{t+1} | \text{parents}(s^{(k)}_{t+1}))

(1)

This ensures that the state transition remains fully observable and reversible by the agent if Adyen rejects the payload.