Errors & Troubleshooting
How errors look
Errors are JSON with an error code. Payment-path 401 errors also include errorCategory ("POLICY_DENIAL" or "AUTH_FAILURE"), plus message and context:
{ "error": "INVOICE_HASH_MISMATCH", "errorCategory": "AUTH_FAILURE" }
{ "error": "BUDGET_CAP_EXCEEDED", "errorCategory": "POLICY_DENIAL", "message": "Cart amount (15000 cents) exceeds mandate budget limit (5000 cents)", "stepUpChallenge": { … } }
Branch on error (and errorCategory), not on message text.
A stateful payment request can return 503 DATABASE_UNAVAILABLE when the gateway cannot access its store. Save tx-refid and check readiness at /readyz. If a payment or refund was already submitted, reconcile the order with your gateway and processor records before submitting another attempt.
Error codes seen on the payment path
Request and structure
| Code | HTTP | Meaning | Fix |
|---|---|---|---|
INVALID_REQUEST_STRUCTURE | 400 | Missing agentId/cart on negotiate, or protocol/cart on transact. | Send the required fields. |
INVALID_CART_STRUCTURE | 400 | Cart is missing merchantId, currency, amount (> 0) or items, or a field has the wrong type. | Fix the cart; amounts are integers in minor units. |
UNSUPPORTED_PROTOCOL | 400 | protocol isn't AP4M/VISA_TAP/TOKENEX_REST (or aliases). | Use a supported protocol and include credentials. |
MALFORMED_RFC9421_HEADERS / MALFORMED_RFC9421_PARAMS | 401 | Signature / Signature-Input missing or unparseable. | Send both headers; include keyid and created. |
MALFORMED_PAYLOAD_STRUCTURE, MALFORMED_JSON, MISSING_MANDATE_HASH | 400 | Body or hash input is invalid. | Send valid JSON and include the mandate hash. |
UNAUTHORIZED_API_KEY | 401 | Gateway key authentication failed. | Verify your gateway origin, credential and header against the onboarding configuration. |
Visa TAP may return 401 INVALID_ENCRYPTED_BUNDLE for an unreadable encrypted payment bundle, or 401 INVALID_CREDENTIAL_HASH when dynamic verification fails. Verify the provisioned recipient key, credential mode and locked invoice hash on your server. Share only the error code and request reference with support.
Session and replay
| Code | HTTP | Meaning | Fix |
|---|---|---|---|
SESSION_EXPIRED_OR_NOT_FOUND | 401 | sessionId unknown or older than 300 s. | Call /v1/negotiate again. |
NONCE_REPLAY_DETECTED | 401 | Visa TAP keyid+created+nonce reused within 300 s. | Fresh nonce per request. |
INVALID_STATE_TRANSITION | 409 | A session that already failed or settled was submitted again. | One session per attempt; negotiate a new session. |
Cryptographic
| Code | HTTP | Meaning | Fix |
|---|---|---|---|
INVOICE_HASH_MISMATCH | 401 | Submitted cart doesn't hash to the negotiated session hash or signed mandate hash. | Rebuild the cart exactly as locked; recompute the hash (rules). |
INVALID_SIGNATURE | 401 | Signature failed verification. | Check key, algorithm and signature base string. |
INTEGRITY_VIOLATION | 401 | AP4M layer2.sd_hash doesn't match layer1. | Mint L2 from the same L1 you submit. |
CRYPTOGRAM_EXPIRED | 401 | AP4M layer exp passed, or Visa expires passed. | Re-issue; sync clocks. |
CLOCK_SKEW_LIMIT_EXCEEDED | 401 | Visa created more than 300 s in the future. | Sync clock (NTP). |
INVALID_TAG_SCOPE | 401 | Visa tag isn't agent-payer-auth. | Set the tag. |
UNRESOLVED_KEY_ID | 401 | The keyid can't be resolved to a public key. | Use a gateway JWKS key or configure the external JWKS URL. |
UNSUPPORTED_SIGNATURE_ALGORITHM | 401 | alg not ed25519, rsa-pss-sha256 or ps256. | Use a supported algorithm. |
Spending rules and step-up (errorCategory: "POLICY_DENIAL")
| Code | HTTP | Meaning | Fix |
|---|---|---|---|
MANDATE_EXPIRED | 401 | Mandate validUntil timestamp has passed. | Issue a fresh L2 mandate. |
CURRENCY_MISMATCH | 401 | Mandate and cart currencies differ. | Align currencies. |
UNAUTHORIZED_MERCHANT | 401 | Merchant not in allowedMerchantIds. | Ask the user to approve the merchant. |
UNAUTHORIZED_SKU | 401 | An item id isn't in allowedSkus. | Remove the item or get approval. |
BUDGET_CAP_EXCEEDED | 401 | Amount exceeds the mandate cap. | Stop. In the pilot, continue only if the response includes a challenge and the user completes it. A signed AP4M policy denial can omit the challenge. |
INVALID_STEPUP_PAYLOAD | 400 | sessionId or assertion missing on step-up. | Send both. |
CHALLENGE_NOT_FOUND / CHALLENGE_EXPIRED / INVALID_FIDO2_CHALLENGE / FIDO2_SIGNATURE_INVALID / INVALID_FIDO2_ASSERTION | 401 | No live challenge, challenge older than 300 s, challenge mismatch, or invalid assertion signature. | Request a new challenge and complete it within 300 s. |
Vault and checkout
| Code | HTTP | Meaning | Fix |
|---|---|---|---|
VAULT_AUTH_FAILED and other vault codes | 502 (AP4M), or TOKENEX_FAILED in the iFrame | Vault authentication or mapping failed. | Contact your IXOPAY integration manager. |
MISSING_UTT_TOKEN / MISSING_SESSION_ID | 400 | /v1/checkout/complete called without uttToken or without a pre-negotiated sessionId. | Send both sessionId and the iFrame's uttToken. |
PCI_SCOPE_VIOLATION_RAW_PAN_PROHIBITED | 400 | Raw 13–19 digit card number sent to TOKENEX_REST on /v1/transact. | Tokenize browser-direct first and send only the vault token. |
DO_NOT_CREATE_TOKEN, UNAUTHORIZED_INTENT_GATE, UNAUTHORIZED_PPCB_GATE | 403 | Token creation refused because intent or cart binding wasn't verified. | Complete verification first. |
TOKEN_NOT_FOUND | 404 | Network token not in the vault. | Re-tokenize through the TokenEx iFrame. |
ORIGINAL_TRANSACTION_NOT_FOUND | 404 | /v1/refund called for a transactionId that has not settled. | Pass a valid settled originalTransactionId. |
REFUND_AMOUNT_EXCEEDS_ORIGINAL_TRANSACTION | 400 | Cumulative refund amount exceeds the original settled transaction amount. | Request an amount within remainingRefundableCents. |
MISSING_TRANSACTION_ID | 400 | /v1/audit/proof called without transaction_id / transactionId. | Supply the query parameter. |
TRANSACTION_NOT_FOUND | 404 | /v1/audit/proof called for an unknown transactionId. | Query a settled transactionId. |
WebMCP
| Code | HTTP | Meaning |
|---|---|---|
USER_CONFIRMATION_REQUIRED | 403 | Transact-tier tool called without a valid single-use session consent token. |
INVALID_ARGUMENTS | 400 | Tool arguments missing or not an object. |
UNKNOWN_TOOL | 400 | Tool isn't registered. |
Troubleshooting by symptom
"INVOICE_HASH_MISMATCH but my cart is the same"
Nine times in ten it is one of these. Check them in order:
- Item order or extra fields. Items are sorted by
id; onlyid,name,price,qtyare hashed. A differingnamestring (even whitespace) changes the hash. - Optional fields.
shippingCents: 0≠ omitted. Include optional fields in both places or neither. - Number formats. Use integers.
42.00vs4200are different hashes (and wrong units). - Currency case. The Payment Agent upper-cases the currency before hashing, so
usdandUSDmatch. If you compute the hash yourself, upper-case it too. - Different
merchantId. The lock and the transact call must use the identical value. - Wrong hash in
mandateInvoiceHash. It must equal the hash for the cart you submit.
Debug: run examples/invoice-hash.js on both carts and diff the canonical strings.
"INVALID_SIGNATURE on Visa TAP"
- Does the signature base match your request's
Host/X-Forwarded-Host(@authority) and request path (@path, e.g./v1/transact)? (Details.) - Is
content-digestcomputed overJSON.stringifyof the object under thebodykey, and does that key's content match what you send byte-for-byte after JSON parsing? - Is
@signature-paramsthe wholeSignature-Inputheader value, includingsig1=? - Does the
keyidresolve to the public half of the key you signed with? - Compare against
examples/visa-tap-sign.js.
"SESSION_EXPIRED_OR_NOT_FOUND right after negotiating"
- More than 300 seconds passed, or the session was already used. Sessions are single-use; negotiate again.
- If it happens within seconds on every attempt, report it to your IXOPAY integration manager with the
sessionId.
"Works in one environment, 401s in another"
- Clock drift on the agent host:
created/expiresand AP4Mexpare checked against the server's clock. - Sandbox and production use different keys; sign with keys published in the JWKS of the environment you are calling.
"BUDGET_CAP_EXCEEDED but the user is fine with it"
Stop on a budget denial. A response containing stepUpChallenge can start the pilot step-up flow. A denial without a challenge requires a newly authorized mandate before a new attempt.
Webhook signature fails
You are probably verifying a re-serialized body. Use the raw bytes, build "<t>.<raw>", and use the v1 value. See Webhooks.
Getting support
Include: the error code, HTTP status, approximate time (UTC), the sessionId, and the Payment Agent host. Never send private keys, full mandates, card data or tokens.