API 契約
欄位已分組,原始字段名保留在標籤旁。展開詳細資料或切換原始檔,可核對完整內容。
- 資料性質
kind - teaching-contract-not-openapi
- 版本
version - demo-api-1
- endpoint
endpoint - POST /payments
- request
request - order_id
order_id - non-empty string
- order_id
- responses
responses - 200
200 - order_id
order_id - requested order
- 狀態
status - PAID
- order_id
- 400
400 - error
error - INVALID_REQUEST
- error
- 404
404 - error
error - ORDER_NOT_FOUND
- error
- 409
409 - error
error - ORDER_ALREADY_PAID
- error
- 200
- persistence
persistence - orders
orders - id TEXT PRIMARY KEY, status TEXT NOT NULL (PENDING or PAID)
- payments
payments - id INTEGER PRIMARY KEY, order_id TEXT NOT NULL
- successful_payment
successful_payment - one payment row and PENDING -> PAID in one atomic transaction
- rejected_payment
rejected_payment - no state or row count changes
- concurrency
concurrency - two simultaneous requests for one PENDING order yield one 200, one 409 and one payment
- orders
- not_in_scope
not_in_scope - real payment provider
- authentication
- pricing
- refunds
- multi-tenant isolation