{
  "openapi": "3.1.0",
  "info": {
    "title": "XXYZ 租户接入 API",
    "version": "1.0.0",
    "description": "使用租户 HMAC-SHA256 请求签名创建会员、获取会员详情和游戏登录链接。API 服务地址由接入方配置。"
  },
  "servers": [
    {
      "url": "http://10.10.200.16:20255",
      "description": "16 服务器内网租户 API"
    }
  ],
  "tags": [
    {
      "name": "会员相关",
      "description": "在已认证租户范围内创建会员、查询会员详情和获取游戏登录链接。"
    },
    {
      "name": "支付相关",
      "description": "XXYZ 向渠道方提交游戏商品扣款申请。"
    }
  ],
  "paths": {
    "/v1/member/login-link": {
      "post": {
        "operationId": "createMemberLoginLink",
        "summary": "获取会员游戏登录链接",
        "description": "通过 appId、timestamp、nonce 和 sign 请求头认证，正文仅含 customId。app_secret 作为 HMAC-SHA256 密钥。会员不存在返回业务码 1004。 如需创建会员，请调用 /v1/member/create。完整错误码见 /errors。",
        "tags": [
          "会员相关"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginLinkRequest"
              },
              "example": {
                "customId": "user_10001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "业务响应。code 为 0 表示成功，非 0 表示失败。",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "请求标识"
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "业务码为 1005 时返回的重试等待秒数。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/SuccessResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "成功响应",
                    "value": {
                      "code": 0,
                      "message": "成功",
                      "data": {
                        "loginUrl": "<服务端返回的游戏登录链接>",
                        "expiresIn": 3600
                      },
                      "requestId": "c651eab4c8ad4f8aa18994f108e89460c",
                      "timestamp": 1794283200000
                    }
                  },
                  "memberNotFound": {
                    "summary": "会员不存在",
                    "value": {
                      "code": 1004,
                      "message": "该租户下的会员不存在，请先创建会员",
                      "data": null,
                      "requestId": "7daf3bd35c3248c690280fd3e8c2d9b07",
                      "timestamp": 1794283200000
                    }
                  }
                }
              }
            }
          }
        },
        "x-request-signature": {
          "algorithm": "HMAC-SHA256",
          "encoding": "lowercase hex",
          "canonicalInput": "POST\n/v1/member/login-link\nappId={appId}\ncustomId={customId}\ntimestamp={timestamp}\nnonce={nonce}",
          "maxClockSkewSeconds": 300,
          "documentation": "/signing",
          "key": "app_secret 的 UTF-8 字节",
          "signatureHeader": "sign",
          "headerFields": [
            "appId",
            "timestamp",
            "nonce"
          ],
          "bodyFields": [
            "customId"
          ],
          "canonicalRules": "LF 分隔，末尾无换行；customId 使用 JSON 解码后的原值。"
        },
        "parameters": [
          {
            "name": "appId",
            "in": "header",
            "required": true,
            "description": "非 0 开头的 10 位数字。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{9}$"
            },
            "example": "1234567890"
          },
          {
            "name": "timestamp",
            "in": "header",
            "required": true,
            "description": "十进制 Unix 毫秒时间戳，允许时钟偏差 5 分钟。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,18}$"
            },
            "example": "1794283200000"
          },
          {
            "name": "nonce",
            "in": "header",
            "required": true,
            "description": "16 字节安全随机值编码成 32 位小写十六进制。每次调用生成新值。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            },
            "example": "00112233445566778899aabbccddeeff"
          },
          {
            "name": "sign",
            "in": "header",
            "required": true,
            "description": "HMAC-SHA256 签名，64 位小写十六进制。 使用 app_secret 作为 HMAC 密钥。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "example": "aea2f3ca5c77c81871a8665d4b3bf130d5e1702dabf8941c2accc6a592bb3bca"
          }
        ]
      }
    },
    "/v1/member/create": {
      "post": {
        "operationId": "createMember",
        "summary": "创建会员",
        "description": "在当前 appId 对应租户下创建会员资料；首次登录游戏时初始化游戏钱包。同租户 customId 重复（包括已删除会员）返回业务码 1013，不会覆盖资料。网络结果不确定时可调用 /v1/member/detail 核实。完整错误码见 /errors。",
        "tags": [
          "会员相关"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberCreateRequest"
              },
              "example": {
                "customId": "user_10001",
                "nickname": "小小猎手"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "业务响应。code 为 0 表示成功，非 0 表示失败。",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "请求标识"
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "业务码为 1005 时返回的重试等待秒数。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MemberSuccessResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "成功响应",
                    "value": {
                      "code": 0,
                      "message": "成功",
                      "data": {
                        "customId": "user_10001",
                        "nickname": "小小猎手",
                        "stamina": null,
                        "gold": null,
                        "diamonds": null,
                        "createTime": 1794283200000,
                        "updateTime": 1794283200000
                      },
                      "requestId": "c651eab4c8ad4f8aa18994f108e89460c",
                      "timestamp": 1794283200000
                    }
                  },
                  "duplicateCustomId": {
                    "summary": "自定义 ID 已存在",
                    "value": {
                      "code": 1013,
                      "message": "该租户下的自定义 ID 已存在",
                      "data": null,
                      "requestId": "c651eab4c8ad4f8aa18994f108e89460c",
                      "timestamp": 1794283200000
                    }
                  }
                }
              }
            }
          }
        },
        "x-request-signature": {
          "algorithm": "HMAC-SHA256",
          "encoding": "lowercase hex",
          "canonicalInput": "POST\n/v1/member/create\nappId={appId}\ncustomId={customId}\nnickname={nickname}\ntimestamp={timestamp}\nnonce={nonce}",
          "maxClockSkewSeconds": 300,
          "documentation": "/signing",
          "key": "app_secret 的 UTF-8 字节",
          "signatureHeader": "sign",
          "headerFields": [
            "appId",
            "timestamp",
            "nonce"
          ],
          "bodyFields": [
            "customId",
            "nickname"
          ],
          "canonicalRules": "LF 分隔，末尾无换行；customId、nickname 使用 JSON 解码后的原值。省略或空 nickname 都保留 nickname= 行，服务端默认昵称“玩家”不参与签名。"
        },
        "parameters": [
          {
            "name": "appId",
            "in": "header",
            "required": true,
            "description": "非 0 开头的 10 位数字。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{9}$"
            },
            "example": "1234567890"
          },
          {
            "name": "timestamp",
            "in": "header",
            "required": true,
            "description": "十进制 Unix 毫秒时间戳，允许时钟偏差 5 分钟。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,18}$"
            },
            "example": "1794283200000"
          },
          {
            "name": "nonce",
            "in": "header",
            "required": true,
            "description": "16 字节安全随机值编码成 32 位小写十六进制。每次调用生成新值。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            },
            "example": "00112233445566778899aabbccddeeff"
          },
          {
            "name": "sign",
            "in": "header",
            "required": true,
            "description": "HMAC-SHA256 签名，64 位小写十六进制。 使用 app_secret 作为 HMAC 密钥。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "example": "5d974944f1a722822cbf28f23edd7ded122ca0ab16bfd87a202982ae8283df74"
          }
        ]
      }
    },
    "/v1/member/detail": {
      "post": {
        "operationId": "getMemberDetail",
        "summary": "获取会员详情",
        "description": "按 customId 查询当前 appId 对应租户下未删除的会员。不存在返回业务码 1004。蜡烛、钞票和魂石为最近已保存的游戏钱包数据，不预测蜡烛恢复。完整错误码见 /errors。",
        "tags": [
          "会员相关"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberDetailRequest"
              },
              "example": {
                "customId": "user_10001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "业务响应。code 为 0 表示成功，非 0 表示失败。",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "请求标识"
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Retry-After": {
                "description": "业务码为 1005 时返回的重试等待秒数。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MemberSuccessResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "成功响应",
                    "value": {
                      "code": 0,
                      "message": "成功",
                      "data": {
                        "customId": "user_10001",
                        "nickname": "小小猎手",
                        "stamina": 80,
                        "gold": "9007199254740993",
                        "diamonds": "50",
                        "createTime": 1794283200000,
                        "updateTime": 1794283200000
                      },
                      "requestId": "c651eab4c8ad4f8aa18994f108e89460c",
                      "timestamp": 1794283200000
                    }
                  },
                  "memberNotFound": {
                    "summary": "会员不存在",
                    "value": {
                      "code": 1004,
                      "message": "该租户下的会员不存在，请先创建会员",
                      "data": null,
                      "requestId": "7daf3bd35c3248c690280fd3e8c2d9b07",
                      "timestamp": 1794283200000
                    }
                  }
                }
              }
            }
          }
        },
        "x-request-signature": {
          "algorithm": "HMAC-SHA256",
          "encoding": "lowercase hex",
          "canonicalInput": "POST\n/v1/member/detail\nappId={appId}\ncustomId={customId}\ntimestamp={timestamp}\nnonce={nonce}",
          "maxClockSkewSeconds": 300,
          "documentation": "/signing",
          "key": "app_secret 的 UTF-8 字节",
          "signatureHeader": "sign",
          "headerFields": [
            "appId",
            "timestamp",
            "nonce"
          ],
          "bodyFields": [
            "customId"
          ],
          "canonicalRules": "LF 分隔，末尾无换行；customId 使用 JSON 解码后的原值。"
        },
        "parameters": [
          {
            "name": "appId",
            "in": "header",
            "required": true,
            "description": "非 0 开头的 10 位数字。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{9}$"
            },
            "example": "1234567890"
          },
          {
            "name": "timestamp",
            "in": "header",
            "required": true,
            "description": "十进制 Unix 毫秒时间戳，允许时钟偏差 5 分钟。",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,18}$"
            },
            "example": "1794283200000"
          },
          {
            "name": "nonce",
            "in": "header",
            "required": true,
            "description": "16 字节安全随机值编码成 32 位小写十六进制。每次调用生成新值。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            },
            "example": "00112233445566778899aabbccddeeff"
          },
          {
            "name": "sign",
            "in": "header",
            "required": true,
            "description": "HMAC-SHA256 签名，64 位小写十六进制。 使用 app_secret 作为 HMAC 密钥。",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "example": "a43379f78660a768897ad80f4fd35f15b6c1ca95e3d5d060c8381adb7c70e92a"
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "LoginLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "customId"
        ],
        "properties": {
          "customId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "该租户下会员的自定义 ID。精确匹配、区分大小写；首尾不能有空白，不能包含控制字符。按 Unicode 字符计数。"
          }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message",
          "data",
          "requestId",
          "timestamp"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "description": "0 为成功；非 0 为业务错误。",
            "const": 0
          },
          "message": {
            "type": "string",
            "description": "供开发者阅读的说明，程序应以 code 判断结果。"
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "loginUrl",
              "expiresIn"
            ],
            "properties": {
              "loginUrl": {
                "type": "string",
                "format": "uri",
                "description": "可直接打开的完整游戏登录链接，属于敏感凭证。每次请求返回的域名可能不同，请直接使用完整 loginUrl，不要自行替换域名、端口或 token。"
              },
              "expiresIn": {
                "type": "integer",
                "const": 3600,
                "description": "签发时的无操作有效期，单位秒。游戏鉴权请求成功后续期 3600 秒。"
              }
            }
          },
          "requestId": {
            "type": "string",
            "description": "本次请求标识，与响应头 X-Request-ID 一致。"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "服务端生成响应时的 Unix 毫秒时间戳。"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message",
          "data",
          "requestId",
          "timestamp"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "description": "0 为成功；非 0 为业务错误。",
            "enum": [
              1000,
              1001,
              1002,
              1003,
              1004,
              1005,
              1006,
              1007,
              1008,
              1009,
              1010,
              1011,
              1012,
              1013
            ]
          },
          "message": {
            "type": "string",
            "description": "供开发者阅读的说明，程序应以 code 判断结果。"
          },
          "data": {
            "type": "null"
          },
          "requestId": {
            "type": "string",
            "description": "本次请求标识，与响应头 X-Request-ID 一致。"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "服务端生成响应时的 Unix 毫秒时间戳。"
          }
        }
      },
      "MemberDetailRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "customId"
        ],
        "properties": {
          "customId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "该租户下会员的自定义 ID。精确匹配、区分大小写；首尾不能有空白，不能包含控制字符。按 Unicode 字符计数。"
          }
        }
      },
      "MemberCreateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "customId"
        ],
        "properties": {
          "customId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "该租户下会员的自定义 ID。精确匹配、区分大小写；首尾不能有空白，不能包含控制字符。按 Unicode 字符计数。"
          },
          "nickname": {
            "type": "string",
            "maxLength": 64,
            "description": "可省略或传空字符串，此时保存默认昵称“玩家”。非空时为 1 至 64 个 Unicode 字符，首尾不得有空白，不得包含控制字符。签名使用传入原值，省略时使用空字符串。"
          }
        }
      },
      "MemberData": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "customId",
          "nickname",
          "stamina",
          "gold",
          "diamonds",
          "createTime",
          "updateTime"
        ],
        "properties": {
          "customId": {
            "type": "string",
            "description": "当前租户下的会员自定义 ID。"
          },
          "nickname": {
            "type": "string",
            "description": "会员昵称；创建时省略或为空则保存“玩家”。"
          },
          "stamina": {
            "type": [
              "integer",
              "null"
            ],
            "description": "最近已保存的蜡烛值；没有游戏钱包存档时为 null，不预测蜡烛恢复。"
          },
          "gold": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]+$",
            "description": "最近已保存的钞票值，精确十进制字符串；没有游戏钱包存档时为 null。不要转换为浮点数。",
            "examples": [
              "9007199254740993",
              null
            ]
          },
          "diamonds": {
            "type": [
              "string",
              "null"
            ],
            "description": "最近已保存的魂石值；没有游戏钱包存档时为 null。",
            "pattern": "^[0-9]+$"
          },
          "createTime": {
            "type": "integer",
            "format": "int64",
            "description": "会员创建时间，Unix 毫秒时间戳。"
          },
          "updateTime": {
            "type": "integer",
            "format": "int64",
            "description": "会员资料更新时间，Unix 毫秒时间戳。"
          }
        }
      },
      "MemberSuccessResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message",
          "data",
          "requestId",
          "timestamp"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "description": "0 为成功；非 0 为业务错误。",
            "const": 0
          },
          "message": {
            "type": "string",
            "description": "供开发者阅读的说明，程序应以 code 判断结果。"
          },
          "data": {
            "$ref": "#/components/schemas/MemberData"
          },
          "requestId": {
            "type": "string",
            "description": "本次请求标识，与响应头 X-Request-ID 一致。"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "服务端生成响应时的 Unix 毫秒时间戳。"
          }
        }
      },
      "ChargeRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "orderId",
          "customId",
          "productId",
          "amountFen",
          "expiresAt"
        ],
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid",
            "description": "平台订单号。渠道以 appId 与 orderId 作为扣款幂等键。"
          },
          "customId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "该租户下的会员自定义 ID。"
          },
          "productId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "所购商品标识。"
          },
          "amountFen": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000000,
            "description": "扣款金额，单位分。"
          },
          "expiresAt": {
            "type": "integer",
            "format": "int64",
            "description": "首次扣款截止时间，Unix 毫秒。已处理订单重放原结果。"
          }
        }
      },
      "ChargeSuccess": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message",
          "data",
          "requestId",
          "timestamp"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "const": 0
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "orderId"
            ],
            "properties": {
              "orderId": {
                "type": "string",
                "format": "uuid",
                "description": "平台订单号。渠道以 appId 与 orderId 作为扣款幂等键。"
              }
            }
          },
          "requestId": {
            "type": "string",
            "description": "渠道方生成的请求标识。"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "服务端生成响应时的 Unix 毫秒时间戳。"
          }
        }
      },
      "ChargeError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message",
          "data",
          "requestId",
          "timestamp"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              1006,
              1014,
              1015
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "null"
          },
          "requestId": {
            "type": "string",
            "description": "渠道方生成的请求标识。"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "服务端生成响应时的 Unix 毫秒时间戳。"
          }
        }
      }
    }
  },
  "x-error-codes": [
    {
      "code": 0,
      "message": "成功",
      "resolution": "读取 data 中的业务数据"
    },
    {
      "code": 1000,
      "message": "参数错误",
      "resolution": "检查必填请求头与正文的字段格式"
    },
    {
      "code": 1001,
      "message": "APPID 或签名无效",
      "resolution": "检查 APPID、密钥和签名原文"
    },
    {
      "code": 1002,
      "message": "租户已停用",
      "resolution": "确认租户状态"
    },
    {
      "code": 1003,
      "message": "租户已到期",
      "resolution": "确认租户有效期"
    },
    {
      "code": 1004,
      "message": "会员不存在",
      "resolution": "确认该租户下存在未删除的会员；未创建时可调用创建会员接口。"
    },
    {
      "code": 1005,
      "message": "请求过于频繁",
      "resolution": "按 Retry-After 指定的秒数重试"
    },
    {
      "code": 1006,
      "message": "服务暂不可用",
      "resolution": "稍后重试，保留 requestId"
    },
    {
      "code": 1007,
      "message": "接口不存在",
      "resolution": "检查 API 路径"
    },
    {
      "code": 1008,
      "message": "请求方法不支持",
      "resolution": "使用 POST"
    },
    {
      "code": 1009,
      "message": "内容类型不支持",
      "resolution": "使用 application/json"
    },
    {
      "code": 1010,
      "message": "请求体过大",
      "resolution": "请求体不得超过 16 KiB"
    },
    {
      "code": 1011,
      "message": "请求时间超出签名有效窗口",
      "resolution": "同步系统时钟，使用当前毫秒时间戳重新签名"
    },
    {
      "code": 1012,
      "message": "请求 nonce 已使用",
      "resolution": "生成新的 nonce 并重新签名"
    },
    {
      "code": 1013,
      "message": "该租户下的自定义 ID 已存在",
      "resolution": "不会覆盖已有资料；已删除会员仍占用该 ID。创建结果不确定时可获取会员详情核实。"
    },
    {
      "code": 1014,
      "message": "余额不足，购买失败",
      "resolution": "渠道确认余额不足且未扣款。"
    },
    {
      "code": 1015,
      "message": "购买失败，请联系渠道商",
      "resolution": "渠道确认拒绝且未扣款。"
    }
  ],
  "x-error-documentation": "/errors",
  "webhooks": {
    "chargeRequest": {
      "post": {
        "operationId": "receiveChargeRequest",
        "summary": "扣款申请",
        "tags": [
          "支付相关"
        ],
        "description": "平台向租户配置的完整扣款地址发送 POST 请求，保留路径和查询参数。请求签名使用 app_secret 作为 HMAC-SHA256 密钥，原文包含实际路径及查询字符串和请求体 SHA-256。HTTP 响应须签名。以 appId 和 orderId 幂等扣款，重复订单返回原结果。超过 expiresAt 后禁止首次扣款。详见 /payment-charge。",
        "parameters": [
          {
            "name": "appId",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{9}$"
            }
          },
          {
            "name": "timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{12}$"
            }
          },
          {
            "name": "nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          },
          {
            "name": "sign",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChargeRequest"
              },
              "example": {
                "orderId": "6628d6b4-6cde-4c69-bde7-e0bd0f19d367",
                "customId": "user_10001",
                "productId": "1001",
                "amountFen": 600,
                "expiresAt": 1794284100000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "扣款结果",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ChargeSuccess"
                    },
                    {
                      "$ref": "#/components/schemas/ChargeError"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "code": 0,
                      "message": "成功",
                      "data": {
                        "orderId": "6628d6b4-6cde-4c69-bde7-e0bd0f19d367"
                      },
                      "requestId": "channel_req_001",
                      "timestamp": 1794283200050
                    }
                  },
                  "error1014": {
                    "value": {
                      "code": 1014,
                      "message": "余额不足，购买失败",
                      "data": null,
                      "requestId": "channel_req_002",
                      "timestamp": 1794283200050
                    }
                  },
                  "error1015": {
                    "value": {
                      "code": 1015,
                      "message": "购买失败，请联系渠道商",
                      "data": null,
                      "requestId": "channel_req_002",
                      "timestamp": 1794283200050
                    }
                  }
                }
              }
            },
            "headers": {
              "sign": {
                "description": "使用 HTTP 时必填，HTTPS 时可选。以 app_secret 为密钥，对方法、路径及查询字符串、appId、orderId、响应体 SHA-256、原请求 timestamp 及 nonce 生成 HMAC-SHA256。签名原文见 /payment-charge#response-signing。",
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            }
          }
        }
      }
    }
  }
}
