首页 / 帮助文档 / 开发者文档 / 4.2. 报价与下单

报价与下单

下单分两步:先报价拿 quoteToken,再用令牌下单。这个设计保证扣款金额由服务端决定,客户端无法篡改价格。

第 1 步:报价

POST /api/iplt/client/residential/live/quote

认证方式:API Key(x-merchant-code + x-merchant-token)

请求头

参数名必选类型说明
x-merchant-token是String商户令牌(API Key 的 token 部分)
x-merchant-code是String商户代码(API Key 的 code 部分)
Content-Type否String固定 application/json(POST/PUT 必填)

请求参数(Body)

参数名必选类型说明
productId是String商品 ID,来自商品目录
quantity是Integer购买 IP 数量
kind否String商品类型,一般由商品目录回填
lang否String返回语言:zh / en
curl -s -X POST 'https://www.iplight.net/api/iplt/client/residential/live/quote' \
  -H 'Content-Type: application/json' \
  -H 'x-merchant-code: YOUR_CODE' \
  -H 'x-merchant-token: YOUR_TOKEN' \
  -d '{"productId": "L30M-USA-SEATTLE-N", "quantity": 1}'
{
  "msg": "操作成功",
  "code": 200,
  "data": {
    "items": [
      {
        "productId": "L30M-USA-SEATTLE-N",
        "name": "美国 · 西雅图 原生",
        "quantity": 1,
        "unitPrice": 5.5,
        "payable": 5.5,
        "discount": 0,
        "listPrice": 5.5,
        "priceLabel": "标准价",
        "renewOf": null
      }
    ],
    "total": 5.5,
    "originalTotal": 5.5,
    "payable": 5.5,
    "discount": 0,
    "currency": "USD",
    "quoteToken": "<一次性令牌>",
    "expiresAt": "<过期时间>",
    "walletBalance": 128.5,
    "kind": "NATIVE",
    "renewOf": null
  }
}

第 2 步:下单

POST /api/iplt/client/residential/live/purchase

认证方式:API Key(x-merchant-code + x-merchant-token)

请求参数(Body)

参数名必选类型说明
productId是String商品 ID
quantity是Integer购买 IP 数量
quoteToken是String报价接口返回的令牌
requestNo否String幂等键。同值重复提交返回首次结果,不会重复扣款
curl -s -X POST 'https://www.iplight.net/api/iplt/client/residential/live/purchase' \
  -H 'Content-Type: application/json' \
  -H 'x-merchant-code: YOUR_CODE' \
  -H 'x-merchant-token: YOUR_TOKEN' \
  -d '{
    "productId": "L30M-USA-SEATTLE-N",
    "quantity": 1,
    "quoteToken": "<第 1 步返回的令牌>",
    "requestNo": "your-order-ref-20250722-001"
  }'
建议强烈建议每次都传 requestNo。网络超时、用户双击、任务重跑时,它是唯一能防止重复扣款的手段。

已购资源

GET /api/iplt/client/residential/live/resources?effectiveStatus=CURRENT&page=1&pageSize=20

认证方式:API Key(x-merchant-code + x-merchant-token)

参数名必选类型说明
effectiveStatus否String资源状态,默认 CURRENT
page否Integer页码,默认 1
pageSize否Integer每页条数,默认 100,上限 200
lang否String返回语言

返回 { rows, total, page, pageSize, pending, pendingTotal, counts },其中 counts 是各状态的数量汇总,适合做页签计数。

自动续费

POST /api/iplt/client/residential/live/resources/{id}/auto-renew

认证方式:API Key(x-merchant-code + x-merchant-token)

请求参数(Body)

参数名必选类型说明
enabled是Boolean开启 / 关闭自动续费
version否Integer资源版本号,用于乐观锁;不匹配会返回 409
注意开关自动续费会返回 409 表示资源状态已变化(例如刚好到期),此时应重新拉取资源列表再操作。
技术支持 support@iplight.net · 返回官网 · 使用教程