Skip to main content

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​

StepMerchant sideAgent side
1A1. Publish /.well-known/ai-payments.jsonB1. Fetch the manifest, pick a protocol
2A2. Publish /products.jsonB2. Read the catalog, build a cart
3A3. Lock the cart with POST /v1/negotiateB3. Receive sessionId and invoiceHash
4A4. Receive the settlement webhookB4. Sign a mandate bound to invoiceHash
5A5. Fulfill the order, keep the audit proofB5. POST /v1/transact

Three integration styles are supported. Pick one per merchant:

StyleEffortUse when
1. Static manifest + gateway negotiationLowest. 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 storefrontHighest. 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 its supportedProtocols, endpoints and security blocks, and add your own merchantId.

Verify:

curl -i https://shop.example.org/.well-known/ai-payments.json
note

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.

Webhook delivery

/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_COMPLETE and payment.settled acknowledge 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 transactionId and vaultReference with 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:

  1. Lock the cart (/v1/negotiate) and keep the cart, sessionId and invoiceHash on your server.
  2. 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.
  3. The buyer enters the card inside the iFrame. When you call iframe.tokenize(), the tokenize event returns a token and tokenHMAC, never a card number. Send both to your server and verify tokenHMAC there.
  4. Call POST /v1/checkout/complete with { "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:

FieldTypeNotes
merchantIdstringFrom the manifest.
currencystringISO 4217, case-insensitive (hashed upper-cased).
amountintegerTotal in minor units (> 0). /v1/negotiate verifies that amount === sum(price * qty) + taxCents + shippingCents.
items[]arrayEach with id, name, price (integer), qty (integer). Extra fields on an item are ignored by the hash.
taxCents, shippingCents, shippingMethod, destinationPostalCodeoptionalIf 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​

ResultHTTPWhat to do
status: SETTLEMENT_HANDOVER200Success. Keep transactionId; report the receipt to the user.
BUDGET_CAP_EXCEEDED + stepUpChallenge401Ask the human for a passkey, then call POST /v1/transact/step-up. Never retry silently.
INVOICE_HASH_MISMATCH401Cart differs from what was signed. Rebuild, re-lock, re-sign. Do not blindly retry.
SESSION_EXPIRED_OR_NOT_FOUND401The 300 s lock lapsed (or the session already settled). Negotiate again.
INVALID_SIGNATURE, CRYPTOGRAM_EXPIRED, NONCE_REPLAY_DETECTED401Re-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 merchantId matches.
  • 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:

  1. Sort items by id (UTF-16 code-unit order), not by sku or position.
  2. Only id, name, price, qty are hashed per item. Other fields such as sku are ignored.
  3. currency is upper-cased before hashing.
  4. Optional top-level fields are hashed only if you send them. Sending shippingCents: 0 is different from omitting it.
  5. 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):

Sessions​

  • Created by /v1/negotiate. Valid 300 seconds.
  • States: PARAMETER_NEGOTIATION → SIGNATURE_VERIFICATION → PPCB_VALIDATION → VAULT_MAPPING → SETTLEMENT_HANDOVER (or FAILED_TERMINATE at any step).
  • A session that has failed or settled cannot be re-used. A second /v1/transact on it fails; negotiate again.
  • sessionId is 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:

CheckFailing result
Currency equals cart currency401 CURRENCY_MISMATCH
Merchant in allowedMerchantIds (if set)401 UNAUTHORIZED_MERCHANT
Every item id in allowedSkus (if set)401 UNAUTHORIZED_SKU
amount ≤ maxAmountCents401 BUDGET_CAP_EXCEEDED. A pilot challenge may be included.

Testing your integration​

  1. Use your IXOPAY sandbox base URL and test cards.
  2. For agent integrations, ask your IXOPAY integration manager for sandbox signing keys and test mandates.
  3. Confirm each failure path returns the documented error (Errors).
  4. Run a replay: submit the same Visa TAP request twice; the second must fail with NONCE_REPLAY_DETECTED.

Going live​

  1. 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.
  2. Keep every /v1/* call on your servers, behind your own authentication and network controls. The Quickstart browser calls only its merchant checkout server.
  3. Switch the base URL, merchant ID and manifest endpoints from sandbox to the production values IXOPAY gives you.
  4. Make sure your webhook receiver verifies signatures and is idempotent (Webhooks).
  5. Run a low-value end-to-end transaction and confirm fulfillment, notification and reconciliation.