Search by

falconmedia / magento2-agentic-checkout

falconmedia

OpenAI Agentic Commerce Protocol (ACP) agentic checkout merchant API for Magento 2 and Mage-OS

Package info

github.com/falconmedia/magento2-agentic-checkout

Type:magento2-module

pkg:composer/falconmedia/magento2-agentic-checkout

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-12-03 13:26 UTC

This package is not auto-updated.

Last update: 2026-12-04 09:00:01 UTC


README

Merchant side of the OpenAI Agentic Commerce Protocol (ACP) Agentic Checkout API for Magento 2 and Mage-OS. An agent creates a checkout session, updates it with items, buyer and fulfillment choices, and completes it. This package keeps the session on a real Magento quote and places a real Magento order.

Implements ACP spec version 2026-01-16. Requires PHP 8.2 or higher.

Install

composer require falconmedia/magento2-agentic-checkout
bin/magento module:enable FalconMedia_AgenticCheckout
bin/magento setup:upgrade
bin/magento cache:flush

Cron must run: it sends webhooks and removes expired sessions (hourly, in batches) and idempotency keys.

Configure

Stores > Configuration > Sales > Agentic Checkout, per store view. The module is off by default.

Group Field Default
General Enable, base path, discovery document, session lifetime, signature required, clock skew, rate limit, guest orders only, log error messages off, /acp/v1, off, 60 minutes, on, 300 s, 120, on, off
Catalog Allowed product types, backorders, virtual and downloadable products, products not visible in the catalog simple, off, off, off
Fulfillment Allowed shipping methods all methods with a rate
Order limits Minimum and maximum total, allowed countries, maximum open sessions per client none, none, all, 50
Legal links Require links, terms, privacy and return URLs required, empty
Hosted payment Payment method, order status empty, pending_payment
Outbound webhooks URL, signing secret, events empty, empty, both

Access to the section is controlled by the ACL resource FalconMedia_AgenticCheckout::config.

Create an API client and hand the values to the agent platform:

bin/magento falconmedia:agentic:client:create "Agent platform"
bin/magento falconmedia:agentic:client:list
bin/magento falconmedia:agentic:client:revoke 1

The API key and signing secret are shown once. Only a SHA-256 hash of the API key is stored. The signing secret is stored encrypted with the Magento crypt key, because the HMAC check needs the original value.

Requests

Base path default: /acp/v1. Every request needs Authorization: Bearer <api key>, API-Version: 2026-01-16, Content-Type: application/json and, for POST, an Idempotency-Key.

Signature: Signature is the unpadded base64url HMAC-SHA256 of <Timestamp>.<body> with the client signing secret. Timestamp is a strict RFC 3339 date-time with Z or an offset. A signature is accepted once: a second request with the same signature inside twice the clock skew is answered 401 replayed_request, so a retry needs a fresh timestamp. The body may be signed as sent or as canonical JSON (sorted keys, no whitespace). Requests outside the allowed clock skew are rejected.

Idempotency follows section 6 of the RFC: a replay returns the stored response, the same key with another body returns 422, a request still in flight returns 409, and 5xx responses are not stored. Keys are kept 24 hours.

Errors use the flat ACP shape {type, code, message, param}. Amounts are integers in minor units, computed by ISO 4217 exponent.

Protocol coverage

Feature Status
POST /checkout_sessions Implemented
GET and POST /checkout_sessions/{id} Implemented
POST /checkout_sessions/{id}/complete Implemented, needs a payment handler
POST /checkout_sessions/{id}/cancel Implemented
Idempotency, API-Version, signature, bearer auth Implemented
Fulfillment options (shipping, digital) Implemented
order_create and order_update webhooks Implemented
Discovery document /.well-known/acp.json Implemented, off by default
Hosted payment handler (buyer pays on the store) Implemented
Delegated payment tokens (Delegate Payment spec) Not implemented, add-on packages
Coupons and discounts entered by the agent Not implemented
Pickup and local delivery Not implemented
B2B and customer group pricing Not implemented
Multiple currencies per session Not implemented, amounts are in the base currency
Admin grid for sessions and clients Not implemented, CLI only

Spec choices where the RFC text and the OpenAPI file differ: the session exposes payment.handlers and the payment provider block, selected fulfillment options are returned nested and accepted nested or flat, and discount amounts are positive.

Payment handlers

