{
  "info": {
    "name": "BankGateway OpenBanking 2.0 Collection",
    "description": "Bộ sưu tập Postman chính thức của BankGateway. Tích hợp chuẩn OpenBanking: Tra cứu tài khoản Napas 24/7, Giải mã VietQR, Quản lý ví & Sổ cái.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.bankgateway.pro",
      "type": "string"
    },
    {
      "key": "apiKey",
      "value": "bg_live_YOUR_API_KEY",
      "type": "string"
    },
    {
      "key": "bankCode",
      "value": "MB",
      "type": "string"
    },
    {
      "key": "accountNumber",
      "value": "0783825888",
      "type": "string"
    },
    {
      "key": "jobId",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "01. Tra cứu tài khoản Napas 24/7",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "// Tự động sinh Idempotency-Key duy nhất nếu chưa có",
              "if (!pm.variables.get('idempotencyKey')) {",
              "    pm.variables.set('idempotencyKey', 'req_' + Date.now() + '_' + Math.random().toString(36).substring(2, 7));",
              "}"
            ]
          }
        },
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Status code is 200 or 404', function () {",
              "    pm.expect([200, 404, 503]).to.include(pm.response.code);",
              "});",
              "",
              "var jsonData = pm.response.json();",
              "if (pm.response.code === 200) {",
              "    pm.test('Tìm thấy chủ tài khoản', function () {",
              "        pm.expect(jsonData.success).to.eql(true);",
              "        pm.expect(jsonData.data.accountName).to.be.a('string');",
              "        console.log('Chủ TK:', jsonData.data.accountName, 'Latency:', jsonData.data.latencyMs + 'ms');",
              "    });",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "X-API-Key",
            "value": "{{apiKey}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Idempotency-Key",
            "value": "{{idempotencyKey}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"bankCode\": \"{{bankCode}}\",\n  \"accountNumber\": \"{{accountNumber}}\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/lookup",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "lookup"]
        },
        "description": "Tra cứu tên chủ tài khoản ngân hàng thụ hưởng Napas 24/7 theo thời gian thực."
      }
    },
    {
      "name": "02. Kiểm tra số dư ví & Quota",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "X-API-Key",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/wallet/balance",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "wallet", "balance"]
        },
        "description": "Xem số dư ví khả dụng, tiền giữ chỗ và số lượt gói còn lại."
      }
    },
    {
      "name": "03. Sao kê sổ cái (Ledger Statement)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "X-API-Key",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/wallet/statement?limit=50",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "wallet", "statement"],
          "query": [
            {
              "key": "limit",
              "value": "50"
            }
          ]
        },
        "description": "Đối soát biến động số dư và các khoản khấu trừ minh bạch 100%."
      }
    },
    {
      "name": "04. Giải mã VietQR EMVCo",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"qrCode\": \"00020101021238540010A00000072701240006970422011007838258880208QRIBFTTA53037045802VN63048596\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/vietqr/decode",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "vietqr", "decode"]
        },
        "description": "Đọc mã VietQR và trích xuất mã BIN ngân hàng cùng số tài khoản thụ hưởng."
      }
    },
    {
      "name": "05. Danh mục 68 Ngân hàng / Công ty tài chính",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/api/v1/banks",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "banks"]
        },
        "description": "Lấy danh sách mã ngân hàng, mã BIN Napas và tên đầy đủ của 68 Ngân hàng / Công ty tài chính."
      }
    }
  ]
}
