{
  "openapi": "3.1.0",
  "info": {
    "title": "TH3 ONLINE PromptPay Payment Gateway API",
    "version": "1.0.0",
    "description": "Non-custodial multi-tenant PromptPay QR payment gateway REST API (`/api/v1/`) with Bearer token authentication, Idempotency-Key support, and `X-Correlation-Id` tracing. Legacy drop-in `/apipp.php` is also mounted on `https://api.th3online.com`."
  },
  "servers": [
    { "url": "https://api.th3online.com", "description": "Production API Gateway" },
    { "url": "https://th3online.com", "description": "Primary Portal Domain" }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer" },
      "webhookSecret": { "type": "apiKey", "in": "header", "name": "X-Webhook-Secret" },
      "syncKey": { "type": "apiKey", "in": "header", "name": "X-Sync-Key" }
    }
  },
  "paths": {
    "/api/v1/health": {
      "get": { "summary": "Read-only Gateway Health Check", "responses": { "200": { "description": "Healthy" } } }
    },
    "/api/v1/connections": {
      "get": { "summary": "List Merchant Gateway Connections", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "OK" } } }
    },
    "/api/v1/orders": {
      "get": { "summary": "List Merchant Payment Orders", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "OK" } } },
      "post": {
        "summary": "Create Payment Order (unique .01-.99 satang match amount)",
        "security": [{ "bearerAuth": [] }],
        "parameters": [{ "name": "Idempotency-Key", "in": "header", "required": false, "schema": { "type": "string", "maxLength": 128 } }],
        "responses": { "201": { "description": "Order Created" }, "409": { "description": "Satang slots exhausted or idempotency conflict" } }
      }
    },
    "/api/v1/orders/{idOrUlid}": {
      "get": { "summary": "Get Payment Order Detail & PromptPay QR Card", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "OK" } } }
    },
    "/api/v1/orders/{idOrUlid}/confirm": {
      "post": { "summary": "Atomically confirm Payment Order against unclaimed Incoming Transfer", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "Order Paid" }, "404": { "description": "No matching transfer yet" } } }
    },
    "/api/v1/orders/{idOrUlid}/cancel": {
      "post": { "summary": "Cancel a pending Payment Order", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "Cancelled" } } }
    },
    "/api/v1/feeds/webhook/transfers": {
      "post": { "summary": "Push Verification Feed transfer ingestion", "security": [{ "webhookSecret": [] }], "responses": { "200": { "description": "Accepted" } } }
    },
    "/api/v1/feeds/line-connect": {
      "post": { "summary": "LINE Connect heartbeat & Thai bank alert ingestion", "security": [{ "syncKey": [] }], "responses": { "200": { "description": "OK" } } }
    }
  }
}
