{
  "info": {
    "_postman_id": "8b9e67d2-9721-4a5c-8b89-28c0b5f54312",
    "name": "Single Billing V3 - Set Expired Billing",
    "description": "Postman Collection terdedikasi untuk pengujian siklus hidup pembatalan dan set expired billing V3 (TASK-SET-EXPIRED-BILLING-V3) mencakup 4 skenario terisolasi dengan assertion tests otomatis.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "1. Happy Path - Set Expired Berhasil",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"Status code is 200 OK\", function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "pm.test(\"Response structure and success flag are valid\", function () {",
              "    var jsonData = pm.response.json();",
              "    pm.expect(jsonData.success).to.eql(true);",
              "    pm.expect(jsonData.statusCode).to.eql(200);",
              "    pm.expect(jsonData.data).to.be.an(\"object\");",
              "    pm.expect(jsonData.data.fl_expired).to.eql(true);",
              "    pm.expect(jsonData.data.expired_date).to.be.a(\"string\");",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{bearerToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"trx_id_insw\": \"{{trx_id_unpaid}}\",\n  \"alasan\": \"Uji QA - Pembatalan warta oleh pengguna jasa\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v3/set-expired-billing",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v3",
            "set-expired-billing"
          ]
        },
        "description": "Skenario Happy Path: Billing aktif belum bayar di-set expired. Mengharapkan respons 200 OK dan fl_expired bernilai true."
      },
      "response": []
    },
    {
      "name": "2. Negative - Penolakan Billing Lunas",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"Status code is 400 Bad Request\", function () {",
              "    pm.response.to.have.status(400);",
              "});",
              "",
              "pm.test(\"Error message indicates billing already paid\", function () {",
              "    var jsonData = pm.response.json();",
              "    pm.expect(jsonData.success).to.eql(false);",
              "    pm.expect(jsonData.statusCode).to.eql(400);",
              "    pm.expect(jsonData.message).to.include(\"sudah dibayar\");",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{bearerToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"trx_id_insw\": \"{{trx_id_paid}}\",\n  \"alasan\": \"Uji QA - Percobaan expire tagihan lunas\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v3/set-expired-billing",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v3",
            "set-expired-billing"
          ]
        },
        "description": "Skenario Negatif: Billing dengan fl_paid = true dilarang di-set expired. Menghasilkan error 400 Bad Request."
      },
      "response": []
    },
    {
      "name": "3. Negative - Penolakan Billing Sudah Expired",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"Status code is 400 Bad Request\", function () {",
              "    pm.response.to.have.status(400);",
              "});",
              "",
              "pm.test(\"Error message indicates billing already expired\", function () {",
              "    var jsonData = pm.response.json();",
              "    pm.expect(jsonData.success).to.eql(false);",
              "    pm.expect(jsonData.statusCode).to.eql(400);",
              "    pm.expect(jsonData.message).to.include(\"status expired\");",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{bearerToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"trx_id_insw\": \"{{trx_id_expired}}\",\n  \"alasan\": \"Uji QA - Percobaan double expire\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v3/set-expired-billing",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v3",
            "set-expired-billing"
          ]
        },
        "description": "Skenario Negatif: Billing dengan fl_expired = true tidak boleh di-expire ulang (idempotency guard). Menghasilkan 400 Bad Request."
      },
      "response": []
    },
    {
      "name": "4. Negative - Penolakan Trx ID Tidak Ditemukan",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"Status code is 404 Not Found\", function () {",
              "    pm.response.to.have.status(404);",
              "});",
              "",
              "pm.test(\"Error message indicates billing record not found\", function () {",
              "    var jsonData = pm.response.json();",
              "    pm.expect(jsonData.success).to.eql(false);",
              "    pm.expect(jsonData.statusCode).to.eql(404);",
              "    pm.expect(jsonData.message).to.include(\"tidak ditemukan\");",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{bearerToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"trx_id_insw\": \"TRX-NON-EXISTENT-404\",\n  \"alasan\": \"Uji QA - Trx ID fiktif\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v3/set-expired-billing",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v3",
            "set-expired-billing"
          ]
        },
        "description": "Skenario Negatif: trx_id_insw tidak terdaftar di database. Menghasilkan respons 404 Not Found."
      },
      "response": []
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:3333",
      "type": "string"
    },
    {
      "key": "bearerToken",
      "value": "KZ6IlAA4NxocmCozKC71xaYymS7sMAgM_94h0gftFnG",
      "type": "string"
    },
    {
      "key": "trx_id_unpaid",
      "value": "510009B82CC17",
      "type": "string"
    },
    {
      "key": "trx_id_paid",
      "value": "510009B82CC18",
      "type": "string"
    },
    {
      "key": "trx_id_expired",
      "value": "510009B82CC19",
      "type": "string"
    }
  ]
}
