Skip to content

錯誤碼與解決方案

錯誤碼參考

所有 API 響應返回 HTTP Code 200,通過 5 位數字的響應碼表達業務結果。

錯誤碼分類

代碼範圍分類描述
00000成功請求成功完成
10xxx參數/校驗錯誤無效參數或校驗失敗
20xxx業務邏輯錯誤業務規則違反或狀態錯誤
30xxx數據狀態錯誤數據一致性或版本衝突
40xxx資源未找到請求的資源不存在
50xxx權限/認證錯誤權限被拒絕或認證失敗
99999系統錯誤內部系統錯誤

完整錯誤碼列表

成功 (00000)

代碼訊息描述
00000Success請求成功完成

參數/校驗錯誤 (10xxx)

代碼訊息描述
10001Invalid argument一個或多個參數無效
10002Missing required parameter缺少必填參數
10003Invalid parameter format參數格式不符合要求
10004Order amount must be greater than 0訂單金額無效
10005Expiration time cannot be earlier than current time過期時間無效
10006Currency not supported不支持指定的幣種
10007Invalid merchant商戶 ID 無效
10008Amount is not within the allowed range金額超出最小/最大限制
10009Amount precision is not within reasonable range小數位數過多
10010Invalid payment method支付方式無效

業務邏輯錯誤 (20xxx)

代碼訊息描述
20001Order already exists商戶訂單號重複
20002Order already paid訂單已支付
20003Order already cancelled訂單已取消
20004Order already closed訂單已關閉
20005Order expired訂單已過期
20006Order not payable訂單當前狀態不可支付
20007Invalid order status for this operation當前訂單狀態不允許此操作
20008Duplicate payment重複支付
20009Payment amount mismatch支付金額不匹配訂單金額
20010Refund amount exceeded退款金額超過已支付金額
20011Insufficient balance帳戶餘額不足
20012Payment timeout支付處理超時
20013Payment channel unavailable支付通道當前不可用
20014Transaction limit exceeded超過單筆交易限額
20015Daily limit exceeded超過每日交易限額
20016Payment method not supported此訂單不支持該支付方式
20017Risk control rejected風控拒絕交易
20018Refund not allowed此訂單不允許退款
20019Order cannot be cancelled當前狀態不允許取消訂單
20020Payment in progress支付正在處理中
20021Merchant not active商戶帳戶未啟用
20022Account frozen帳戶已凍結
20023Account disabled帳戶已停用
20024KYC verification required需要 KYC 驗證
20025Payment method expired支付方式已過期
20026Card declined卡支付被拒絕
20027Network error網絡通信錯誤
20028Settlement failed結算處理失敗
20029Withdrawal not allowed不允許提款
20030Blacklist user用戶已被列入黑名單
20031Address already allocated充值地址已分配
20032Address allocation failed分配充值地址失敗
20033Order query failed查詢訂單失敗
20034Deposit order creation failed創建充值訂單失敗
20035Insufficient paid amount支付金額不足
20036Withdrawal failed, please try again later提款處理失敗
20037Wallet line does not match wallet code錢包配置不匹配
20038Asset query failed查詢資產餘額失敗
20039Asset available not enough可用資產餘額不足
20040Failed to estimate miner fee無法估算區塊鏈礦工費
20041Conversion failed貨幣轉換失敗
20042Duplicate transfer order number轉賬訂單號已存在
20043Wallet code error錢包代碼無效
20044Network configuration error區塊鏈網絡配置錯誤
20045Coin not found未找到加密貨幣
20046Deposit address not found未找到充值地址
20047Exchange rate not found匯率不可用
20048Third party API error外部 API 錯誤
20049Address allocation failed error地址分配系統錯誤
20050Deposit order not found充值訂單不存在
20051Deposit order send record not found未找到充值訂單發送記錄

數據狀態錯誤 (30xxx)

