{
  "info": {
    "name": "IXOPAY Payment Agent API",
    "description": "Set baseUrl to the HTTPS gateway origin supplied during onboarding. Set merchantId, tokenexId and a local secret variable gatewayKey for this environment. The examples use X-API-Key. Run Negotiate to save sessionId and invoiceHash. Payment and refund responses acknowledge gateway records; confirm the processor outcome separately.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://<ixopay-payment-agent-host>"
    },
    {
      "key": "merchantId",
      "value": "<your-merchant-id>"
    },
    {
      "key": "tokenexId",
      "value": ""
    },
    {
      "key": "gatewayKey",
      "value": ""
    },
    {
      "key": "sessionId",
      "value": ""
    },
    {
      "key": "invoiceHash",
      "value": ""
    },
    {
      "key": "transactionId",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Discovery",
      "item": [
        {
          "name": "Health",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/health",
              "host": ["{{baseUrl}}"],
              "path": ["health"]
            },
            "description": ""
          }
        },
        {
          "name": "Discovery manifest",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/.well-known/ai-payments.json",
              "host": ["{{baseUrl}}"],
              "path": [".well-known", "ai-payments.json"]
            },
            "description": ""
          }
        },
        {
          "name": "JWKS",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/.well-known/jwks.json",
              "host": ["{{baseUrl}}"],
              "path": [".well-known", "jwks.json"]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Payments",
      "item": [
        {
          "name": "1. Negotiate (lock cart)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/negotiate",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "negotiate"]
            },
            "description": "Locks the cart; stores sessionId and invoiceHash.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"agentId\": \"postman\",\n  \"cartParams\": {\n    \"merchantId\": \"{{merchantId}}\",\n    \"currency\": \"USD\",\n    \"amount\": 4200,\n    \"items\": [\n      {\n        \"id\": \"SKU-A\",\n        \"name\": \"Lip Treat\",\n        \"price\": 1600,\n        \"qty\": 1\n      },\n      {\n        \"id\": \"SKU-B\",\n        \"name\": \"Glazing Fluid\",\n        \"price\": 2600,\n        \"qty\": 1\n      }\n    ]\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const j = pm.response.json();",
                  "pm.test('locked', () => pm.response.code === 200 && j.sessionId && j.invoiceHash.length === 64);",
                  "pm.collectionVariables.set('sessionId', j.sessionId);",
                  "pm.collectionVariables.set('invoiceHash', j.invoiceHash);"
                ]
              }
            }
          ],
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "2a. Checkout complete (iFrame token)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/checkout/complete",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "checkout", "complete"]
            },
            "description": "Records the iFrame checkout handover. Wait for independent processor confirmation before fulfillment.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sessionId\": \"{{sessionId}}\",\n  \"invoiceHash\": \"{{invoiceHash}}\",\n  \"uttToken\": \"<token from the iFrame tokenize event>\",\n  \"protocol\": \"TOKENEX_DIRECT\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const j = pm.response.json();",
                  "pm.test('settled', () => j.status === 'SETTLEMENT_COMPLETE');",
                  "pm.collectionVariables.set('transactionId', j.transactionId);"
                ]
              }
            }
          ],
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "2b. Transact (AP4M)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/transact",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "transact"]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sessionId\": \"{{sessionId}}\",\n  \"protocol\": \"AP4M\",\n  \"credentials\": {\n    \"layer1\": \"<SD-JWT>\",\n    \"layer2\": \"<SD-JWT>\",\n    \"layer3a\": \"<SD-JWT>\",\n    \"layer3b\": \"<SD-JWT>\",\n    \"mandateInvoiceHash\": \"{{invoiceHash}}\"\n  },\n  \"cartParams\": {\n    \"merchantId\": \"{{merchantId}}\",\n    \"currency\": \"USD\",\n    \"amount\": 4200,\n    \"items\": [\n      {\n        \"id\": \"SKU-A\",\n        \"name\": \"Lip Treat\",\n        \"price\": 1600,\n        \"qty\": 1\n      },\n      {\n        \"id\": \"SKU-B\",\n        \"name\": \"Glazing Fluid\",\n        \"price\": 2600,\n        \"qty\": 1\n      }\n    ]\n  },\n  \"l2Mandate\": {\n    \"mandateId\": \"m1\",\n    \"userFidoPubkeyId\": \"k1\",\n    \"maxAmountCents\": 5000,\n    \"currency\": \"USD\",\n    \"allowedMerchantIds\": [\n      \"{{merchantId}}\"\n    ],\n    \"validUntil\": \"2027-01-01T00:00:00Z\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "2c. Transact (Visa TAP) - add Signature headers",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/transact",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "transact"]
            },
            "description": "Add Signature-Input and Signature headers (see examples/visa-tap-sign.js). body.paymentContainer.invoiceHash is required and is covered by the content-digest.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sessionId\": \"{{sessionId}}\",\n  \"protocol\": \"VISA_TAP\",\n  \"cartParams\": {\n    \"merchantId\": \"{{merchantId}}\",\n    \"currency\": \"USD\",\n    \"amount\": 4200,\n    \"items\": [\n      {\n        \"id\": \"SKU-A\",\n        \"name\": \"Lip Treat\",\n        \"price\": 1600,\n        \"qty\": 1\n      },\n      {\n        \"id\": \"SKU-B\",\n        \"name\": \"Glazing Fluid\",\n        \"price\": 2600,\n        \"qty\": 1\n      }\n    ]\n  },\n  \"body\": {\n    \"consumerRecognition\": {\n      \"tavv\": \"<tavv>\"\n    },\n    \"paymentContainer\": {\n      \"invoiceHash\": \"{{invoiceHash}}\",\n      \"vtsToken\": \"<token>\",\n      \"expiry\": \"12/28\"\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "3. Step-up (passkey assertion)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/transact/step-up",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "transact", "step-up"]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sessionId\": \"{{sessionId}}\",\n  \"assertion\": {\n    \"credentialId\": \"\",\n    \"authenticatorData\": \"\",\n    \"clientDataJSON\": \"\",\n    \"signature\": \"\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "Split mandate",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/transact/split",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "transact", "split"]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"l3aToken\": \"<jwt>\",\n  \"l3bToken\": \"<jwt>\",\n  \"cartParams\": {\n    \"merchantId\": \"{{merchantId}}\",\n    \"currency\": \"USD\",\n    \"amount\": 4200,\n    \"items\": [\n      {\n        \"id\": \"SKU-A\",\n        \"name\": \"Lip Treat\",\n        \"price\": 1600,\n        \"qty\": 1\n      },\n      {\n        \"id\": \"SKU-B\",\n        \"name\": \"Glazing Fluid\",\n        \"price\": 2600,\n        \"qty\": 1\n      }\n    ]\n  },\n  \"mandateInvoiceHash\": \"{{invoiceHash}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        }
      ]
    },
    {
      "name": "After payment",
      "item": [
        {
          "name": "Refund",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/refund",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "refund"]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"originalTransactionId\": \"{{transactionId}}\",\n  \"merchantId\": \"{{merchantId}}\",\n  \"amountCents\": 1600,\n  \"currency\": \"USD\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        },
        {
          "name": "Audit proof",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tx-tokenex-id",
                "value": "{{tokenexId}}"
              },
              {
                "key": "X-API-Key",
                "value": "{{gatewayKey}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/audit/proof?transaction_id={{transactionId}}",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "audit", "proof"],
              "query": [
                {
                  "key": "transaction_id",
                  "value": "{{transactionId}}"
                }
              ]
            },
            "description": ""
          },
          "protocolProfileBehavior": {
            "followRedirects": false
          }
        }
      ]
    }
  ]
}
