Integration Guide: How to Hook Up the IXOPAY Payment Agent
This is the step-by-step guide for connecting the IXOPAY Payment Agent to a merchant store (Part A) or a buyer agent (Part B). Part C covers the pieces both sides need: the Invoice Hash, sessions, and going live.
Before you start
- Run through the Quickstart so you have seen a payment succeed.
- Have your base URL and merchant ID from IXOPAY. Make
/v1/*calls from your servers; see Security. - Amounts are integers in minor units (cents). Never send
42.00.
Integration at a glance
| Step | Merchant side | Agent side |
|---|---|---|
| 1 | A1. Publish /.well-known/ai-payments.json | B1. Fetch the manifest, pick a protocol |
| 2 | A2. Publish /products.json | B2. Read the catalog, build a cart |
| 3 | A3. Lock the cart with POST /v1/negotiate | B3. Receive sessionId and invoiceHash |
| 4 | A4. Receive the settlement webhook | B4. Sign a mandate bound to invoiceHash |
| 5 | A5. Fulfill the order, keep the audit proof | B5. POST /v1/transact |
Three integration styles are supported. Pick one per merchant:
| Style | Effort | Use when |
|---|---|---|
| 1. Static manifest + gateway negotiation | Lowest. No server code beyond a static file and a webhook. | Existing Shopify/WooCommerce/custom store; you only need to be discoverable and notified. |
| 2. Merchant-side cart lock (server middleware) | Medium. One endpoint on your server that calls /v1/negotiate. | You want the cart priced and locked by your own server before the agent sees a hash. |
| 3. WebMCP storefront | Highest. Adds MCP tools for search, cart and checkout. | You want agents that speak Model Context Protocol to shop natively. |
Styles can be combined.
Part A — Merchant integration
A1. Publish your discovery manifest
Agents look for GET https://shop.example.org/.well-known/ai-payments.json. Serve it with Content-Type: application/json and Access-Control-Allow-Origin: *.
Minimum useful manifest (add your merchantId and the Payment Agent URL):
{
"version": "0.0.4",
"gateway": "IXOPAY Payment Agent",
"merchantId": "your-merchant-id",
"supportedProtocols": ["VISA_TAP", "AP4M", "TOKENEX_IFRAME_HPP"],
"endpoints": {
"jwks": "https://<ixopay-payment-agent-host>/.well-known/jwks.json",
"negotiate": "https://<ixopay-payment-agent-host>/v1/negotiate",
"transact": "https://<ixopay-payment-agent-host>/v1/transact",
"discovery": "https://shop.example.org/.well-known/ai-payments.json"
},
"security": { "ppcbRequired": true, "jcsHashing": "RFC-8785-SHA256" },
"catalogUrl": "https://shop.example.org/products.json",
"storeName": "Your Store"
}
Three ways to serve it:
- Static file. Drop it in your web root under
.well-known/. Easiest; update by hand if endpoints change. - Reverse-proxy or redirect to a manifest you host elsewhere.
- Copy IXOPAY's manifest. Fetch
https://<ixopay-payment-agent-host>/.well-known/ai-payments.json, copy itssupportedProtocols,endpointsandsecurityblocks, and add your ownmerchantId.
Verify:
curl -i https://shop.example.org/.well-known/ai-payments.json
Agents may check that the manifest is served over HTTPS (localhost is exempt for development) and that its merchantId matches the merchant they were asked to pay. A mismatch is reported as MERCHANT_DOMAIN_MISMATCH_OR_UNTRUSTED_TLS.
A2. Expose your catalog
Publish GET /products.json. Shopify stores already do. For other platforms, mirror Shopify's shape so agents can read it without custom code:
{
"products": [
{
"id": "p_101",
"title": "Lip Treat",
"handle": "lip-treat",
"vendor": "Acme",
"variants": [{ "id": "p_101_V1", "title": "Standard", "price": "16.00", "sku": "SKU-A", "available": true }]
}
]
}
Optionally publish /llms.txt (a plain-text description of your store for language models).
A3. Lock the cart (/v1/negotiate)
When an agent is ready to buy, build the cart from your own prices, never the agent's, and lock it.
curl -X POST https://<ixopay-payment-agent-host>/v1/negotiate \
-H "Content-Type: application/json" \
-H "X-API-Key: $IXOPAY_GATEWAY_KEY" -H "tx-tokenex-id: $TOKENEX_ID" \
-d '{
"agentId": "agent-1",
"cartParams": {
"merchantId": "your-merchant-id",
"currency": "USD",
"amount": 4200,
"items": [
{ "id": "SKU-A", "name": "Lip Treat", "price": 1600, "qty": 1 },
{ "id": "SKU-B", "name": "Glazing Fluid", "price": 2600, "qty": 1 }
],
"taxCents": 0,
"shippingCents": 0
}
}'
Response:
{ "sessionId": "sess_…", "invoiceHash": "e53d7b6a…a627", "status": "PARAMETER_NEGOTIATION", "expiresIn": 300 }
Return sessionId, invoiceHash and the locked cart to the agent, so it can recompute the hash before signing. Keep your own record of sessionId → cart so you can fulfill exactly what was locked.
A Node/Express middleware example:
app.post("/checkout/lock", async (req, res) => {
const cart = priceCartFromMyDatabase(req.body.items); // YOUR prices, YOUR tax/shipping
const r = await fetch(`${process.env.IXOPAY_URL}/v1/negotiate`, {
method: "POST",
redirect: "error",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.IXOPAY_GATEWAY_KEY,
"tx-tokenex-id": process.env.TOKENEX_ID,
},
body: JSON.stringify({ agentId: req.body.agentId, cartParams: cart }),
});
if (!r.ok) return res.status(502).json(await r.json());
const lock = await r.json();
orders.save(lock.sessionId, cart, lock.invoiceHash); // remember what was locked
res.json({ sessionId: lock.sessionId, invoiceHash: lock.invoiceHash, expiresIn: lock.expiresIn, cart }); // return the locked cart so the agent can recompute the hash
});
The lock lasts 300 seconds. Hold inventory for at most that long. If it lapses, the agent must negotiate again.
A4. Receive settlement notifications
Follow Webhooks: expose an HTTPS POST endpoint, verify the X-Ixopay-Signature header against the raw request body, respond 2xx, and make your handler idempotent on eventId. A tested handler is in examples/verify-webhook.js.
/v1/transact, /v1/checkout/complete, and /v1/refund automatically dispatch signed webhook events (payment.settled, refund.settled) when you pass webhookUrl in the request body, or when the environment has a default URL. When neither is set, the gateway uses registered destinations for the tenant.
A5. Fulfill the order and keep the proof
SETTLEMENT_HANDOVER,SETTLEMENT_COMPLETEandpayment.settledacknowledge gateway processing. Keep the order pending until the downstream processor confirms the authorization or capture required for fulfillment. Match the confirmation to the order, amount and currency.- Store
transactionIdandvaultReferencewith the order. - For disputes, fetch the audit bundle:
GET /v1/audit/proof?transactionId=<id>.
A6. Guest buyers with no stored card (optional)
If the agent's owner has no delegated card, take the card with the TokenEx iFrame:
- Lock the cart (
/v1/negotiate) and keep the cart,sessionIdandinvoiceHashon your server. - Generate the iFrame Authentication Key on your server, load the TokenEx iFrame script from TokenEx's servers, and create the iFrame with
new TokenEx.Iframe(containerId, config), exactly as in the Quickstart. - The buyer enters the card inside the iFrame. When you call
iframe.tokenize(), thetokenizeevent returns a token andtokenHMAC, never a card number. Send both to your server and verifytokenHMACthere. - Call
POST /v1/checkout/completewith{ "sessionId", "invoiceHash", "uttToken", "protocol": "TOKENEX_DIRECT" }.
Your page never sees the PAN, which is what keeps your integration eligible for the lightest PCI self-assessment (SAQ A). Your QSA confirms your actual scope.
Merchant checklist
- Manifest reachable over HTTPS with CORS
*. - Catalog reachable at
/products.json. - Cart is priced server-side before
/v1/negotiate. - Amounts are integer cents; items use
id,name,price,qty. - Webhook endpoint verifies signature and is idempotent.
- Inventory hold ≤ 300 s.
- You fulfill from your own stored cart, not from agent-supplied data.
Part B — Agent integration
B1. Discover the merchant
curl https://shop.example.org/.well-known/ai-payments.json
Choose a supported protocol. Use the gateway origin provisioned through onboarding for all credentialed calls, and reject redirects. A storefront manifest supplies discovery information only.
B2. Read the catalog and build a cart
Fetch catalogUrl (usually /products.json). Build the cart with the fields the Payment Agent hashes:
| Field | Type | Notes |
|---|---|---|
merchantId | string | From the manifest. |
currency | string | ISO 4217, case-insensitive (hashed upper-cased). |
amount | integer | Total in minor units (> 0). /v1/negotiate verifies that amount === sum(price * qty) + taxCents + shippingCents. |
items[] | array | Each with id, name, price (integer), qty (integer). Extra fields on an item are ignored by the hash. |
taxCents, shippingCents, shippingMethod, destinationPostalCode | optional | If present they are included in the hash. Include them in both the lock and the transact call, or in neither. |
B3. Get the lock
Ask the merchant to lock the cart. Load the original buyer-approved order from trusted state, including merchant, currency, total, items, quantities and applicable shipping or tax. Compute its hash and compare it with both the returned cart and invoiceHash before signing.
const { invoiceHash } = require("./examples/invoice-hash.js");
const approvedHash = invoiceHash(approvedCart);
if (invoiceHash(lock.cart) !== approvedHash || lock.invoiceHash !== approvedHash)
throw new Error("cart/approval mismatch");
B4. Sign the mandate and submit
Mastercard Agent Pay (AP4M)
curl -X POST https://<ixopay-payment-agent-host>/v1/transact \
-H "Content-Type: application/json" \
-H "X-API-Key: $IXOPAY_GATEWAY_KEY" -H "tx-tokenex-id: $TOKENEX_ID" \
-d '{
"sessionId": "sess_…",
"protocol": "AP4M",
"credentials": {
"layer1": "<SD-JWT>", "layer2": "<SD-JWT>", "layer3a": "<SD-JWT>", "layer3b": "<SD-JWT>",
"mandateInvoiceHash": "e53d7b6a…a627"
},
"cartParams": { "merchantId": "…", "currency": "USD", "amount": 4200, "items": [ … ] },
"l2Mandate": { "mandateId": "…", "userFidoPubkeyId": "…", "maxAmountCents": 5000,
"currency": "USD", "allowedMerchantIds": ["…"], "validUntil": "2027-01-01T00:00:00Z" }
}'
Visa TAP — headers carry the signature; the cart goes in the JSON body:
curl -X POST https://<ixopay-payment-agent-host>/v1/transact \
-H "Content-Type: application/json" \
-H "X-API-Key: $IXOPAY_GATEWAY_KEY" -H "tx-tokenex-id: $TOKENEX_ID" \
-H 'Signature-Input: sig1=("@authority" "@method" "@path" "content-digest");created=1792093450;expires=1792093750;keyid="<key id>";alg="ed25519";tag="agent-payer-auth";nonce="<unique>"' \
-H "Signature: sig1=:<base64 signature>:" \
-d '{ "protocol": "VISA_TAP", "cartParams": { … }, "body": { "consumerRecognition": { … }, "paymentContainer": { "vtsToken": "…", "expiryMonth": "12", "expiryYear": "28", "invoiceHash": "…" } } }'
Full detail, including how to build the signature base string, is in the Agent Developer Guide.
B5. Handle the response
| Result | HTTP | What to do |
|---|---|---|
status: SETTLEMENT_HANDOVER | 200 | Success. Keep transactionId; report the receipt to the user. |
BUDGET_CAP_EXCEEDED + stepUpChallenge | 401 | Ask the human for a passkey, then call POST /v1/transact/step-up. Never retry silently. |
INVOICE_HASH_MISMATCH | 401 | Cart differs from what was signed. Rebuild, re-lock, re-sign. Do not blindly retry. |
SESSION_EXPIRED_OR_NOT_FOUND | 401 | The 300 s lock lapsed (or the session already settled). Negotiate again. |
INVALID_SIGNATURE, CRYPTOGRAM_EXPIRED, NONCE_REPLAY_DETECTED | 401 | Re-sign with a fresh nonce and a fresh created/expires. |
| Other 4xx / 5xx | — | See Errors & Troubleshooting. |
Use a 5 second client timeout. Use one sessionId per purchase attempt; a settled session cannot be reused.
Agent checklist
- Verify the manifest origin is HTTPS and
merchantIdmatches. - Recompute the Invoice Hash locally and compare before signing.
- Never sign a mandate whose cart you did not build or verify.
- Fresh nonce on every Visa TAP request; ES256 key never leaves the user's device or enclave.
- Surface step-up challenges to the human.
- Do not log card data, tokens or signatures.
Part C — Shared building blocks
How the Invoice Hash is computed
The hash is SHA-256 over the RFC 8785 (JCS) canonical JSON of this object:
{
"amount": <integer>,
"currency": "<UPPERCASE>",
"items": [ { "id", "name", "price", "qty" }, … ] // sorted ascending by id
"merchantId": "<string>",
// only when present in the request:
"taxCents", "shippingCents", "shippingMethod", "destinationPostalCode"
}
Rules that trip people up:
- Sort items by
id(UTF-16 code-unit order), not byskuor position. - Only
id,name,price,qtyare hashed per item. Other fields such asskuare ignored. currencyis upper-cased before hashing.- Optional top-level fields are hashed only if you send them. Sending
shippingCents: 0is different from omitting it. - Use integers. If you must hash non-integers, serialize numbers the way JavaScript's
String(number)does.
Reference implementations (both produce e53d7b6a…a627 for the Quickstart cart):
- Node:
examples/invoice-hash.js - Python:
examples/invoice_hash.py
Sessions
- Created by
/v1/negotiate. Valid 300 seconds. - States:
PARAMETER_NEGOTIATION→SIGNATURE_VERIFICATION→PPCB_VALIDATION→VAULT_MAPPING→SETTLEMENT_HANDOVER(orFAILED_TERMINATEat any step). - A session that has failed or settled cannot be re-used. A second
/v1/transacton it fails; negotiate again. sessionIdis optional on/v1/transact. If you omit it the Payment Agent creates a one-shot session from the submitted cart. Always send it when you have one, so the lock is honored.
Spending rules (L2 mandate)
Optional l2Mandate on /v1/transact is checked before signature verification:
| Check | Failing result |
|---|---|
| Currency equals cart currency | 401 CURRENCY_MISMATCH |
Merchant in allowedMerchantIds (if set) | 401 UNAUTHORIZED_MERCHANT |
Every item id in allowedSkus (if set) | 401 UNAUTHORIZED_SKU |
amount ≤ maxAmountCents | 401 BUDGET_CAP_EXCEEDED. A pilot challenge may be included. |
Testing your integration
- Use your IXOPAY sandbox base URL and test cards.
- For agent integrations, ask your IXOPAY integration manager for sandbox signing keys and test mandates.
- Confirm each failure path returns the documented error (Errors).
- Run a replay: submit the same Visa TAP request twice; the second must fail with
NONCE_REPLAY_DETECTED.
Going live
- Ask your IXOPAY integration manager to confirm that production keys are configured for verifying Mastercard and Visa mandates on your account. Built-in sandbox keys are rejected in production; see Release Notes.
- Keep every
/v1/*call on your servers, behind your own authentication and network controls. The Quickstart browser calls only its merchant checkout server. - Switch the base URL, merchant ID and manifest endpoints from sandbox to the production values IXOPAY gives you.
- Make sure your webhook receiver verifies signatures and is idempotent (Webhooks).
- Run a low-value end-to-end transaction and confirm fulfillment, notification and reconciliation.