公开接口

POST /core/v1/billing/stripe-test/webhook

原始字节验签、服务端查证与幂等测试入账

Stripe 仍关闭,其接口仅支持测试模式。全局 payment_enabled 不能证明 Stripe 可用。webhook 必须由服务端校验官方签名和未经改写的原始字节,不可由前端伪造。

身份要求

公开接口. 会话/管理写操作不在公共 Playground 执行。

接口

curl --request POST 'https://api.oneaster.ai/core/v1/billing/stripe-test/webhook' \
  --header 'Stripe-Signature: '"$STRIPE_SIGNATURE" \
  --header 'Content-Type: application/json' \
  --data-binary @"$STRIPE_EVENT_FILE"

参数

- Stripe-Signature (header, 必填): {"type":"string","maxLength":4096} Stripe官方签名;不能由前端代填或改写原始body。

请求 JSON Schema

{
  "type": "object",
  "description": "原始Stripe事件JSON;必须保留原始字节并使用Stripe-Signature验签。不是浏览器提交的付款证明。"
}

响应

200

原始字节验签、服务端查证与幂等测试入账

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "reused": {
                  "type": "boolean"
                }
              },
              "required": [
                "reused"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "ignored": {
                  "const": true
                }
              },
              "required": [
                "ignored"
              ]
            }
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

default

错误代码见 core-api.md;供应商/数据库错误已隐藏。

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": false
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "type": {
              "const": "oneaster_error"
            }
          },
          "required": [
            "code",
            "message",
            "type"
          ]
        },
        "data": {
          "type": "null"
        }
      },
      "required": [
        "success",
        "error",
        "data"
      ]
    }
  }
}