Agentic commerce covers everything from an assistant clicking through a checkout to software buying the resources it needs to finish a job. The Machine Payments Protocol (MPP) gives PHP developers a practical entry point: put a price on an API request, explain how to pay, and deliver the result. Let’s build that exchange, then look at the questions that appear when people start using it.
What do we mean by agentic commerce?
Working with clients on payments, I have started having a familiar conversation. Somebody wants agentic commerce. There is plenty of enthusiasm about how big it will be and how soon it’s coming, but when we ask, “What exactly should that look like in your business?” there’s a lot less certainty.
That is understandable! As with all heavily-hyped new technologies, the term covers a fairly broad spectrum. An assistant buying you a jacket and an agent paying for an inference request both qualify, but the applications behind them look quite different. Before choosing an integration, it helps to work out which problem we are trying to solve.

Fig. 1: “Agentic commerce” is a term that covers a full spectrum of uses.
At one end, computer-use agents (like Muse or OpenClaw) drive existing human UIs, navigating pages and filling forms. This requires zero backend changes, but remains brittle: it fails the moment controls shift, checkout flows stall, or bot challenges intervene.
Structured commerce protocols, such as Universal Commerce Protocol (UCP), give agents a more explicit way to interact with a business. Product information, checkout and the surrounding commerce operations become structured exchanges rather than something inferred from a page. The idea is that a customer asks ChatGPT, Gemini, or Claude to “find me the best jacket for less than $200,” the AI shows a one-click purchase option from your site, and when the customer clicks “buy,” it’s all handled automatically under the hood. Implementing those interfaces is one part of the work; getting discovered and recommended by the AI platforms is another. If you enjoyed optimising for search engines, there is a whole new world of fun and games waiting for you here!
Then there are payment primitives. We have a resource, a price and a way to pay. Perhaps we own a dataset and want to sell access to individual records. Perhaps an API performs inference, generates a report, or processes an image. We do not necessarily need a basket, a subscription or a customer who remembers their password; we have a resource and want to sell it with as little friction as possible.
This is where the Machine Payments Protocol becomes interesting. It lets a server request payment and a client respond through a simple HTTP header exchange.
Giving 402 something useful to do
HTTP has had a status code reserved for this problem for a long time: 402 Payment Required. Back in 1997, the thinking was that this internet thing was really catching on, and maybe in the future we’d want to standardise a way to buy and sell things at protocol level. In January 1997, the HTTP 1.1 spec reserved it for future use. We had the status code, but future engineers were left to work out the details. How much is required? How should the client pay? What should it send back?
The code sat there mostly unused for about a quarter century. Around 2020, lightning-based protocols like LSAT and L402 introduced Bitcoin micro-payments over HTTP, but developers and users still had to navigate specialised wallet ecosystems.
Another approach arrived in 2025 with Coinbase’s x402. This made stablecoins part of an HTTP exchange. Dollar-denominated stablecoins offered a more familiar pricing unit than a fluctuating Bitcoin amount. This got more traction, including support from Cloudflare’s Monetisation Gateway project. In March 2026, Stripe and Tempo introduced MPP, supporting multiple payment methods, including not just stablecoins, but also credit cards through Stripe or “real money,” as my parents would probably describe the latter. This update came at the right time, as a surge of new AI agents was being unleashed on the broader web.
It’s not been a quick journey, but nearly thirty years between reserving a status code and finding a solid use case makes me feel slightly better about the domains I bought long ago for side projects I still haven’t built.
These are related attempts to solve a longstanding problem, rather than successive versions of one specification. MPP’s specifications are still evolving; the examples here use the one-off charge flow: request, challenge, paid retry, verified payment, and response.

Fig. 2: Giving HTTP 402 something useful to do
Here is the exchange we are going to build: request a resource, receive a payment challenge, prepare a payment credential, retry, and receive the result.

Fig. 3: The whole protocol exchange process
Putting a price on an endpoint
To explore MPP in more detail, ahead of the World Cup this year we built PayForGoals.com: an interactive sandbox returning historic football scorelines through a paid API. It has a reasonable claim to being the world’s least useful football data product. It’s very MVP; you get the score and the year, but not the teams. Team names are maybe a version-two feature.

