跳转到主要内容

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.

一个轻量级端点,仅返回订单的当前状态。在需要检查支付是否已确认而无需获取完整订单详情的轮询场景中使用。

请求

GET http://your-gateway:3010/v1/order/getOrderStatus?orderId={orderId}&sign={sign}

查询参数

orderId
string
必填
订单标识符。
sign
string
必填
基于 orderId 值计算的 HMAC-SHA256 签名。

cURL

curl "http://your-gateway:3010/v1/order/getOrderStatus?orderId=order_1042&sign=a1b2c3d4e5f6..."

响应

成功的请求返回 HTTP 200,带 R<PaymentOrderStatus> 信封。

PaymentOrderStatus 对象

status
string
当前订单状态:
  • INIT — 等待支付
  • PENDING — 检测到交易
  • PENDING_CONFIRMATION — 等待区块确认
  • SUCCESS — 支付已确认
  • EXPIRED — 订单已过期
  • FAILED — 支付失败

示例响应

{
  "code": 200,
  "msg": "success",
  "data": {
    "status": "SUCCESS"
  }
}

使用示例

async function waitForPayment(orderId, token) {
  const sign = computeSign(orderId, token);

  for (let i = 0; i < 120; i++) {
    const response = await fetch(
      `http://your-gateway:3010/v1/order/getOrderStatus?orderId=${orderId}&sign=${sign}`
    );
    const result = await response.json();

    if (result.data.status === "SUCCESS") {
      console.log("支付已确认!");
      return true;
    }
    if (result.data.status === "EXPIRED" || result.data.status === "FAILED") {
      console.log("支付失败或已过期");
      return false;
    }

    await new Promise(r => setTimeout(r, 2000));
  }
  return false;
}
Last modified on May 31, 2026