Sandbox & Testing Guide
Test everything in the sandbox before production. This guide lists what to test, how, and what you should see.
The sandbox
- Uses its own base URL, merchant ID, keys, webhook secret and test cards (from your IXOPAY integration manager).
- Card-network calls go to the networks' sandboxes, so no real money moves.
- Sandbox and production use different keys. A mandate signed for one will not verify in the other.
- Sessions last 300 seconds in both.
Quick health probes
curl $PA/health # status HEALTHY, version
curl $PA/.well-known/ai-payments.json # supportedProtocols, endpoints
curl $PA/.well-known/jwks.json # public keys
Test plan
A. Merchant checkout (TokenEx iFrame)
| # | Test | Expected |
|---|---|---|
| A1 | Lock a valid cart | 200, sessionId, 64-char invoiceHash, expiresIn: 300 |
| A2 | Recompute the hash locally | Equals invoiceHash (examples/invoice-hash.js) |
| A3 | Create the iFrame from the configuration your server returns (new TokenEx.Iframe(...), load()) | The iFrame appears and the load event fires |
| A4 | Submit a sandbox test card | The tokenize event returns a token, tokenHMAC, firstSix and lastFour |
| A5 | Verify tokenHMAC on your server, then POST /v1/checkout/complete | SETTLEMENT_COMPLETE, invoiceHashMatch: true, zeroPanScrubbed: true |
| A6 | Complete with a wrong invoiceHash | 401 INVOICE_HASH_MISMATCH, session terminated |
| A7 | Enter a too-short card number and call tokenize() | A validate event with isValid: false; no token is produced |
| A8 | Change the origin (or corrupt the Authentication Key) in the iFrame configuration | The iFrame does not load, and an error event reports an invalid Authentication Key |
| A8a | Alter tokenHMAC before it reaches your server | Your server rejects the token and does not call /v1/checkout/complete |
| A9 | Wait over 300 s, then pay | 401 SESSION_EXPIRED_OR_NOT_FOUND; lock again |
| A9a | Lock a cart whose amount is not the sum of its lines | 400 INVALID_CART_STRUCTURE |
| A9b | Complete without a sessionId | 400 MISSING_SESSION_ID |
| A9c | Complete the same session (or token) twice | Second call 409 INVALID_STATE_TRANSITION |
| A10 | Double-click Pay | Your server completes the order once (TokenEx iFrame checkout recipe) |
| A11 | Refund part of the payment, then more than the remainder | 200 with remainingRefundableCents, then 400 REFUND_AMOUNT_EXCEEDS_ORIGINAL_TRANSACTION |
| A12 | Refund an unknown transaction; fetch proof for an unknown transaction | 404 ORIGINAL_TRANSACTION_NOT_FOUND; 404 TRANSACTION_NOT_FOUND |
B. Agent payments
Ask your IXOPAY integration manager for sandbox signing keys and test mandates. If the Developer Console is enabled for you, its test-vector generator can produce signed sandbox payloads (Developer Console Guide). Run each scenario and confirm the exact result.
| # | Scenario | Expected |
|---|---|---|
| B1 | Valid Mastercard Agent Pay (AP4M) mandate | 200 SETTLEMENT_HANDOVER, transactionId tx_ap4m_… |
| B2 | Valid Visa TAP request with body.paymentContainer.invoiceHash | 200 SETTLEMENT_HANDOVER, transactionId tx_visa_… |
| B2a | Visa TAP request with paymentContainer.invoiceHash missing or different | 401 INVOICE_HASH_MISMATCH |
| B2b | Replay an identical AP4M mandate after it settled | 401 NONCE_REPLAY_DETECTED |
| B3 | Cart price changed after signing (PI2PI attempt) | 401 INVOICE_HASH_MISMATCH |
| B4 | Visa TAP request replayed unchanged | Second call 401 NONCE_REPLAY_DETECTED |
| B5 | Visa TAP expires in the past | 401 CRYPTOGRAM_EXPIRED |
| B6 | Corrupted Visa signature | 401 INVALID_SIGNATURE |
| B7 | Visa tag not agent-payer-auth | 401 INVALID_TAG_SCOPE |
| B8 | Cart currency differs from mandate | 401 CURRENCY_MISMATCH |
| B9 | Merchant not in allowedMerchantIds | 401 UNAUTHORIZED_MERCHANT |
| B10 | Item not in allowedSkus | 401 UNAUTHORIZED_SKU |
| B11 | Mandate past validUntil | 401 MANDATE_EXPIRED |
| B12 | Exceed a request-level cap, then test a signed AP4M cap independently | 401 BUDGET_CAP_EXCEEDED. The request-level pilot flow can include a challenge. Stop on a denial without one. |
| B13 | Complete step-up, then retry with the same sessionId | 200 SETTLEMENT_HANDOVER |
| B14 | Reuse a settled session on /v1/transact | 409 INVALID_STATE_TRANSITION |
| B14a | Pilot assertion uses a credential different from the challenge credential | 401 step-up failure. |
| B15 | AP4M layer2 minted from a different layer1 | 401 INTEGRITY_VIOLATION |
All 401 responses carry errorCategory (POLICY_DENIAL or AUTH_FAILURE); assert on it.
C. Webhooks
| # | Test | Expected |
|---|---|---|
| C1 | Complete a payment with webhookUrl set | payment.settled arrives |
| C2 | Verify the signature on the raw body | Passes |
| C3 | Alter one character after signing | Your receiver returns 401 |
| C4 | Return 500 once | Delivery is retried (up to 3 attempts) |
| C5 | Receive the same eventId twice | Processed once |
| C6 | Receive an event 10 minutes old | Rejected by your timestamp check |
| C7 | Issue a refund with webhookUrl | refund.settled arrives |
D. Failure and edge cases
- Network timeout: your client gives up after 5 s and does not blindly retry a payment.
- In a gateway configured for key authentication, a missing or incorrect gateway key returns
401 UNAUTHORIZED_API_KEY. Test the provisioned HTTPS entry point. - Register a fixed public HTTPS webhook endpoint. Check that your deployment restricts egress to approved destinations.
- iFrame origin mismatch: the iFrame refuses to load. Sign the exact origin of the page that shows it.
- Browser origin not allowed: CORS refusal; call
/v1/*from your server. - Clock drift: set your agent host to NTP; Visa
createdmore than 300 s ahead givesCLOCK_SKEW_LIMIT_EXCEEDED.
Latency
Core routing is designed to stay under 10 ms; the card-network round trip typically adds 150–300 ms. Transact responses include routingLatencyMs and an X-Gateway-Routing-Latency-Ms header so you can separate the two.
Evidence for sign-off
For sign-off, share test-case IDs, UTC times, correlation IDs, transaction IDs, HTTP status, error codes and the expected versus observed outcome. Use a redacted summary for webhook and iFrame checks. Exclude request and response bodies, credentials, tokens, mandates, signatures, cryptograms and card data from logs and attachments.
Automating
Use the OpenAPI file (openapi.yaml) or the Postman collection (ixopay-payment-agent.postman_collection.json) to generate a contract test suite, and run the table above in CI against the sandbox.