简化开放下单幂等参数
This commit is contained in:
@@ -77,7 +77,6 @@ export default function ApiDebugger() {
|
||||
const [pathValues, setPathValues] = useState<Record<string, string>>({})
|
||||
const [queryValues, setQueryValues] = useState<Record<string, string>>({})
|
||||
const [bodyText, setBodyText] = useState('')
|
||||
const [idempotencyKey, setIdempotencyKey] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleAppKeyChange = (val: string) => {
|
||||
@@ -114,7 +113,6 @@ export default function ApiDebugger() {
|
||||
} | null>(null)
|
||||
|
||||
const endpoint = endpoints.find((e) => e.key === selectedKey)
|
||||
const isCreateOrder = selectedKey === 'create-order'
|
||||
|
||||
useEffect(() => {
|
||||
if (endpoint?.requestExample) {
|
||||
@@ -129,7 +127,6 @@ export default function ApiDebugger() {
|
||||
}
|
||||
setPathValues({})
|
||||
setQueryValues({})
|
||||
setIdempotencyKey('')
|
||||
setResponse(null)
|
||||
setSignInfo(null)
|
||||
}, [selectedKey, endpoint])
|
||||
@@ -192,9 +189,6 @@ export default function ApiDebugger() {
|
||||
if (method !== 'GET' && bodyText) {
|
||||
fetchHeaders['Content-Type'] = 'application/json'
|
||||
}
|
||||
if (isCreateOrder && idempotencyKey.trim()) {
|
||||
fetchHeaders['Idempotency-Key'] = idempotencyKey.trim()
|
||||
}
|
||||
|
||||
setLoading(true)
|
||||
const start = performance.now()
|
||||
@@ -363,16 +357,6 @@ export default function ApiDebugger() {
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
{isCreateOrder && (
|
||||
<Form.Item label={<Text code style={{ fontSize: 14 }}>Idempotency-Key</Text>} help="须与 client_order_no 一致">
|
||||
<Input
|
||||
value={idempotencyKey}
|
||||
onChange={(e) => setIdempotencyKey(e.target.value)}
|
||||
style={{ maxWidth: 480 }}
|
||||
placeholder="会从 Request Body 自动取 client_order_no"
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
|
||||
<Alert
|
||||
|
||||
@@ -425,7 +425,7 @@ app_key=ak_xxx&body_sha256=<实际请求 body 字节的 SHA256 十六进制>&met
|
||||
<li>POST 签名用的 <Text code>body</Text> 必须与实际发送的 body <b>字节级一致</b>,不要签名后再改空格或字段顺序。</li>
|
||||
<li>value <b>不要</b> URL encode,原样参与拼接。</li>
|
||||
<li>签名失败常见原因:secret 错、path 多了 query、body 与签名不一致、时间戳过期、nonce 重复、参数未按字典序拼接。</li>
|
||||
<li>下单接口还需携带 <Text code>Idempotency-Key</Text>,且必须与 <Text code>client_order_no</Text> 一致。</li>
|
||||
<li>下单幂等直接使用 <Text code>client_order_no</Text>,无需额外 Header。</li>
|
||||
</ul>
|
||||
}
|
||||
/>
|
||||
@@ -495,7 +495,7 @@ function StatusSection() {
|
||||
description={
|
||||
<pre className="api-docs__pre api-docs__pre--plain">{`拿到 sku(商品列表)
|
||||
↓
|
||||
POST /orders 下单(幂等,Idempotency-Key = client_order_no)
|
||||
POST /orders 下单(client_order_no 幂等)
|
||||
↓
|
||||
拿响应里的 order_no 进入发货平台链接
|
||||
↓
|
||||
|
||||
Reference in New Issue
Block a user