• Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Меч Moscow
Комплексная e-commerce платформа на Medusa для московского fashion-бренда

Меч Moscow · Fashion

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
A

Agentic commerce

Agentic commerce plugin for Medusa v2 — adds UCP and ACP protocol support, enabling AI agents to browse, checkout, and pay at any Medusa storefront.

npm install @financedistrict/medusa-plugin-agentic-commerce
Категория
Другое
Создано
Financedistrict
Версия
0.1.10
Последнее обновление
2 месяца назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
0
npmNPM

@financedistrict/medusa-plugin-agentic-commerce

Make your Medusa v2 store shoppable by AI agents.

This plugin adds UCP and ACP protocol endpoints to your Medusa backend, so AI shopping agents can discover your products, create checkouts, and complete purchases — through standard HTTP APIs that require no frontend at all.

Why this matters

AI agents are becoming the next commerce channel. Just like merchants once added mobile apps alongside their websites, they'll soon need to serve autonomous agents that shop on behalf of consumers. But agents don't browse — they need structured APIs with standardized discovery, checkout flows, and payment settlement.

UCP (Universal Commerce Protocol) and ACP (Agentic Commerce Protocol) are the emerging open standards for this. This plugin implements both as native Medusa v2 modules, so your store speaks the language agents understand — in minutes, with no custom code and no frontend changes.

What you get

FeatureDescription
Dual protocol supportBoth UCP and ACP endpoints from a single plugin
Product discoveryFull-text search and direct lookup for agents to browse your catalog
Checkout sessionsCreate, update, complete, and cancel — with idempotency built in
Pluggable paymentsBring your own payment handler via the adapter interface
Order trackingAgents can retrieve order status and details
Webhook notificationsAutomatic agent callbacks on order placement
Protocol discovery and for automatic capability detection
Product feed syncScheduled job to push your catalog to agent platforms

Quick Start

1. Install

npm install @financedistrict/medusa-plugin-agentic-commerce

2. Configure

1import { defineConfig } from "@medusajs/framework/utils"
2
3export default defineConfig({
4 // Register the plugin for route/workflow/subscriber auto-discovery
5 plugins: [
6 {
7 resolve: "@financedistrict/medusa-plugin-agentic-commerce",
8 options: {},
9 },
10 ],
11 modules: [
12 // Register the core service module with your configuration
13 {
14 key: "agenticCommerce",
15 resolve: "@financedistrict/medusa-plugin-agentic-commerce/modules/agentic-commerce",
16 options: {
17 api_key: process.env.AGENTIC_COMMERCE_API_KEY,
18 signatureKey: process.env.AGENTIC_COMMERCE_SIGNATURE_KEY,
19 storefront_url: process.env.STOREFRONT_URL || "https://your-store.com",
20 store_name: "Your Store Name",
21 store_description: "What your store sells",
22 // Reference payment handler adapter module keys (see Payment Handlers)
23 payment_handler_adapters: ["prismPaymentHandler"],
24 },
25 },
26 ],
27})

3. Set Environment Variables

1# Required
2AGENTIC_COMMERCE_API_KEY=your-secret-api-key
3
4# Optional
5AGENTIC_COMMERCE_SIGNATURE_KEY=your-hmac-secret
6STOREFRONT_URL=https://your-store.com
7AGENTIC_STORE_NAME="Your Store"
8AGENTIC_STORE_DESCRIPTION="Premium widgets for humans and agents"

4. Start Your Store

npx medusa develop

Your agent APIs are now live:

1# Discovery
2curl http://localhost:9000/.well-known/ucp
3curl http://localhost:9000/.well-known/acp.json
4
5# Search products (UCP)
6curl -X POST http://localhost:9000/ucp/catalog/search \
7 -H "UCP-Agent: my-agent/1.0" \
8 -H "Request-Id: $(uuidgen)" \
9 -H "Content-Type: application/json" \
10 -d '{"query": "t-shirt", "limit": 10}'

Protocols

UCP (Unified Commerce Protocol)

UCP is designed for agent-to-merchant interactions. It uses a shopping-cart model where agents manage carts directly.

EndpointMethodDescription
GETProtocol discovery and capabilities
POSTFull-text product search
POSTDirect product lookup by ID or handle
POSTCreate a new cart
GETRetrieve cart
PUTUpdate cart (add/remove items, set address)
POSTCreate checkout session from cart
GETRetrieve checkout session
PUTUpdate checkout session
POSTComplete checkout and place order
POSTCancel checkout session
GETRetrieve order details

Required headers: ,

ACP (Agent Commerce Protocol)

ACP is designed for platform-to-merchant interactions. It uses a session-based model where the platform manages the checkout flow.

EndpointMethodDescription
GETProtocol discovery and capabilities
POSTCreate checkout session
GETRetrieve checkout session
POSTUpdate checkout session
POSTComplete checkout
POSTCancel checkout session
GETRetrieve order
GETRetrieve product feed

Required headers: ,

Payment Handlers

Payment is handled through a pluggable adapter system. Each adapter implements the interface and registers as a Medusa module.

Using the Prism Payment Handler

For x402 stablecoin payments (USDC, FDUSD, etc.), use the companion package:

npm install @financedistrict/medusa-plugin-prism-payment

See @financedistrict/medusa-plugin-prism-payment for setup instructions.

Building a Custom Payment Handler

Implement the interface:

