{
  "info": {
    "name": "pawaPay middleware (payment.cypadi.com)",
    "description": "Test all api/v1 routes. Set collection variable base_url (e.g. https://payment.cypadi.com). Deposit create saves last_deposit_id for status/refund tests.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://payment.cypadi.com" },
    { "key": "last_deposit_id", "value": "" },
    { "key": "last_payout_id", "value": "" },
    { "key": "last_refund_id", "value": "" }
  ],
  "item": [
    {
      "name": "01 Toolkit - Availability (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/toolkit/availability.php?country=RWA&operationType=DEPOSIT",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "toolkit", "availability.php"],
          "query": [
            { "key": "country", "value": "RWA" },
            { "key": "operationType", "value": "DEPOSIT" }
          ]
        },
        "description": "Optional query: country (ISO alpha-3), operationType DEPOSIT|PAYOUT|REFUND|REMITTANCE."
      },
      "response": []
    },
    {
      "name": "02 Deposit - Create (POST)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "try {",
              "  const j = pm.response.json();",
              "  if (j && j.data && j.data.depositId) {",
              "    pm.collectionVariables.set('last_deposit_id', j.data.depositId);",
              "  }",
              "} catch (e) {}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"depositId\": \"{{$guid}}\",\n  \"phone\": \"250792524900\",\n  \"provider\": \"MTN_MOMO_RWA\",\n  \"amount\": \"10\",\n  \"currency\": \"RWF\",\n  \"country\": \"RWA\",\n  \"skipAvailabilityCheck\": true\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/api/v1/deposit/create.php",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "deposit", "create.php"]
        },
        "description": "Rwanda (RWA/RWF). skipAvailabilityCheck bypasses availability pre-check."
      },
      "response": []
    },
    {
      "name": "03 Deposit - Status (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/deposit/status.php?depositId={{last_deposit_id}}",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "deposit", "status.php"],
          "query": [{ "key": "depositId", "value": "{{last_deposit_id}}" }]
        }
      },
      "response": []
    },
    {
      "name": "04 Payout - Create (POST)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "try {",
              "  const j = pm.response.json();",
              "  if (j && j.data && j.data.payoutId) {",
              "    pm.collectionVariables.set('last_payout_id', j.data.payoutId);",
              "  }",
              "} catch (e) {}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"payoutId\": \"{{$guid}}\",\n  \"phone\": \"250792524900\",\n  \"provider\": \"MTN_MOMO_RWA\",\n  \"amount\": \"1\",\n  \"currency\": \"RWF\",\n  \"country\": \"RWA\",\n  \"skipAvailabilityCheck\": true\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/api/v1/payout/create.php",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "payout", "create.php"]
        }
      },
      "response": []
    },
    {
      "name": "05 Payout - Status (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/payout/status.php?payoutId={{last_payout_id}}",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "payout", "status.php"],
          "query": [{ "key": "payoutId", "value": "{{last_payout_id}}" }]
        }
      },
      "response": []
    },
    {
      "name": "06 Refund - Create (POST)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "try {",
              "  const j = pm.response.json();",
              "  if (j && j.data && j.data.refundId) {",
              "    pm.collectionVariables.set('last_refund_id', j.data.refundId);",
              "  }",
              "} catch (e) {}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"refundId\": \"{{$guid}}\",\n  \"depositId\": \"{{last_deposit_id}}\",\n  \"amount\": \"1\",\n  \"currency\": \"RWF\",\n  \"country\": \"RWA\",\n  \"skipAvailabilityCheck\": true\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/api/v1/refund/create.php",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "refund", "create.php"]
        },
        "description": "Requires last_deposit_id from 02."
      },
      "response": []
    },
    {
      "name": "07 Refund - Status (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/refund/status.php?refundId={{last_refund_id}}",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "refund", "status.php"],
          "query": [{ "key": "refundId", "value": "{{last_refund_id}}" }]
        }
      },
      "response": []
    },
    {
      "name": "08 Transaction - Status (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/transaction/status.php?type=DEPOSIT&id={{last_deposit_id}}",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "transaction", "status.php"],
          "query": [
            { "key": "type", "value": "DEPOSIT" },
            { "key": "id", "value": "{{last_deposit_id}}" }
          ]
        }
      },
      "response": []
    },
    {
      "name": "09 Transaction - List (GET)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/transaction/list.php?limit=20&offset=0",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "transaction", "list.php"],
          "query": [
            { "key": "limit", "value": "20" },
            { "key": "offset", "value": "0" }
          ]
        }
      },
      "response": []
    },
    {
      "name": "10 Webhook - Unified simulate deposit (POST)",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"depositId\": \"{{last_deposit_id}}\",\n  \"status\": \"COMPLETED\"\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/api/v1/webhook/unified.php",
          "host": ["{{base_url}}"],
          "path": ["api", "v1", "webhook", "unified.php"]
        }
      },
      "response": []
    }
  ]
}
