Hookup Guide: Connect to the IXOPAY Payment Agent in Fewer Than 10 Steps
This is the one-page answer to "how do I hook this up?" It walks you from your first sandbox request to a recorded gateway handover, and tells you how to prove each step worked before you move on. Deeper detail for every step is linked at the end of it.
Time needed: about 1 hour for a merchant, about half a day for an agent that signs mandates.
The picture
flowchart LR
Frame["Customer checkout<br/>TokenEx iFrame"] -->|Token and tokenHMAC| Merchant["Merchant backend"]
Merchant -->|Lock cart or complete iFrame checkout| Gateway["IXOPAY Payment Agent"]
Agent["Agent backend"] -->|Submit a vault token or signed mandate| Gateway
Gateway -. Signed webhook .-> Merchant
Price the cart on your server and call the Payment Agent from a backend provisioned for your environment. The credential you send depends on the payment path.
| Payment path | What your backend sends |
|---|---|
| Customer pays in the TokenEx iFrame | Verify the token returned by the iFrame using tokenHMAC, then send the token as uttToken to POST /v1/checkout/complete. |
| Agent uses an existing TokenEx Universal Token (UT) | Call POST /v1/transact with protocol: "TOKENEX_REST", your agentId, the locked cart, and the UT in credentials.cardData. This flow requires no new network token. |
| Agent pays with Visa TAP or Mastercard Agent Pay | Send the signed payment credentials required by that protocol to POST /v1/transact. See the Agent Developer Guide. |
Step 0. Get your connection details from IXOPAY
Ask your IXOPAY integration manager for the items below. You cannot start without the first three.
| Item | What it is | Where you use it |
|---|---|---|
| Base URL (sandbox, later production) | https://<ixopay-payment-agent-host> | Every /v1/* call |
| Merchant ID | Your store's identifier | cartParams.merchantId, your manifest |
| Webhook signing secret | Shared secret for verifying notifications | Your webhook receiver |
| Gateway key | Use the credential and HTTPS gateway origin provisioned together for your environment. These examples send X-API-Key. | Your server only, as IXOPAY_GATEWAY_KEY |
| TokenEx iFrame settings | TokenEx ID, token scheme and the Customer Secret Key from iFrame Configuration. Use the secret to sign the iFrame configuration and verify tokenHMAC. | Your checkout server |
| Sandbox test cards | Cards that work only in sandbox | Testing the iFrame |
| Your checkout page origin(s) | The exact origins of the pages that show the TokenEx iFrame (HTTPS in production) | Signed into the Authentication Key and set as the iFrame origin |
| Sandbox signing keys and test mandates (agents only) | Keys the sandbox will accept | Mandate signing |
Keep secrets in your secret manager or environment variables, never in source control or in a web page.
Step 1. Check you can reach it
export PA=https://<ixopay-payment-agent-host>
curl -s $PA/health
curl -s $PA/.well-known/ai-payments.json
curl -s $PA/.well-known/jwks.json
Pass: /health returns "status": "HEALTHY", "service": "ixopay-payment-agent" and a version; the manifest lists supportedProtocols; the JWKS returns keys.
Fail: a timeout or TLS error means a firewall or proxy on your side. Allow outbound HTTPS (443) to the base URL host.
Step 2. Choose your path
| You are… | Path | Follow |
|---|---|---|
| A merchant taking card payments from a person (or a person using an agent) | TokenEx iFrame | Steps 3, 4, 5A, 6, 7 |
| A merchant wanting AI agents to buy autonomously | Agent checkout (publish manifest + catalog, lock carts) | Steps 3, 4, 5B, 6, 7 |
| An agent developer buying on a user's behalf | Mandate signing | Integration Guide, Part B and Agent Developer Guide |
You can do both merchant paths on the same store.
Step 3. Set up your server-side client
Create one small module that holds the base URL and credentials and is the only code that talks to the Payment Agent.
// ixopay-client.js (Node 18+)
const BASE = process.env.IXOPAY_URL; // https://<ixopay-payment-agent-host>
const GATEWAY_KEY = process.env.IXOPAY_GATEWAY_KEY;
async function call(path, body) {
const res = await fetch(BASE + path, {
method: "POST",
redirect: "error",
headers: { "Content-Type": "application/json", "X-API-Key": GATEWAY_KEY, "tx-tokenex-id": process.env.TOKENEX_ID },
body: JSON.stringify(body),
signal: AbortSignal.timeout(5000), // 5 s client timeout
});
const json = await res.json().catch(() => ({}));
if (!res.ok) throw Object.assign(new Error(json.error || res.statusText), { status: res.status, body: json });
return json;
}
module.exports = { negotiate: (b) => call("/v1/negotiate", b), complete: (b) => call("/v1/checkout/complete", b) };
Pass: the gateway accepts your authenticated request. Confirm the expected authentication scheme with your integration manager and verify that the managed environment rejects a missing or incorrect gateway credential.
Step 4. Lock a cart
Build the cart from your own prices, in integer minor units (cents), then lock it.
const { negotiate } = require("./ixopay-client");
const cart = {
merchantId: process.env.IXOPAY_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 },
],
};
const lock = await negotiate({ agentId: "web-checkout", cartParams: cart });
// → { sessionId, invoiceHash, status: "PARAMETER_NEGOTIATION", expiresIn: 300 }
saveOrder(lock.sessionId, cart, lock.invoiceHash);
Pass: recompute the hash of your cart with the invoice hash helper and compare it with lock.invoiceHash. The fixed test vector uses merchantId: "merch_demo_01" and produces e53d7b6af2c008d2fbec41e8ef8ddfac1fcaf3daa41a1c687369d5de7991a627. Your merchant ID changes the digest.
The lock lasts 300 seconds.
/v1/negotiate rejects a cart with 400 INVALID_CART_STRUCTURE if amount is zero or negative, items is empty, or amount is not exactly sum(price × qty) + taxCents + shippingCents. Compute amount on your server from the line items; never copy it from the browser.
Step 5A. TokenEx iFrame path (human enters the card)
- Your server generates the iFrame Authentication Key: a Base64 HMAC-SHA256 of
tokenExID|origin|timestamp|tokenScheme, keyed with your TokenEx iFrame Customer Secret Key (TOKENEX_IFRAME_SECRET). The timestamp is UTC,yyyyMMddHHmmss, and the key is valid for 20 minutes. Send the iFrame configuration, plussessionId, to the page. - The page loads the TokenEx iFrame script from TokenEx's servers, creates the iFrame with
new TokenEx.Iframe(containerId, config), and callsiframe.load(). The customer enters the card inside the iFrame. When they pay, the page callsiframe.tokenize()and sends thetokenandtokenHMACfrom thetokenizeevent to your server. The Quickstart has the full code. - Your server checks
tokenHMACwith your TokenEx iFrame Customer Secret Key, then finishes the payment using thesessionIdandinvoiceHashyou stored when you locked the cart:
if (!tokenIsGenuine(token, tokenHMAC, process.env.TOKENEX_IFRAME_SECRET)) throw new Error("token failed verification");
const result = await complete({ sessionId, invoiceHash, uttToken: token, protocol: "TOKENEX_DIRECT" });
// result.status === 'SETTLEMENT_COMPLETE'
// tokenIsGenuine(token, tokenHMAC, apiKey) is defined in the Quickstart (Step 4).
Pass: the iFrame appears, your page receives a tokenize event with a token and tokenHMAC (and only firstSix and lastFour of the card), your server confirms the HMAC, and /v1/checkout/complete returns SETTLEMENT_COMPLETE with invoiceHashMatch: true.
Step 5B. Agent checkout path (an AI agent pays)
- Publish a manifest at
https://shop.example.org/.well-known/ai-payments.json(template). Serve it over HTTPS withAccess-Control-Allow-Origin: *. - Publish a catalog at
/products.json. - Expose one endpoint that locks carts (the Step 4 code behind your own route).
- The agent verifies the locked cart against the buyer-approved order. Its backend calls
POST /v1/transactwith the signed credentials for Visa TAP or Mastercard Agent Pay, or with its existing vault token for TokenEx REST.
Pass: curl https://shop.example.org/.well-known/ai-payments.json returns JSON with your merchantId, and a sandbox agent run ends in SETTLEMENT_HANDOVER. The Sandbox & Testing Guide has ready-made scenarios.
Step 6. Receive settlement webhooks
- Create an HTTPS
POSTroute that reads the raw body and verifiesX-Ixopay-Signaturewith your webhook signing secret. Useexamples/verify-webhook.js. - Return
200within 3 seconds; do slow work afterwards. Make it idempotent oneventId. - Register a fixed public HTTPS destination with IXOPAY.
Pass: after a sandbox payment your route receives payment.settled, the signature verifies, and a deliberately altered body returns 401. Details: Webhooks.
Step 7. Prove it end to end
Run this checklist in sandbox before you ask for production:
-
/healthreachable from your production network. - A cart locks and returns the expected hash.
- A tampered cart is refused: lock a cart, then call
/v1/checkout/completewith a differentinvoiceHash; expect401 INVOICE_HASH_MISMATCH(Anti-tampering recipe). - A gateway acknowledgment leaves the order pending. Fulfillment uses the stored cart only after a matching processor confirmation.
- The webhook arrives, verifies, and is processed once even if delivered twice.
- A refund works, and a refund over the remaining balance is refused (Refunds & Disputes).
- Logs contain no card data, tokens, signatures or secrets.
Then complete the Go-Live Checklist and swap sandbox values for the production base URL, merchant ID, keys and webhook secret.
If a step fails
| Symptom | First thing to check |
|---|---|
| Connection timeout or TLS error | Outbound HTTPS from your server to the base URL |
401 UNAUTHORIZED_API_KEY | Check the gateway origin, environment and gateway credential. |
400 INVALID_CART_STRUCTURE | Field names (id, name, price, qty), integer amounts, non-empty items, and amount = sum of lines + tax + shipping |
| Browser CORS error | Call /v1/* from your server, not from the browser |
| iFrame does not appear, or reports "Invalid Authentication Key" | The origin, tokenExID, timestamp and tokenScheme you signed must match the iFrame configuration exactly; the key must be under 20 minutes old; run iframe.validateConfig() |
INVOICE_HASH_MISMATCH | Cart at lock differs from cart at payment; see troubleshooting |
SESSION_EXPIRED_OR_NOT_FOUND | More than 300 s elapsed, or the sessionId was never negotiated |
409 INVALID_STATE_TRANSITION | The session or iFrame token was already settled; do not resubmit |
| Webhook signature fails | You verified a re-serialized body; use the raw bytes |
Full list: Errors & Troubleshooting.