Complete stays at 503 until a handler is available. The shipped hosted_payment handler is only available when the configured payment method has a pay URL provider. It places the order with that method and the configured status. The buyer is sent to the URL the provider returns as order.permalink_url.

A payment integration supplies the pay page per payment method by implementing FalconMedia\AgenticCheckout\Api\PayUrlProviderInterface (getPayUrl(OrderInterface $order): string) and registering it:

<type name="FalconMedia\AgenticCheckout\Model\Payment\PayUrlProviderPool">
    <arguments>
        <argument name="providers" xsi:type="array">
            <item name="payment_method_code" xsi:type="object">Vendor\Module\Model\PayUrl</item>
        </argument>
    </arguments>
</type>

The method must also be active for the store. A provider that throws is logged and the order permalink falls back to the store home page, so an order save never fails on it. A placement failure (for example a method that is not available for the address) returns a 422 processing_error with param $.payment_data.handler_id and the reason.

Only registered methods are offered in the admin. No provider is shipped, so a fresh install cannot complete sessions.

Add-on packages register a handler that implements FalconMedia\AgenticCheckout\Api\PaymentHandlerInterface:

<type name="FalconMedia\AgenticCheckout\Model\Payment\HandlerPool">
    <arguments>
        <argument name="handlers" xsi:type="array">
            <item name="my_handler" xsi:type="object">Vendor\Module\Model\MyHandler</item>
        </argument>
    </arguments>
</type>

The interface has getId(), isAvailable(), describe() and placeOrder(CartInterface, array $paymentData, ?array $authenticationResult, int $storeId): int returning the order id. Handlers must never store or log card data.

Unpaid orders

A cron job (falconmedia_agentic_cancel_unpaid, every 15 minutes) cancels orders of checkout sessions that are still unpaid (state new or pending_payment, nothing invoiced) after the lifetime in Payment > Cancel unpaid orders after (minutes) (default 480, 0 disables). Orders are canceled one by one through the order management API, so every cancel fires the usual events and updates updated_at. Bank transfer and payment methods whose due date is at or below the lifetime are skipped. Magento core sales_clean_orders does not cancel agent orders in other states, so this job is the only cleanup for them; keep Magento cron running.

ACP requests and sessions

ACP and discovery requests do not start a frontend session and do not set a PHPSESSID or private_content_version cookie. Replayed idempotent responses return the stored response headers (without per-request ones) plus Idempotent-Replayed: true. The fulfillment option amount is the net shipping price and equals the fulfillment total line, independent of the tax display configuration. When an address has no shipping method, the session carries an invalid error message on $.fulfillment_details.address. Countries that require a region reject an unknown state with a field error on $.fulfillment_details.address.state.

Security notes

  • API keys are compared with hash_equals on a SHA-256 hash. Signatures are compared with hash_equals.
  • No secrets or card data are logged or returned. Error handling logs the exception class only.
  • All request fields are whitelisted and validated. Unknown fields are rejected. Messages are plain text.
  • The webhook URL must be https, without credentials, and must resolve to public addresses. Delivery pins the connection to the checked address and does not follow redirects.
  • The API answers 403 https_required on plain HTTP, before authentication.
  • Signatures are single use inside twice the clock skew (cache based, not atomic across nodes).
  • Webhook targets are checked against an explicit denylist (private, loopback, link-local, carrier-grade NAT, benchmarking, documentation, multicast, reserved, NAT64, 6to4, unique local), including IPv4 addresses embedded in IPv6. Delivery ignores proxy settings.
  • Error handling logs the exception class, code and request id; the message is only logged when "Log error messages" is on.
  • At most the configured number of sessions can be open per client; the next one returns 429.
  • Products must belong to the store website, be enabled, visible (unless allowed) and salable.
  • buyer: null and fulfillment_details: null clear the stored data, an absent key changes nothing.
  • Requests are rate limited per client, and failed authentication is limited per address.
  • Database access uses bound parameters only.

Database policy

The package creates its own tables (falconmedia_agentic_client, _session, _idempotency, _webhook_outbox) and never alters native Magento tables or updates native rows in bulk. Sessions reference quote and order rows with foreign keys that cascade on delete. Quotes and orders are created and changed only through the Magento cart and order services.

Tests

vendor/bin/phpunit -c package-source/FalconMedia/AgenticCheckout/phpunit.xml
vendor/bin/phpcs --standard=Magento2 package-source/FalconMedia/AgenticCheckout/src

License

MIT