GET · /api/v1/wallet/callback/attempts

查询回调 Attempt 历史

查询某个回调任务的每次投递记录,包含请求头摘要、请求/响应 body 摘要、延迟、是否成功等详情。用于排查回调失败原因。

GET/api/v1/wallet/callback/attempts HMAC

先用 /tasks 接口拿 callbackTaskId

本接口需要 callbackTaskId,请先调 GET /api/v1/wallet/callback/tasks 查询任务列表获取 id,或在管理后台找到对应任务的 id。

Header 参数

X-Api-Key
string required
应用 apiKey。沙箱前缀 pk_test_,正式 pk_live_
例: pk_test_4f9d8ab1c0e74...
X-Timestamp
integer (UNIX 毫秒) required
请求发起时刻的 UNIX 毫秒时间戳(13 位整数)。与服务端时差不能超过 ±300000ms(5 分钟)。
例: 1746450000000
X-Nonce
string required
本次请求的随机串,建议 UUID v4 或 16 字节 hex。同一 (apiKey, nonce) 在 10 分钟窗口内不可重复。
例: 8e3a1c2f7b6d4a90
X-Signature
string required
HMAC-SHA256 签名(小写 hex,64 字符)。算法:HMAC(secret, METHOD + "\n" + PATH + "\n" + ts + "\n" + nonce + "\n" + SHA256(body))。详见 鉴权章节
例: 6e4a8c1f...(64 字符)

Query 参数

callbackTaskId
integer required
回调任务 id,从 GET /api/v1/wallet/callback/tasks 获取。必须属于当前 X-Api-Key 对应应用。
例: 5001

请求示例

# 签名算法(4 个 header)见 /docs/api/auth;GET body=''
API_KEY=pk_live_xxx
SECRET=sk_live_xxx
METHOD=GET
REQ_PATH=/api/v1/wallet/callback/attempts
BODY=''
TS=$(( $(date +%s) * 1000 ))
NONCE=$(uuidgen | tr -d '-' | tr '[:upper:]' '[:lower:]')
BODY_SHA=$(printf "" | openssl dgst -sha256 -hex | awk '{print $2}')
SIG=$(printf "%s\n%s\n%s\n%s\n%s" "$METHOD" "$REQ_PATH" "$TS" "$NONCE" "$BODY_SHA" \
  | openssl dgst -sha256 -hmac "$SECRET" -hex | awk '{print $2}')

curl "https://api.pqpa.com$REQ_PATH?callbackTaskId=5001" \
  -H "X-Api-Key:   $API_KEY" \
  -H "X-Timestamp: $TS" \
  -H "X-Nonce:     $NONCE" \
  -H "X-Signature: $SIG"

响应

Response
200OK
{
  "code": 0,
  "data": [
    {
      "id": 10001,
      "callbackTaskId": 5001,
      "attemptNo": 1,
      "requestHeadersSummary": {
        "Content-Type": "application/json; charset=utf-8",
        "X-Api-Key": "pk_li****ve_xxx",
        "X-Timestamp": "1746455000000",
        "X-Nonce": "a1b2c3d4e5f6",
        "X-Signature": "abcd12****ef56",
        ":method": "POST",
        ":url": "https://your-app.com/callback/recharge"
      },
      "requestBodySummary": "{\"event\":\"recharge\",\"id\":9001,...}",
      "requestBodyLength": 180,
      "requestBodySha256": "e3b0c44298fc1c149afbf4c8996fb924...",
      "responseStatus": null,
      "responseContentType": null,
      "responseBodySummary": null,
      "responseBodyLength": null,
      "responseBodySha256": null,
      "accepted": false,
      "latencyMs": 10001,
      "errorReason": "connect timeout",
      "nextRetryTime": "2026-05-05T12:35:00",
      "createTime": "2026-05-05T12:34:56"
    },
    {
      "id": 10002,
      "callbackTaskId": 5001,
      "attemptNo": 2,
      "requestHeadersSummary": {
        "Content-Type": "application/json; charset=utf-8",
        "X-Api-Key": "pk_li****ve_xxx",
        "X-Timestamp": "1746455060000",
        "X-Nonce": "b2c3d4e5f601",
        "X-Signature": "ef1234****5678",
        ":method": "POST",
        ":url": "https://your-app.com/callback/recharge"
      },
      "requestBodySummary": "{\"event\":\"recharge\",\"id\":9001,...}",
      "requestBodyLength": 180,
      "requestBodySha256": "e3b0c44298fc1c149afbf4c8996fb924...",
      "responseStatus": 200,
      "responseContentType": "application/json",
      "responseBodySummary": "{\"code\":0}",
      "responseBodyLength": 10,
      "responseBodySha256": "abc123...",
      "accepted": true,
      "latencyMs": 230,
      "errorReason": null,
      "nextRetryTime": null,
      "createTime": "2026-05-05T12:35:00"
    }
  ],
  "msg": ""
}

data[] 字段说明

id
integer required
attempt 记录 id。
callbackTaskId
integer required
所属回调任务 id。
attemptNo
integer required
本次是第几次投递,从 1 开始(1=首次投递,2 开始为重试)。
requestHeadersSummary
object required
请求头摘要(apiKey / signature 已脱敏)。包含 Content-Type / X-Api-Key / X-Timestamp / X-Nonce / X-Signature 等。
requestBodySummary
string | null required
请求 body 摘要(最多 1000 字符,超出截断并附 "(truncated)")。
requestBodyLength
integer required
请求 body 原始字节长度。
requestBodySha256
string required
请求 body 的 SHA-256 hex,可用于本地还原验证。
responseStatus
integer | null required
商户 endpoint 返回的 HTTP 状态码;网络错误/超时时为 null。
responseContentType
string | null optional
商户 endpoint 返回的 Content-Type。
responseBodySummary
string | null optional
商户响应 body 摘要(最多 1000 字符)。
responseBodyLength
integer | null optional
商户响应 body 字节长度。
responseBodySha256
string | null optional
商户响应 body 的 SHA-256 hex。
accepted
boolean required
本次投递是否被平台判定为 ACK 成功。
latencyMs
integer required
本次 HTTP 请求耗时(毫秒)。
errorReason
string | null optional
失败原因,如 connect timeout / signature rejected 等;成功时为 null。
nextRetryTime
string | null optional
所属任务的下次重试时间(继承自 task,非本 attempt 特有)。
createTime
string required
本次 attempt 的发起时间。

下一步