{
  "info": {
    "name": "AIK Digital × EFU Life Integration",
    "description": "Complete API collection for the AIK Digital × EFU Life Technical Integration (v1.0)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url",   "value": "http://localhost:8000" },
    { "key": "open_id",    "value": "a3f1c92e-4b87-41d0-9f3e-7d2c10ab5e6f" },
    { "key": "order_id",   "value": "EFU-ORD-20250115-001234" }
  ],
  "item": [
    {
      "name": "1. iframe Entry Point",
      "item": [
        {
          "name": "1.1 Load iframe (new customer)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/iframe?uuid={{open_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "iframe"],
              "query": [{ "key": "uuid", "value": "{{open_id}}" }]
            },
            "description": "First call from the AIK Digital app when loading the EFU Life iframe. Resolves UUID → customer."
          }
        },
        {
          "name": "1.2 Load iframe (missing UUID — error)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/iframe",
              "host": ["{{base_url}}"],
              "path": ["api", "iframe"]
            }
          }
        }
      ]
    },
    {
      "name": "2. Authentication",
      "item": [
        {
          "name": "2.1 Apply Token",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/aik/auth/apply-token",
              "host": ["{{base_url}}"],
              "path": ["api", "aik", "auth", "apply-token"]
            },
            "description": "Authenticate with AIK Digital and obtain/cache an access token. Maps to POST /v2/authentications/applyToken."
          }
        },
        {
          "name": "2.2 Revoke Token",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/aik/auth/revoke-token",
              "host": ["{{base_url}}"],
              "path": ["api", "aik", "auth", "revoke-token"]
            },
            "description": "Revoke the current cached access token. Maps to POST /v2/authentications/revokeToken."
          }
        }
      ]
    },
    {
      "name": "3. Customer",
      "item": [
        {
          "name": "3.1 Inquire User Info",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"uuid\": \"{{open_id}}\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/customers/inquire",
              "host": ["{{base_url}}"],
              "path": ["api", "customers", "inquire"]
            },
            "description": "Directly call AIK Digital inquireUserInfo. Maps to POST /v2/users/inquireUserInfo."
          }
        },
        {
          "name": "3.2 Get Customer by openId",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/customers/{{open_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "customers", "{{open_id}}"]
            },
            "description": "Fetch an existing customer record from the EFUL database."
          }
        }
      ]
    },
    {
      "name": "4. Payments",
      "item": [
        {
          "name": "4.1 Create Payment Order",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"open_id\":      \"{{open_id}}\",\n  \"policy_title\": \"Policy Payment - Health Basic Plan\",\n  \"amount\":       5000,\n  \"product_code\": \"HEALTH-BASIC\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/payments/create",
              "host": ["{{base_url}}"],
              "path": ["api", "payments", "create"]
            },
            "description": "Create a payment order with AIK Digital. Maps to POST /v2/payments/createPayment. Use CASHIER mode."
          }
        },
        {
          "name": "4.2 Query Payment Status",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/payments/{{order_id}}/status",
              "host": ["{{base_url}}"],
              "path": ["api", "payments", "{{order_id}}", "status"]
            },
            "description": "Query local EFUL DB status for a payment order. Use when polling for unknown (U) outcomes."
          }
        }
      ]
    },
    {
      "name": "5. Callbacks (AIK Digital → EFU Life)",
      "item": [
        {
          "name": "5.1 Simulate Callback — SUCCESS",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"paymentTransactionID\": \"TXN-AIK-20250115-987654\",\n  \"resultStatus\":        \"S\",\n  \"orderStatus\":         \"SUCCESS\",\n  \"paymentAmount\":       \"5000\",\n  \"openId\":              \"{{open_id}}\",\n  \"msisdn\":              \"03115011412\",\n  \"paymentOrderID\":      \"{{order_id}}\",\n  \"merchantID\":          \"EFULAssurance\",\n  \"resultCode\":          \"SUCCESS\",\n  \"resultMessage\":       \"Payment completed successfully\",\n  \"paymentFinishTime\":   \"2025-01-15T10:20:12+05:00\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/callbacks/payment",
              "host": ["{{base_url}}"],
              "path": ["api", "callbacks", "payment"]
            },
            "description": "Simulate a successful payment callback from AIK Digital (Scenario A). Policy should be activated."
          }
        },
        {
          "name": "5.2 Simulate Callback — FAILED (Insufficient Balance)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"paymentTransactionID\": \"TXN-AIK-20250115-987655\",\n  \"resultStatus\":        \"F\",\n  \"orderStatus\":         \"FAILED\",\n  \"paymentAmount\":       \"5000\",\n  \"openId\":              \"{{open_id}}\",\n  \"msisdn\":              \"03115011412\",\n  \"paymentOrderID\":      \"{{order_id}}\",\n  \"merchantID\":          \"EFULAssurance\",\n  \"resultCode\":          \"USER_BALANCE_NOT_ENOUGH\",\n  \"resultMessage\":       \"Insufficient balance in customer wallet\",\n  \"paymentFinishTime\":   \"2025-01-15T10:25:03+05:00\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/callbacks/payment",
              "host": ["{{base_url}}"],
              "path": ["api", "callbacks", "payment"]
            },
            "description": "Simulate a failed payment callback (Scenario B). Policy must NOT be activated."
          }
        },
        {
          "name": "5.3 Simulate Callback — UNKNOWN (Timeout)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"paymentTransactionID\": \"TXN-AIK-20250115-987656\",\n  \"resultStatus\":        \"U\",\n  \"orderStatus\":         \"UNKNOWN\",\n  \"paymentAmount\":       \"5000\",\n  \"openId\":              \"{{open_id}}\",\n  \"msisdn\":              \"03115011412\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/callbacks/payment",
              "host": ["{{base_url}}"],
              "path": ["api", "callbacks", "payment"]
            },
            "description": "Simulate an unknown/timeout callback (Scenario C). Do NOT activate policy or refund."
          }
        }
      ]
    }
  ]
}
