{
  "openapi": "3.0.3",
  "info": {
    "title": "ClawPay API",
    "version": "1.0.0",
    "description": "USDT (BSC BEP-20) 收付平台:邮箱即身份,人与智能体同权接入。开户费 $99,费率 1%,资金链上直收商户地址。"
  },
  "servers": [{ "url": "https://clawpay.click" }],
  "paths": {
    "/api/merchants/register": {
      "post": {
        "summary": "发送开户验证码到邮箱",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email"], "properties": { "email": { "type": "string", "format": "email" } } } } } },
        "responses": { "200": { "description": "验证码已发送" }, "429": { "description": "发送过频" } }
      }
    },
    "/api/merchants/verify": {
      "post": {
        "summary": "校验验证码,签发 API key(仅此一次返回)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email", "code"], "properties": { "email": { "type": "string" }, "code": { "type": "string" } } } } } },
        "responses": { "200": { "description": "返回 apiKey/callbackSecret/status" }, "409": { "description": "邮箱已注册" } }
      }
    },
    "/api/merchants/me": {
      "get": { "summary": "商户资料", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "商户资料" } } }
    },
    "/api/merchants/me/address": {
      "post": {
        "summary": "绑定 BSC 收款地址/回调地址",
        "security": [{ "bearerAuth": [] }],
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "bsc_address": { "type": "string", "pattern": "^0x[0-9a-fA-F]{40}$" }, "callback_url": { "type": "string" } } } } } },
        "responses": { "200": { "description": "ok" } }
      }
    },
    "/api/orders/activation": {
      "post": { "summary": "创建 $99 开户订单(pending 商户可用)", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "订单(含 to_address/expected_amount/cashier_url)" } } }
    },
    "/api/orders": {
      "post": {
        "summary": "创建收款订单(active 商户)",
        "security": [{ "bearerAuth": [] }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["amount_usdt"], "properties": { "amount_usdt": { "type": "number" }, "memo": { "type": "string" }, "callback_url": { "type": "string" } } } } } },
        "responses": { "200": { "description": "订单" }, "403": { "description": "未激活" } }
      },
      "get": { "summary": "订单列表(最近 50)", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "订单数组" } } }
    },
    "/api/orders/{order_no}": {
      "get": { "summary": "订单详情", "security": [{ "bearerAuth": [] }], "parameters": [{ "name": "order_no", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "订单" }, "404": { "description": "不存在" } } }
    },
    "/api/public/orders/{order_no}/status": {
      "get": { "summary": "公开订单状态(无需 key)", "parameters": [{ "name": "order_no", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "状态" } } }
    },
    "/api/billing/summary": {
      "get": { "summary": "费率账单(1% 记账)", "security": [{ "bearerAuth": [] }], "responses": { "200": { "description": "账单汇总与明细" } } }
    },
    "/health": { "get": { "summary": "健康检查", "responses": { "200": { "description": "ok" } } } }
  },
  "components": {
    "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "description": "pay_live_ 开头的 API key" } }
  }
}
