---
title: "Create Checkout"
method: POST
path: "/payment/create-checkout"
---

# Create Checkout

`POST /payment/create-checkout`

## Request

- Base URL: `https://api.twtapi.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.twtapi.com/payment/create-checkout`
- Auth: none declared

为已存在的 pending 订单创建渠道收银台会话，返回 checkout_url。

校验顺序：订单存在 → 属于当前用户 → 未过期 → 仍为 pending →
免费 API 单拦截 → 订阅单只允许刷卡 → 支付方式可用。
任何一步不过都直接返回业务错误码，不会改动订单。

渠道下单失败时会把订单置为 cancelled 并打上失败原因标记，
避免订单一直悬在 pending 占位；成功后只写回 provider_session_id。

## Request body

- CreateCheckoutRequest: 为已存在的 pending 订单发起支付（生成渠道支付页/会话）。 source / page_slug / entry_path 是前端埋点：记录用户从哪个入口下单， 带长度上限是为了防止有人塞超长字符串撑爆日志与统计表。
  - `order_no` string, required
  - `payment_method` string
  - `lang` string
  - `source` string, nullable
  - `page_slug` string, nullable
  - `entry_path` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/twtapi/apis/twtapi-backend.md) · [All operations](https://skmtc.dev/twtapi/apis/twtapi-backend/llms.txt) · [OpenAPI document](https://skmtc.dev/twtapi/apis/twtapi-backend/revisions/5295976febaf?raw)
