跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.xpaylabs.com/llms.txt

Use this file to discover all available pages before exploring further.

XPayLabs 使用一致的响应信封返回错误,包含与 HTTP 兼容的 code 字段和人类可读的 msg 字段。

错误响应格式

{
  "code": 400,
  "msg": "The amount cannot be left blank.",
  "data": null
}
字段类型描述
codeinteger与 HTTP 兼容的状态码
msgstring人类可读的错误描述
datanull错误响应中始终为 null

HTTP 状态码

含义典型原因
400错误请求缺少或无效的请求参数
401未授权HMAC 签名无效或时间戳已过期
422不可处理业务逻辑错误(例如,地址对该链无效)
429请求过多超出速率限制
500内部服务器错误意外的服务器错误

常见错误码

签名验证错误 (401)

消息原因
"Sign verification failed"HMAC 签名与计算值不匹配
"The sign cannot be left blank."sign 字段缺失
"The timestamp cannot be left blank."timestamp 字段缺失
"The nonce cannot be left blank."nonce 字段缺失

验证错误 (400)

消息原因
"The amount cannot be left blank."金额缺失或为 null
"The symbol cannot be left blank."代币符号缺失或为空
"The chain cannot be left blank."链缺失或无效
"The receiveAddress cannot be left blank."付款地址缺失
"ReceiveAddress error"付款地址对指定链无效
"The orderId cannot be left blank."此商家版本需要 orderId
"The uid cannot be left blank."此商家版本需要 uid
"The uid cannot be zero."uid 不能为字符串 “0”

速率限制错误 (429)

{
  "code": 429,
  "msg": "Too many requests. Please slow down.",
  "data": null
}

错误处理

async function createCollection(payload) {
  const response = await fetch("http://your-gateway:3010/v1/order/createCollection", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(payload),
  });

  const result = await response.json();

  if (result.code !== 200) {
    console.error(`请求失败:${result.msg}`);
    switch (result.code) {
      case 401:
        // 重新计算签名并重试
        break;
      case 400:
        // 修复请求参数
        break;
      case 429:
        // 退避后重试
        break;
    }
    return null;
  }

  return result.data;
}
Last modified on May 31, 2026