代碼訊息描述
30001Data state inconsistent數據狀態不一致
30002Data version conflict, please retry樂觀鎖衝突,需要重試
30003Data has been modified數據已被其他進程修改

資源未找到錯誤 (40xxx)

代碼訊息描述
40001Order not found訂單不存在
40002Merchant not found商戶不存在
40003Payment record not found支付記錄不存在
40004Refund record not found退款記錄不存在
40005User not found用戶不存在
40006Account not found帳戶不存在
40007Channel not found未找到支付通道
40008Wallet not found未找到錢包
40009Transaction not found未找到交易記錄
40010Address not found未找到地址
40011Checkout session not found結賬會話不存在
40012FX rate not found外匯匯率不可用
40013Invalid currency幣種代碼無效
40014Invalid parameter參數無效

權限/認證錯誤 (50xxx)

代碼訊息描述
50001Unauthorized access需要認證
50002Forbidden禁止訪問
50003Signature verification failed請求簽名無效
50004Invalid API keyAPI 密鑰無效或未找到
50005Token expired認證令牌已過期
50006Invalid token認證令牌無效
50007Access denied拒絕訪問資源
50008Rate limit exceeded請求過多,超過速率限制
50009IP not whitelisted請求 IP 未列入白名單

交易所支付錯誤 (501xx)

代碼訊息描述
50101Failed to connect to exchange API無法連接到交易所服務
50102Failed to create exchange order交易所訂單創建失敗
50103Failed to query exchange order交易所訂單查詢失敗
50104Invalid exchange signature交易所簽名驗證失敗
50105Exchange order not found交易所訂單不存在
50106Exchange order expired交易所訂單已過期
50107Unsupported currency for exchange交易所不支持該幣種
50108Failed to process exchange webhook交易所 Webhook 處理失敗
50109Failed to close exchange order無法關閉交易所訂單
50110Failed to fetch exchange certificate交易所證書獲取失敗

系統錯誤 (99999)

代碼訊息描述
99999System error, please try again later發生內部系統錯誤

常見錯誤排查

錯誤: "Invalid signature" (簽名無效)

可能原因:

  1. JSON 格式不匹配 (格式化 vs 壓縮)
  2. API 密鑰錯誤
  3. 簽名計算不正確
  4. 時間戳不匹配

解決方案:

  1. 驗證 JSON 是壓縮的:

    javascript
    // 檢查 JSON 中是否有換行符或多餘空格
    console.log('包含換行符:', body.includes('\n'));
    console.log('包含多餘空格:', body.includes('  '));
  2. 檢查簽名組成部分:

    javascript
    console.log('簽名字符串:', stringToSign.replace(/\n/g, ' | '));
    console.log('請求體哈希:', bodyHash);
  3. 驗證 API 密鑰:

    • 確保 API 密鑰中沒有多餘的空白字符
    • 檢查您使用的是否是正確的環境 (測試環境 vs 生產環境)

錯誤: "Invalid or expired timestamp." (時間戳無效或已過期)

可能原因:

  1. 時間戳不是毫秒級 (10 位數字而非 13 位)
  2. 服務器時間未同步
  3. 請求耗時過長 (>5 分鐘)

解決方案:

  1. 使用毫秒:

    javascript
    // ✅ 正確 (13位數字)
    const timestamp = Date.now(); // 1737554400000
    
    // ❌ 錯誤 (10位數字)
    const timestamp = Math.floor(Date.now() / 1000); // 1737554400
  2. 同步服務器時間:

    bash
    # Linux/macOS
    sudo ntpdate -u pool.ntp.org
    
    # 或啟用 NTP 服務
    sudo systemctl enable chronyd
    sudo systemctl start chronyd

錯誤: "Invalid timestamp format" (時間戳格式無效)

可能原因:

  • 時間戳長度不是 13 位數字

解決方案:

javascript
const timestamp = Date.now().toString();
console.log('時間戳長度:', timestamp.length); // 應該是 13

相關文檔

Released under the MIT License.