Machine Payments Protocol × CoDi × pey
HTTP 402, paid in pesos.
The first Mexican real-time rail on MPP. An agent calls your API, gets a 402 with a CoDi QR, a human taps Pagar in their bank app, and the agent gets 200 plus a receipt with the Banxico tracking key.
GET /api/tacoAn agent, a script or this page.
Payment method="codi"Amount in MXN + a CoDi QR from pey (and a push, if asked).
Pagar ✓Scan or tap in any CoDi bank app. 2-3 s per pey call.
Payment-Receipt: eyJ…pey transaction id + clave de rastreo.
Try it: paid endpoints
One-time charge. A human pays once, the agent gets the recipe.
GET /api/tacoPer-call price on a prepaid balance: one CoDi tap, then no human in the loop.
GET /api/tipo-de-cambioPOST with a body: the challenge is bound to the body digest (RFC 9530).
POST /api/corridoSession deposit: $0.03 per top-up. CoDi through pey has no refunds, so unspent balance stays with the merchant (disclosed in the challenge as refundable: false).
Pick an endpoint to see the handshake.
This page is an MPP client: it reads the 402, shows the QR, polls with the credential.
Escanea con la app de tu banco (CoDi)
Payment-Receipt
Wire
Pay from code
import { fetchWithCodi, printPrompt } from "@pey/mpp-codi/client";
const res = await fetchWithCodi("https://pey-mpp-live.exe.xyz/api/taco", {}, {
onQr: printPrompt, // QR in the terminal (or your UI)
phone: "5512345678", // optional: also push to the payer's bank app
wait: { timeoutMs: 300_000 }, // bounded: the human has 5 minutes
});
if (res.ok) console.log(res.value.receipt?.trackingKey, await res.value.response.json());bun apps/mpp-codi/src/client/demo.ts https://pey-mpp-live.exe.xyz/api/taco
What follows the spec
- Challenges per draft-httpauth-payment-01: JCS + base64url, HMAC-SHA256 id binding (passes the draft's test vectors), RFC 3339 expiry.
- charge intent: amount in centavos, currency
mxn, single-use challenges, atomic redemption, a payment redeems once. - session intent modeled on draft-lightning-session-00: open / bearer / topUp / close.
- RFC 9457 problems, RFC 9530 body digests, Accept-Payment, Idempotency-Key, no-store / private caching.
- MCP binding at
POST /mcp(-32042 / -32043,org.paymentauth/*_meta) and discovery at/openapi.json(mppx validate: 31/31).