<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged agenticcommerce</title>
<link>https://coderlegion.com/tag/agenticcommerce</link>
<description>Powered by Question2Answer</description>
<item>
<title>AP2 Mandates Are Live on UCPReady — Here's What That Actually Means for Autonomous Payment</title>
<link>https://coderlegion.com/15955/ap2-mandates-are-live-on-ucpready-heres-what-that-actually-means-for-autonomous-payment</link>
<description>&lt;p&gt;Zero merchants in &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.to/benjifisher/agentic-commerce-optimization-what-4491-merchants-reveal-about-ucp-readiness-3fk&quot;&gt;Ben Fisher's 4,024-merchant UCP dataset&lt;/a&gt; support native payment. I've been building toward closing that gap since March. Today it's done — at least on the business side.&lt;/p&gt;
&lt;p&gt;This post is about AP2 Mandates: what they are, why they're the only spec-compliant path to autonomous card payment on UCP, and what it took to implement them correctly on WooCommerce.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-every-ucp-checkout-still-ends-with-a-browser-redirect&quot;&gt;Why every UCP checkout still ends with a browser redirect&lt;/h3&gt;
&lt;p&gt;When an AI agent completes a UCP checkout today, it gets a &lt;code&gt;continue_url&lt;/code&gt;. The buyer clicks a link, lands on the WooCommerce checkout page, fills in their card, and pays. The agent handled discovery and session setup. The human handled payment.&lt;/p&gt;
&lt;p&gt;That handoff exists because the spec requires it — unless one specific extension is active.&lt;/p&gt;
&lt;p&gt;From the UCP checkout specification:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&quot;The checkout has to be finalized manually by the user through a trusted UI &lt;strong&gt;unless the AP2 Mandates extension is supported&lt;/strong&gt;.&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That &quot;unless&quot; is the entire autonomous payment story in UCP. Not Stripe tokens. Not saved cards. Not wallet APIs. &lt;strong&gt;AP2 Mandates.&lt;/strong&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-ap2-mandates-actually-are&quot;&gt;What AP2 Mandates actually are&lt;/h3&gt;
&lt;p&gt;AP2 is a cryptographic authorization framework. When it's negotiated between a business and a platform, the checkout session is &quot;security locked&quot; — neither party can revert to an unprotected flow.&lt;/p&gt;
&lt;p&gt;The flow has two sides:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Business side:&lt;/strong&gt; Every checkout response must include &lt;code&gt;ap2.merchant_authorization&lt;/code&gt; — a JWS detached signature proving the checkout terms (price, line items, totals) are authentic and haven't been tampered with. The signature is ES256, JCS-canonicalized per RFC 8785, with the payload excluded from the JWS body (RFC 7515 Appendix F detached content format).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Platform side:&lt;/strong&gt; When the user confirms the purchase, the platform generates a cryptographically signed mandate — an SD-JWT credential proving the user explicitly authorized this specific transaction. It submits that mandate at &lt;code&gt;complete_checkout&lt;/code&gt;. The business verifies it. If valid, payment proceeds without a browser redirect.&lt;/p&gt;
&lt;p&gt;The checkout mandate contains the full checkout response including the business's &lt;code&gt;merchant_authorization&lt;/code&gt;. So the platform's signature covers the business's signature. It's a nested cryptographic binding: the business proves the terms, the platform proves the user consented to those exact terms.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-implementing-this-actually-required&quot;&gt;What implementing this actually required&lt;/h3&gt;
&lt;h4 id=&quot;getting-the-signing-right&quot;&gt;Getting the signing right&lt;/h4&gt;
&lt;p&gt;The spec says ES256 with detached JWS. In PHP, &lt;code&gt;openssl_sign()&lt;/code&gt; on a P-256 key produces a DER-encoded ECDSA signature. JWS ES256 requires raw &lt;code&gt;r||s&lt;/code&gt; — 64 bytes for P-256. Those are not the same format.&lt;/p&gt;
&lt;p&gt;Every JWS library you'd use on the platform side (jose, python-jose, jsonwebtoken) expects raw r||s. A DER signature will fail verification silently or throw a malformed signature error. The fix is a DER-to-raw-rs converter:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-php&quot;&gt;// openssl_sign() → DER. JWS ES256 → raw r||s. Not the same.
openssl_sign( $signing_input, $signature_der, $private_key, OPENSSL_ALGO_SHA256 );
$r = substr( $der_inner, $r_offset, $r_len );
$s = substr( $der_inner, $s_offset, $s_len );
$signature_raw = str_pad( ltrim($r, &quot;\x00&quot;), 32, &quot;\x00&quot;, STR_PAD_LEFT )
               . str_pad( ltrim($s, &quot;\x00&quot;), 32, &quot;\x00&quot;, STR_PAD_LEFT );
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The JCS canonicalization (RFC 8785) is the other non-obvious requirement. Before signing, the checkout payload is canonicalized — keys sorted recursively, Unicode normalized, numbers in IEEE 754 format. This ensures the signature is reproducible across systems that may re-serialize JSON differently.&lt;/p&gt;
&lt;h4 id=&quot;enforcing-the-mandate-at-complete-checkout&quot;&gt;Enforcing the mandate at complete_checkout&lt;/h4&gt;
&lt;p&gt;The spec is explicit: if AP2 was negotiated, &lt;code&gt;complete_checkout&lt;/code&gt; MUST reject requests without &lt;code&gt;ap2.checkout_mandate&lt;/code&gt;. This is the security boundary. Without it, AP2 is advertised but provides no protection — a platform could skip the mandate entirely and the checkout would succeed.&lt;/p&gt;
&lt;p&gt;The enforcement block runs before order creation:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-php&quot;&gt;if ( $ap2_ext-&amp;gt;is_ap2_configured() ) {
    $mandate_jwt = $body['ap2']['checkout_mandate'] ?? null;
    if ( empty( $mandate_jwt ) ) {
        // Return mandate_required error — session stays ready_for_complete
        return $this-&amp;gt;mandate_error_response( 'mandate_required', $session );
    }
    $mandate_error = $ap2_ext-&amp;gt;verify_checkout_mandate( $mandate_jwt, $session, $request );
    if ( null !== $mandate_error ) {
        return $this-&amp;gt;mandate_error_response( $mandate_error['code'], $session );
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;verifying-the-mandate&quot;&gt;Verifying the mandate&lt;/h4&gt;
&lt;p&gt;When a mandate is present, the full verification chain runs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Parse the SD-JWT structure (&lt;code&gt;header.payload.signature~disclosures~keybinding&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Check expiry (&lt;code&gt;exp&lt;/code&gt; claim)&lt;/li&gt;
&lt;li&gt;Extract the embedded checkout from mandate claims&lt;/li&gt;
&lt;li&gt;Re-verify &lt;code&gt;merchant_authorization&lt;/code&gt; — confirm the platform wrapped our own signature, not a different checkout&lt;/li&gt;
&lt;li&gt;Verify checkout ID matches the current session&lt;/li&gt;
&lt;li&gt;Verify totals match — no bait-and-switch between what the user saw and what gets charged&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;platform-key-verification&quot;&gt;Platform key verification&lt;/h4&gt;
&lt;p&gt;The final step: verifying the SD-JWT outer signature using the platform's public key. This is what proves the mandate is genuinely from the platform and not forged.&lt;/p&gt;
&lt;p&gt;The flow: decode the JWS header → extract &lt;code&gt;alg&lt;/code&gt; and &lt;code&gt;kid&lt;/code&gt; → fetch the platform's UCP profile from the &lt;code&gt;UCP-Agent&lt;/code&gt; header → pull &lt;code&gt;signing_keys&lt;/code&gt; → find the JWK matching &lt;code&gt;kid&lt;/code&gt; → build an OpenSSL public key from the JWK &lt;code&gt;x&lt;/code&gt;/&lt;code&gt;y&lt;/code&gt; coordinates → verify.&lt;/p&gt;
&lt;p&gt;Building an EC public key from JWK coordinates without a library means constructing the SubjectPublicKeyInfo DER by hand in PHP — OID encoding, SEQUENCE wrapping, BIT STRING for the uncompressed EC point. It's ~80 lines but removes a runtime dependency and works on any WordPress host.&lt;/p&gt;
&lt;p&gt;The platform profile is fetched over HTTPS and cached with WP transients, respecting &lt;code&gt;Cache-Control max-age&lt;/code&gt; with a 60-second floor. Verification result is logged with kid, algorithm, and session ID for auditability.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-capability-name-that-broke-everything&quot;&gt;The capability name that broke everything&lt;/h3&gt;
&lt;p&gt;Before any of this verification mattered, there was a simpler bug: the capability was advertised as &lt;code&gt;dev.ucp.shopping.ap2_mandates&lt;/code&gt; — plural. The spec uses &lt;code&gt;dev.ucp.shopping.ap2_mandate&lt;/code&gt; — singular.&lt;/p&gt;
&lt;p&gt;Capability negotiation is a string equality check. The intersection algorithm finds no match between &lt;code&gt;ap2_mandates&lt;/code&gt; and &lt;code&gt;ap2_mandate&lt;/code&gt;. AP2 is never activated. Every checkout session falls back to delegate payment. No error, no warning — it silently never negotiates.&lt;/p&gt;
&lt;p&gt;One character. Every implementation should validate capability names against the spec registry rather than trusting their own strings.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-s-live-now&quot;&gt;What's live now&lt;/h3&gt;
&lt;p&gt;When &lt;code&gt;dev.ucp.shopping.ap2_mandate&lt;/code&gt; is enabled in UCPReady and a compatible platform connects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Every checkout response includes &lt;code&gt;ap2.merchant_authorization&lt;/code&gt; (JWS ES256, detached, JCS payload)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;complete_checkout&lt;/code&gt; rejects requests without &lt;code&gt;ap2.checkout_mandate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Verification runs: SD-JWT parse → expiry → embedded checkout extraction → merchant_authorization re-verification → ID and totals match → platform key verification&lt;/li&gt;
&lt;li&gt;If all checks pass, payment proceeds — no browser redirect&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The one remaining piece is ecosystem readiness: a platform that supports AP2 mandate submission and forwards the access token that proves identity linking. &lt;a rel=&quot;nofollow&quot; href=&quot;https://ucpplayground.com&quot;&gt;Ben Fisher's UCPPlayground&lt;/a&gt; is the logical first test. Once that's connected, UCPReady will produce the first confirmed AP2-mandate-verified autonomous purchase on WooCommerce.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-this-matters-beyond-woocommerce&quot;&gt;Why this matters beyond WooCommerce&lt;/h3&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.to/benjifisher/the-state-of-agentic-commerce-april-2026-l93&quot;&gt;Ben's dataset of 4,024 merchants&lt;/a&gt; shows zero native payment support. Part of that is the SPT/ACS story — Stripe's Shared Payment Token is US-only right now and requires Stripe to host the checkout flow. That's a different architecture than UCP.&lt;/p&gt;
&lt;p&gt;On UCP, AP2 Mandates is the spec's answer. It's protocol-agnostic — the mandate can cover any payment method handled by any PSP. The platform proves user consent cryptographically. The business verifies that proof and charges via their existing payment gateway. No card data crosses protocol boundaries. PSD2 SCA compliance comes from the mandate being platform-issued and buyer-authenticated at mandate creation time.&lt;/p&gt;
&lt;p&gt;This is what autonomous agent commerce looks like when the merchant controls the checkout instead of delegating it to Stripe's infrastructure.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;UCPReady is available at &lt;strong&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://zologic.nl/ucpready&quot;&gt;zologic.nl/ucpready&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you're building a platform that supports UCP and want to test AP2 mandate submission against a live endpoint, reach out. houseofparfum.nl is running UCPReady 1.8.23 with AP2 ready to activate.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/15955/ap2-mandates-are-live-on-ucpready-heres-what-that-actually-means-for-autonomous-payment</guid>
<pubDate>Mon, 27 Apr 2026 09:00:29 +0000</pubDate>
</item>
<item>
<title>Payment Infrastructure Has Always Assumed a Human. That Assumption Is Breaking</title>
<link>https://coderlegion.com/15042/payment-infrastructure-has-always-assumed-a-human-that-assumption-is-breaking</link>
<description>&lt;p&gt;This article was originally published on the Blockonomics blog. Read the original version &lt;a rel=&quot;nofollow&quot; href=&quot;https://insights.blockonomics.co/payment-infrastructure-has-always-assumed-a-human-that-assumption-is-breaking/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Search through any PayPal forum or subreddit and you'll find the same story told a thousand ways: an account flagged for fraud, funds frozen, business interrupted. More often than not these are false positives — a legitimate transaction that tripped an algorithm.&lt;/p&gt;
&lt;p&gt;The first instinct is that this is a bug, an example of how automated systems break down when engaging with real humans. That isn't an incorrect analysis. But it's also a view into the future — and things are only going to get worse, though not for the reasons you might think.&lt;/p&gt;
&lt;p&gt;Every payment system built in the last 50 years was built for humans. Why wouldn't it be? Humans are who buy things. No bot had the sophistication or the trust to make a purchase worth designing around. So human interaction got baked into everything: fraud detection, KYC, dispute resolution, checkout flows, purchasing.&lt;/p&gt;
&lt;p&gt;But as we enter the era of AI agents, that is changing. AI will soon need to interact with these systems, navigate them without breaking, and complete purchases on behalf of the people who deploy them. This is a problem. Our infrastructure was never designed to accommodate that.&lt;/p&gt;
&lt;p&gt;We can already see it breaking down — and agents haven't even arrived yet. Take this account of a tech-savvy professional who lost his PayPal account of twenty years: &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.linkedin.com/pulse/twenty-years-one-invoice-im-out-how-paypals-killed-my-michael-mcnally-wb7tc/&quot;&gt;https://www.linkedin.com/pulse/twenty-years-one-invoice-im-out-how-paypals-killed-my-michael-mcnally-wb7tc/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The system wasn't trying to stop him. He simply wound up in the wrong menus, and that was enough to trigger a permanent deletion — reversed only after his story gained enough public attention to force a human review. A competent person, doing normal things, undone by an interface that had no tolerance for deviation.&lt;/p&gt;
&lt;p&gt;And it's not just fraud detection. KYC assumes a human is present to verify everything. An AI agent can't hold a passport up to its face and take a picture. Checkout flows time out when no one is actively clicking through them. Two-factor authentication expects someone to be watching a phone.&lt;/p&gt;
&lt;p&gt;The entire architecture of internet commerce was built around keeping bots out. We invented CAPTCHAs for that exact reason. Now we have to reckon with the fact that some bots are supposed to be let in.&lt;/p&gt;
&lt;p&gt;AI usage is growing, and agents will increasingly need to access ecommerce systems to do their jobs. We already see those systems struggling with ordinary human behavior — false positives, unnecessary friction, unexplained account closures. But these aren't bugs to be patched. They are structural decisions made years ago, now hardened into infrastructure, with consequences that will compound as agent-driven transactions begin to scale. AI behavior will look nothing like human behavior. And humans are already getting stuck.&lt;/p&gt;
&lt;p&gt;As agents enter our commercial ecosystems in larger numbers, the question becomes unavoidable: how will these systems deal with them?&lt;/p&gt;
&lt;p&gt;The answer requires more than a software update. It requires rethinking the assumptions underneath. Can fraud detection be built around accountability rather than identity? Can KYC verify an entity and its delegated permissions rather than a face? Can checkout flows be designed for both human and non-human actors without sacrificing security or usability?&lt;/p&gt;
&lt;p&gt;I don't have complete answers to those questions. What I do know is that these systems need to be rebuilt intentionally — with the knowledge that autonomous agents will interact with them. That means finding ways to establish accountability while separating it from individual identity. It means designing for actors that don't get tired, don't browse before they buy, and don't respond to a verification text.&lt;/p&gt;
&lt;p&gt;These are the problems that people across payments, security, and infrastructure are beginning to work through.&lt;/p&gt;
&lt;p&gt;At the end of the day, the coming revolution is not really about AI. It is about infrastructure that was never as robust as we assumed.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/15042/payment-infrastructure-has-always-assumed-a-human-that-assumption-is-breaking</guid>
<pubDate>Fri, 17 Apr 2026 09:10:12 +0000</pubDate>
</item>
</channel>
</rss>