{
  "info": {
    "_postman_id": "1e2c726a-59b4-4ee7-9e56-14e911f8f7a4",
    "name": "KanaCash Digit9 Send Money API",
    "description": "Digit9 integration collection for KanaCash USD send-money flow. Includes token, quote, send, and status APIs only.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{accessToken}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://core.kanacash.com/api/v1",
      "type": "string"
    },
    {
      "key": "sandboxBaseUrl",
      "value": "https://sandbox.kanacash.com/api/v1",
      "type": "string"
    },
    {
      "key": "clientId",
      "value": "",
      "type": "string"
    },
    {
      "key": "clientSecret",
      "value": "",
      "type": "string"
    },
    {
      "key": "accessToken",
      "value": "",
      "type": "string"
    },
    {
      "key": "phone",
      "value": "+231881234567",
      "type": "string"
    },
    {
      "key": "amount",
      "value": "125.50",
      "type": "string"
    },
    {
      "key": "quoteId",
      "value": "",
      "type": "string"
    },
    {
      "key": "externalId",
      "value": "D9-ORDER-{{$timestamp}}",
      "type": "string"
    },
    {
      "key": "referenceId",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "1. Token",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json.access_token) {",
              "  pm.collectionVariables.set('accessToken', json.access_token);",
              "}",
              "pm.test('Token generated', function () {",
              "  pm.expect(pm.response.code).to.eql(200);",
              "  pm.expect(json.access_token).to.be.a('string');",
              "});"
            ]
          }
        }
      ],
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"client_id\": \"{{clientId}}\",\n  \"client_secret\": \"{{clientSecret}}\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/digit9/auth/token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "digit9",
            "auth",
            "token"
          ]
        },
        "description": "Generate a bearer token using Digit9 client credentials. The token is valid for 1 hour."
      },
      "response": []
    },
    {
      "name": "2. Quote Send Money",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json.data && json.data.quoteId) {",
              "  pm.collectionVariables.set('quoteId', json.data.quoteId);",
              "}",
              "pm.test('Quote created', function () {",
              "  pm.expect(pm.response.code).to.eql(200);",
              "  pm.expect(json.data.quoteId).to.match(/^D9Q-/);",
              "});"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"phone\": \"{{phone}}\",\n  \"amount\": {{amount}},\n  \"currency\": \"USD\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/digit9/v1/send/quote",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "digit9",
            "v1",
            "send",
            "quote"
          ]
        },
        "description": "Validate receiver phone, USD wallet, amount, and hardcoded limits. Quote expires after 10 minutes and is single-use."
      },
      "response": []
    },
    {
      "name": "3. Send Money",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (!pm.collectionVariables.get('externalId') || pm.collectionVariables.get('externalId').includes('{{$timestamp}}')) {",
              "  pm.collectionVariables.set('externalId', 'D9-ORDER-' + Date.now());",
              "}"
            ]
          }
        },
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json.data && json.data.referenceId) {",
              "  pm.collectionVariables.set('referenceId', json.data.referenceId);",
              "}",
              "pm.test('Send money completed', function () {",
              "  pm.expect(pm.response.code).to.eql(200);",
              "  pm.expect(json.data.status).to.eql('completed');",
              "});"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"quoteId\": \"{{quoteId}}\",\n  \"externalId\": \"{{externalId}}\",\n  \"note\": \"Digit9 Postman test\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/digit9/v1/send",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "digit9",
            "v1",
            "send"
          ]
        },
        "description": "Consumes the quote and credits the receiver's KanaCash USD wallet."
      },
      "response": []
    },
    {
      "name": "4A. Status By Reference ID",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/digit9/v1/send/{{referenceId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "digit9",
            "v1",
            "send",
            "{{referenceId}}"
          ]
        },
        "description": "Check transaction status using the KanaCash referenceId returned by Send Money."
      },
      "response": []
    },
    {
      "name": "4B. Status By External ID",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/digit9/v1/send/status?externalId={{externalId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "digit9",
            "v1",
            "send",
            "status"
          ],
          "query": [
            {
              "key": "externalId",
              "value": "{{externalId}}"
            }
          ]
        },
        "description": "Check transaction status using Digit9 externalId."
      },
      "response": []
    }
  ]
}