Fig. 4: “Is this real?” Kind of!
The point was to put something in public that people could poke at. Reading a specification is useful, but having an implementation people can play with and try to break teaches you far more about a new protocol.
Let’s start with a small Laravel endpoint, in routes/api.php:
use Illuminate\Support\Facades\Route;
Route::get('/api/v1/scores/match/1', fn () => response()->json([
'year' => 2014,
'score' => '7-1',
]));
Calling /api/v1/scores/match/1 returns 200 and our scoreline. We would now like to get paid for it. With MPP, this involves adding payment information to a WWW-Authenticate header. We created a Laravel package which adds middleware to simplify that job:
composer require square1/laravel-mpp
php artisan vendor:publish --tag=mpp-config
For this example, we’ll configure Stripe test mode and a Tempo testnet recipient to allow us to contrast fiat and crypto rails.
# .env file
STRIPE_SECRET_KEY=sk_test_...
STRIPE_NETWORK_ID=profile_...
STRIPE_API_VERSION=2026-05-27.preview
TEMPO_RECIPIENT=0x...
The profile identifies our business to a buyer’s wallet. The secret key lets our server process payment. The preview version above is the package’s documented version; Stripe’s newer examples may target another preview, so keep the installed integration and its API version aligned.
Add the middleware to the route:
Route::get('/matches/1', fn () => response()->json([
'year' => 2014,
'score' => '7-1',
]))->middleware('mpp:1.00,USD,methods=stripe|tempo');
We are asking for one dollar and offering two ways to pay (methods=stripe|tempo). Think of a restaurant accepting cash or card: the customer chooses a supported method, rather than paying both.
HTTP/1.1 402 Payment Required
Cache-Control: no-store
WWW-Authenticate: Payment id="...", realm="www.payforgoals.com",
method="stripe", intent="charge", request="eyJ...",
expires="2026-11-14T17:05:00Z", opaque="..."
WWW-Authenticate: Payment id="...", realm="www.payforgoals.com",
method="tempo", intent="charge", request="eyJ...",
expires="2026-11-14T17:05:00Z", opaque="..."
Multiple WWW-Authenticate fields are valid in one response. Each carries a separate offer, with its own identifier. Looking at the parameters:
methodidentifies the payment method. Stripe or Tempo here.intentidentifies the operation. In this case, a charge.requestcontains the payment terms as base64url-encoded JSON.expireslimits the lifetime of the offer;realmidentifies its protection space.ididentifies the challenge. This package generates it using an HMAC over the bound fields, protecting the quoted terms against client tampering.opaquecarries server binding information that the client returns unchanged.
When working with MPP, you’ll get very used to base64 encoding and decoding. The request param is the one that contains payment terms, so if we decode the Stripe request, the price is easier to read:
{
"amount": "100", # Price in cents
"currency": "usd",
"methodDetails": {
"networkId": "profile_...", # Our business id
"paymentMethodTypes": ["card"]
}
}
The equivalent Tempo testnet request has a different shape:
{
"amount": "1000000",
"currency": "0x20c0000000000000000000000000000000000000",
"recipient": "0x...",
"methodDetails": {
"chainId": 42431,
"supportedModes": ["pull"],
"memo": "0x..."
}
}
Stripe expresses the price in cents. Tempo expresses it in the token’s base units: pathUSD has six decimal places. Its currency is a token address, and the request identifies the recipient, chain, and transfer memo. The rail-specific instructions for moving money depend on the method we’re using.
Those methods also have different economics. Putting a one-cent price on a route does not make card minimums and processing fees disappear. Keep this in mind when pricing up your routes.
From a payment challenge to getting paid
We have successfully asked for money. Now we need to collect it. Suppose the client chooses Stripe. A reasonable question is where the customer’s card lives in all of this. Has somebody pasted their card number into an AI prompt? Hopefully not!
A wallet or authorised agent integration holds access to the customer’s saved payment method. When using Stripe rails, the wallet will generate a new Stripe primitive, known as a Shared Payment Token, or SPT. The token minted by the wallet grants scoped permission to use that saved card. But how do customers trust that their agent isn’t going to have a wild hallucination, go to the wrong site, and spend all the money on the card? SPTs can be minted with restrictions on the intended seller, maximum amount, currency, and expiry. The client’s agent carries the token to us; it does not need to hand us the underlying card details.
Before obtaining that token, though, the client needs to know what we are asking it to pay. It calls our endpoint without a payment credential and receives the 402 response we saw above. For the separate payment headers in that response, we can extract the Stripe offer using Guzzle’s header parser:
use GuzzleHttp\Psr7\Header;
use Illuminate\Support\Facades\Http;
$unpaid = Http::get('https://www.payforgoals.com/api/v1/scores/match/1');
$challenge = null;
foreach ($unpaid->toPsrResponse()->getHeader('WWW-Authenticate') as $line) {
if (!str_starts_with($line, 'Payment ')) {
continue;
}
// Remove the scheme; merge the comma-separated name=value pairs.
params=array_merge(...Header::parse(substr(line, 8)));
if (($params['method'] ?? null) === 'stripe') {
$challenge = $params;
break;
}
}
if ($challenge === null) {
throw new \RuntimeException('No Stripe payment offer received.');
}
$challenge now contains id, realm, method, intent, request, expires and opaque from that header. The request and opaque parameters remain base64url strings.
The client can decode request to inspect the price. In our example, those terms ask for 100 cents in USD and identify our business through its networkId. The wallet now has the information it needs to prepare a token for this purchase.
To see what the buyer’s agent is doing under the hood, let’s step into the client’s shoes for a moment before returning to our server. For development, Stripe provides a test helper that simulates the buyer issuing a token. If you have a Stripe test account, you can generate a token as follows:
curl https://api.stripe.com/v1/test_helpers/shared_payment/granted_tokens \
-u "$BUYER_TEST_KEY:" \
-H 'Stripe-Version: 2026-05-27.preview' \
-d payment_method=pm_card_visa \
-d 'usage_limits[currency]=usd' \
-d 'usage_limits[max_amount]=100' \
-d "usage_limits[expires_at]=$(($(date +%s)+300))" # 5 minutes
This generates a shared payment token with a maximum authorisation of $1 (Stripe list prices in cents), which will expire in five minutes. We have hard-coded the amount and currency from our example offer; a client handling different purchases would use the terms of the challenge it selected.
With authorisation in hand, the client can prepare its paid retry. It keeps the original encoded challenge parameters, adds the SPT as a separate payload, and base64url-encodes the lot. Here, $shared_payment_token holds the token returned by the test helper:
$envelope = json_encode([
'challenge' => $challenge,
// $shared_payment_token generated previously
'payload' => ['spt' => $shared_payment_token],
], JSON_THROW_ON_ERROR);
$credential = rtrim(
strtr(base64_encode($envelope), '+/', '-_'), '='
);
The resulting $credential carries the payment instrument alongside the original offer. The client sends it back to the same endpoint in the Authorization header. Substituting that value for <CREDENTIAL>, the request looks like this:
curl -i https://www.payforgoals.com/api/v1/scores/match/1 \
-H "Authorization: Payment <CREDENTIAL>"
Back on our server, we decode the envelope into two parts: the offer we originally made and the rail-specific credential the client has brought back. We check the challenge’s HMAC using our secret, check its expiry, and confirm that it belongs to this request. The HMAC covers the quoted terms, including the price, so a valid match proves they are the terms our server issued. This is the price we’ll charge; we’re never simply trusting an amount supplied by the client.
So far, we have checked the offer and received permission to attempt payment. We have not collected any money yet.
For Stripe, the middleware’s settlement flow looks roughly like this:
// Decode the Authorization envelope into challenge and payment payload.
$credential = parsePaymentCredential($request);
// Reject tampering, expired offers, and a challenge for another request.
$challenge = validateBoundChallenge($credential, $request);
// Only one worker may settle this challenge at a time.
return withSettlementLock($challenge->id, function () use (
$stripe, $credential, $challenge, $request, $next
) {
// A matching retry? Return the saved response without charging again.
if ($saved = matchingPaidResponse($credential, $request)) {
return $saved;
}
// Charge the quoted amount using the permission carried by the SPT.
$payment = $stripe->paymentIntents->create([
'amount' => (int) $challenge->amount(),
'currency' => $challenge->currency(),
'payment_method_data' => [
'shared_payment_granted_token' => $credential->spt(),
],
'confirm' => true,
], ['idempotency_key' => $challenge->id]);
// Require success and the expected amount/currency before delivery.
requireSuccessfulMatchingPayment($payment, $challenge);
$response = attachReceipt($next($request), $payment);
// Save the result and receipt for a later matching retry.
rememberPaidResponse($credential, $request, $response);
return $response;
});
Tempo follows a different settlement path. In the pull mode used by this package, the client signs a token transfer and includes that transaction in its payment credential. Our server validates the transfer against the challenge, broadcasts it, and checks its confirmed outcome. The recipient, token, amount, network, and challenge binding all matter. A perfectly valid transfer to somebody else’s wallet is not much use to us.
MPP defines the common exchange, while its payment-method specifications define the rail-specific rules. Spending controls likewise belong to the payment system: an SPT has Stripe-enforced limits; Tempo can use scoped access keys with limits and expiry.
After success, the client receives the resource they wanted, and a receipt:
HTTP/1.1 200 OK
Content-Type: application/json
Payment-Receipt: eyJbA8s...
{"year":2014,"score":"7-1"}
The decoded receipt gives us a payment reference:
# eyJbA8s... decoded
{
"status": "success",
"method": "stripe",
"reference": "pi_...",
"timestamp": "2026-10-14T17:01:00Z"
}
For Tempo, the reference is typically a transaction hash. For Stripe, it is the PaymentIntent ID.
Here we have constructed the exchange manually to show how the protocol works. In practice, tools like mppx handle challenge parsing, payment preparation, and retries for supported methods. Stripe’s Link CLI can obtain SPTs and make MPP payments. They belong on the buyer’s side. Our middleware remains responsible for checking payment before serving the resource.
The customer has paid for a 404
Once PayForGoals was public, people started asking useful questions. One was what happened when somebody requested a match that did not exist.
# Customer pays for match with high id
GET /api/v1/scores/match/999999999
Authorization: Payment eyJ...
# Server charges them, then returns 404
HTTP/1.1 404 Not Found
The middleware had done its job: no entry without payment. The application had also done its job: there was no such match. Together, they had successfully charged someone for finding out that we had nothing to sell them.
When asked whether charging for a 404 was intentional, the answer was the classic payments one: it depends. If we sell an existing database record, a cheap existence check must happen before the charge. Asking somebody to pay for a football score we do not have is difficult to defend, even by the modest standards of this particular product.
But suppose the endpoint performs inference or an expensive search. Finding out whether an answer exists may itself be the work we sell. Running that work for free before deciding whether to charge would defeat the business model. A result returning no matches is different from a missing database record.
That distinction is an application decision. The protocol cannot decide whether our customer bought a result or an attempt. Our API description and pricing should make the promise clear before the client pays.
We added preconditions to our Laravel package so applications can run checks before issuing a challenge, and again before settlement. An existence check can reject the request with 404; a valid resource proceeds to payment. Preconditions are useful when we can answer the eligibility question cheaply.
For a database-backed version of our endpoint, we can attach a named check to the route. Here, Scoreline is our application’s Eloquent model:
// routes/api.php:
Route::get('/api/v1/scores/match/{id}', fn (string $id) =>
\App\Models\Scoreline::findOrFail($id)
)->middleware('mpp:1.00,USD,methods=stripe,preconditions=match_exists');
// Add to preconditions.checks in config/mpp.php:
'match_exists' => [\App\Mpp\MatchExists::class, 'check'],
The check returns a response to stop the request or null to continue:
namespace App\Mpp;
use App\Models\Scoreline;
use Illuminate\Http\Request;
use Square1\Mpp\Payment\PaymentSpec;
use Symfony\Component\HttpFoundation\Response;
final class MatchExists
{
public function check(Request $request, PaymentSpec $spec): ?Response
{
return Scoreline::whereKey($request->route('id'))->exists()
? null
: response()->json(['error' => 'Unknown match'], 404);
}
}
This was the value of the playground. People treating a mostly jokey project semi-seriously helped surface implementation questions we now take into real-world engagements.
Retrying without paying twice
Agents have not persuaded the internet to stop dropping connections. A payment succeeds, a load balancer hiccups, and the client never sees the response. Naturally, it tries again.
We need to recognise that as the same purchase. In the package, a settlement lock lets one request process a challenge at a time. A concurrent retry gets 409 with Retry-After. Once a matching response is recorded, a retry can receive that result and its original receipt instead of another charge.
The Stripe call also uses the challenge ID as its idempotency key. If our connection to Stripe disappears, retrying that same operation need not create another payment. The saved-response check additionally binds the credential to the request target and body; knowing a public challenge ID should not unlock somebody else’s purchase.
A lock cannot recover an unsaved response if the worker crashes post-payment. For operations dispatching physical goods or queued compute jobs, the application must maintain a durable job state to resume safely, without double-charging.
We can charge. How do agents find us?
Our endpoint now accepts payment. Great! Next question: how will anybody (and their agent) find out about it?
The simplest discovery route is a human who already knows the service: “Go to this website and buy that report.” The agent has a starting point and can inspect the service’s documentation and payment challenge.
The second is a directory. mpp.dev is a useful learning resource and maintains a services catalogue, with an MCP endpoint through which agents can inspect available services. Someone could ask for historic football scorelines while expressing absolutely no interest in the teams involved, for example. And if they have the mpp.dev MCP server attached, there’s a good chance they’ll find us!
The third is machine-readable discovery on our own domain. MPP’s discovery approach uses an OpenAPI 3.1 document at /openapi.json, with x-payment-info extensions describing payment offers. It helps an agent that has found us understand what operations exist, how to call them, and which payment methods they advertise.
{
"info": { "title": "PayForGoals.com", "version": "1.0.0" },
"paths": {
"/api/v1/scores/match/{id}": {
"get": {
"parameters": [
{ "name": "id", "in": "path", "required": true,
"schema": { "type": "integer" }, "example": 1 }
],
"x-payment-info": {
"offers": [
{ "method": "tempo", "intent": "charge", "amount": "1000000",
"currency": "0x20c0…", "description": "One scoreline" },
{ "method": "stripe", "intent": "charge", "amount": "100",
"currency": "usd", "description": "One scoreline" }
]
},
}
}
}
}
The Laravel package generates this document from the router and payment configuration. We can add operation descriptions and request/response schemas alongside our routes. It keeps payment metadata tied to the configuration rather than asking us to maintain a second price list by hand.
If maintaining this schema manually, make sure to keep it synchronised with route changes. Remember that schema prices are advisory only: the live 402 challenge remains authoritative, especially for dynamic, per-request pricing.
What can you use today?
The protocol, payment rails, and buyer-facing products are moving at different speeds. Tempo mainnet has been live globally since March 2026, alongside a separate testnet for development. A mainnet integration is possible today, but receiving tokens is only one part of operating a business. Questions over funding wallets, converting receipts over off-ramps into the fiat currency we need, accounting, and local regulation vary around the world.
Stripe’s SPT documentation lists availability in the US, Canada, and most of EMEA for agents, customers, and sellers. This list changes regularly, so it’s worth keeping an eye on if your region isn’t on the list yet.
Buyer tooling introduces further friction: Link’s agent-wallet features currently remain limited to US consumers. Accepting a token is one thing; having a consumer wallet capable of minting one is another.
However, Stripe’s test helpers let us develop the exchange without waiting for a particular consumer wallet to reach our market. We can build the server side now, then check the live eligibility of the seller, buyer, and wallet we actually intend to use. Those details will change quickly (possibly even by the time you read this), so the provider documentation is worth revisiting before any launch.
When the customer is software
Many early agentic-commerce examples recreate something a person already does: find a jacket, choose a size, and buy it. I’m more interested in what happens when an agent buys resources because it needs them to finish a task.
We give an agent a job and a budget. It decides that a specialist dataset would improve the answer or that temporary compute would finish the work sooner. It purchases access, uses the resource and moves on. We may never know or care which provider it chose.
The provider, however, cares very much. Businesses have spent years optimising checkout pages, building brand loyalty, and finding the right moment for an upsell. What happens when the customer never visits those pages? How do we become the service an agent chooses on price, reliability, capability, or the quality of our documentation?
Those commercial and operational questions will take time to work through. In the meantime, we can already build services that offer useful data, computation, or access in units an agent can buy. A dataset that never justified a subscription business might be worth exposing one query at a time. An expensive operation could become a paid endpoint other tools can call when they need it.
Perhaps the biggest takeaway for backend engineers is how grounded this work actually is. The client might be an AI deciding how to solve an ambiguous problem, but the contract between us remains strict HTTP. We don’t need a lot of AI to support AI; we need predictable state machines, solid idempotency, robust caching, and clear interfaces.
For PHP developers, that is familiar territory. We aren’t reinventing computer science; we are taking web primitives we’ve refined over decades and giving them a new audience. The business models around agentic commerce are still taking shape. The good news is that we already have the tools to build them.
Author
🔍 FAQ
1. What is agentic commerce?
Agentic commerce describes transactions initiated or facilitated by AI agents. It includes both consumer purchases, such as buying products online, and software-driven transactions, such as purchasing access to datasets, API endpoints, inference services or computational resources.
2. What is the Machine Payments Protocol (MPP)?
The Machine Payments Protocol (MPP) is an open payment standard co-authored by Stripe and Tempo. It enables clients, including AI agents, to request and pay for online resources through an HTTP-based exchange using payment challenges, credentials and receipts.
3. How does HTTP 402 Payment Required work with MPP?
When a client requests a paid resource without a payment credential, the server responds with HTTP 402 Payment Required and a payment challenge in the WWW-Authenticate header. The client prepares a payment credential and retries the request using the Authorization header. After successful payment verification, the server delivers the resource and a payment receipt.
4. How can developers implement MPP in Laravel?
PHP developers can use the open-source square1/laravel-mpp Composer package to add payment requirements to Laravel routes through middleware. Developers configure supported payment methods, define prices and allow the middleware to issue payment challenges and validate payments before serving protected resources.
5. What is the difference between MPP and x402?
MPP and x402 are related approaches to integrating payments into HTTP interactions. The x402 protocol emerged with a focus on stablecoin payments, while MPP provides an extensible payment architecture supporting different methods, including Stripe card-based payments and Tempo token transfers. They are distinct protocols rather than successive versions of the same specification.
6. What are Stripe Shared Payment Tokens?
Stripe Shared Payment Tokens (SPTs) are scoped payment credentials that allow an authorised agent or wallet to use a customer's saved payment method without sharing underlying card details with the merchant. Restrictions can include the maximum amount, currency, intended seller and expiry.
7. How do Stripe and Tempo payments differ in MPP?
Stripe can process card-based payments using Shared Payment Tokens and PaymentIntents. Tempo supports token-based payments in which a signed transfer is validated, broadcast and checked for successful settlement. MPP provides the common HTTP exchange, while each payment method defines its own settlement rules.
8. How can developers prevent AI agents from paying twice for an API request?
Developers can use challenge-specific settlement locks, idempotency keys and stored payment responses to prevent duplicate charges during matching retries. Applications must also maintain durable state where necessary to recover safely from failures that occur after payment has succeeded.
9. What happens if an AI agent pays for an API resource that does not exist?
For APIs selling existing records, developers should check resource availability before issuing a payment challenge and before settlement. However, when an API sells computational work rather than a guaranteed result, charging for an operation that returns no matches may be appropriate if those terms are communicated clearly.
10. How can AI agents discover payment-enabled APIs?
AI agents can discover paid APIs through service directories, documentation and machine-readable API descriptions. MPP supports discovery through OpenAPI 3.1 documents containing x-payment-info extensions that describe available operations and payment offers. The live HTTP 402 challenge remains authoritative for actual pricing.
11. Can developers use MPP without cryptocurrency?
Yes. MPP supports multiple payment methods, including card-based payments through Stripe. However, actual availability depends on the eligibility of the payment provider, seller, buyer and wallet in the relevant region.
12. What can businesses monetise through agentic commerce APIs?
Businesses can monetise individual API requests, proprietary datasets, inference operations, image processing, report generation and temporary computational resources. Rather than requiring a traditional subscription or checkout, these services can offer resources in units that an authorised agent can purchase when needed.