1import type {
2 PaymentHandlerAdapter,
3 CheckoutPrepareInput,
4} from "@financedistrict/medusa-plugin-agentic-commerce"
5
6export default class MyPaymentAdapter implements PaymentHandlerAdapter {
7 readonly id = "my_payment_handler"
8 readonly name = "My Payment"
9
10 // Discovery — what to advertise in .well-known endpoints
11 async getUcpDiscoveryHandlers(): Promise<Record<string, unknown[]>> {
12 return {
13 "com.example.my_payment": [{
14 id: "my-handler",
15 version: "1.0.0",
16 }],
17 }
18 }
19
20 async getAcpDiscoveryHandlers(): Promise<unknown[]> {
21 return [{
22 id: "com.example.my_payment",
23 name: "My Payment",
24 version: "1.0.0",
25 psp: "my-psp",
26 requires_delegate_payment: false,
27 instrument_schemas: [/* ... */],
28 }]
29 }
30
31 // Checkout preparation — called when a checkout session is created
32 async prepareCheckoutPayment(input: CheckoutPrepareInput) {
33 // Call your payment gateway, return config for the agent
34 return { id: "my-handler", version: "1.0.0", config: { /* ... */ } }
35 }
36
37 // Response formatting — include payment config in checkout responses
38 getUcpCheckoutHandlers(cartMetadata?: Record<string, unknown>) {
39 return { /* ... */ }
40 }
41
42 getAcpCheckoutHandlers(cartMetadata?: Record<string, unknown>) {
43 return [/* ... */]
44 }
45}

Register it as a Medusa module and reference it in :

1// medusa-config.ts
2modules: [
3 {
4 key: "myPaymentHandler",
5 resolve: "./src/modules/my-payment-handler",
6 options: { /* ... */ },
7 },
8 {
9 key: "agenticCommerce",
10 resolve: "@financedistrict/medusa-plugin-agentic-commerce/modules/agentic-commerce",
11 options: {
12 payment_handler_adapters: ["myPaymentHandler"],
13 // ...
14 },
15 },
16]

Architecture

1medusa-config.ts
2 |
3 +-- plugins: [@financedistrict/medusa-plugin-agentic-commerce]
4 | Routes, workflows, subscribers, jobs auto-discovered
5 |
6 +-- modules:
7 +-- agenticCommerce (core service)
8 | Config, auth, formatting, payment registry
9 |
10 +-- prismPaymentHandler (optional adapter)
11 Discovery, checkout-prepare, response formatting

How Adapter Resolution Works

Medusa v2 modules have isolated DI containers. The plugin resolves payment handler adapters from the request-scoped container () via middleware — not from the module's constructor. This ensures all modules are registered and accessible at request time.

1Request → resolvePaymentAdapters middleware → route handler
2 |
3 +-- req.scope.resolve("prismPaymentHandler")
4 +-- agenticCommerceService.resolveAdapters(req.scope)

Workflows

The plugin provides four reusable workflows that orchestrate the checkout process:

WorkflowDescription
Validates cart, resolves region, prepares payment
Handles item/address changes, re-prepares payment
Completes payment, creates order
Cancels session and releases resources

Import them in your custom code:

1import {
2 createCheckoutSessionWorkflow,
3 completeCheckoutSessionWorkflow,
4} from "@financedistrict/medusa-plugin-agentic-commerce/workflows"

Configuration

Plugin Options

OptionTypeDefaultDescription
API key for ACP Bearer token authentication
HMAC-SHA256 key for request signing
Public URL of your storefront
Store name in protocol responses
Store description for discovery
Medusa payment provider ID
Module keys of payment handler adapters
UCP protocol version to advertise
ACP protocol version to advertise

Environment Variables

VariableMaps to

Exported Utilities

1import {
2 // Service & module
3 AgenticCommerceService,
4 AgenticCommerceModule,
5 AGENTIC_COMMERCE_MODULE,
6
7 // Payment adapter interface
8 PaymentHandlerAdapter, // type
9 CheckoutPrepareInput, // type
10 PaymentHandlerRegistry,
11
12 // Error formatting
13 formatAcpError,
14 formatUcpError,
15
16 // Address translation
17 medusaToAcpAddress,
18 acpAddressToMedusa,
19 medusaToUcpAddress,
20 ucpAddressToMedusa,
21
22 // Status mapping
23 resolveAcpStatus,
24 resolveUcpStatus,
25} from "@financedistrict/medusa-plugin-agentic-commerce"

Protocol Compliance

Types and formatters are audited against the official protocol specifications:

  • UCP — catalog, checkout, fulfillment, payment, order, discovery
  • ACP — checkout sessions, delegate payment, capabilities

Versioning

This package follows semver. While pre-1.0:

  • Protocol spec changes → minor bump (e.g., 0.1.x → 0.2.0)
  • Medusa compatibility changes → patch bump (e.g., 0.1.0 → 0.1.1)
  • Bug fixes → patch bump

The companion declares this package as a peer dependency with a range (e.g., ), so incompatible combinations are caught at install time.

Requirements

  • Medusa v2 (2.x)
  • Node.js >= 20
  • PostgreSQL (standard Medusa requirement)

License

MIT


Built by Finance District

Еще в этой категории

Посмотреть все
Другое
Gati logo

Gati

От Devx Commerce

Синхронизируйте Medusa с Gati ERP

Загрузка данных
npm
Другое
Product Reviews logo

Product Reviews

От Lambda Curry

Добавляйте рейтинги, отзывы и модерацию товаров

Загрузка данных
GitHubnpm
Другое
Variant Images logo

Variant Images

От Betanoir

Организуйте и загружайте варианты изображений в Medusa

Загрузка данных
GitHubnpm