首页 / 帮助文档 / 开发者文档 / 3. 静态住宅代理

3.2. 报价与锁价

提交要买的商品与数量,返回你账号的实际结算价、当前钱包余额,以及一个 quoteToken。下单时必须把这个 token 原样回传,以保证按你看到的价格成交。

请求

POST /api/iplt/client/residential/quote
Content-Type: application/json
{
  "items": [
    { "productId": "0e070832-acf5-4f49-8996-ebba639c7172", "quantity": 2 }
  ],
  "couponCode": ""
}
字段必选类型说明
items是array明细列表,不能为空,可传多个商品
items[].productId是string商品 ID
items[].quantity是int购买 IP 数量,≥ 1
items[].allocationMode否string传 SEGMENT 表示指定 IP 段,需配合 ipSegment
items[].ipSegment否string期望的 IP 段(仅部分商品支持)
couponCode否string优惠码,无则传空串

响应

{
  "code": 200,
  "msg": "操作成功",
  "data": {
    "total": 3.5,
    "payable": 3.5,
    "originalTotal": 7.0,
    "discount": 3.5,
    "currency": "USD",
    "payBasisPoints": 5000,
    "walletBalance": 1341.00,
    "quoteToken": "2b0c65c54b8333d3588b660137b3f50c...",
    "unitAmounts": [3.5],
    "items": [
      {
        "productId": "0b260c61-3410-4561-b56b-865974a40907",
        "quantity": 1,
        "name": "菲律宾 原生住宅 10Mbps 30天",
        "region": "PH",
        "baseUnitPrice": 7.00,
        "unitPrice": 3.50,
        "merchantBasisPoints": 5000,
        "amount": 3.50,
        "payable": 3.50,
        "days": 30,
        "bandwidth": 10,
        "protocol": "socks5"
      }
    ]
  }
}

关键字段

字段说明
payable最终应付金额(USD),下单实际扣这个数
total / originalTotal折后合计 / 折前合计
discount优惠金额 = originalTotal − total
payBasisPoints本次适用折扣基数,5000 表示五折
walletBalance你当前的钱包余额,用于判断是否够付
quoteToken报价凭证,下单时必须原样回传;短期有效,过期需重新报价
items[].unitPrice单 IP 折后价;amount = unitPrice × quantity
items[].baseUnitPrice单 IP 刊例价,用于核对折扣
为什么要先报价报价时系统会复核商品是否在售、库存是否充足、并锁定价格版本。跳过报价直接下单会失败。
注意quoteToken 有有效期,长时间不用需重新调报价。换商品或改数量也必须重新报价。

示例

curl -s -X POST 'https://www.iplight.net/api/iplt/client/residential/quote' \
  -H 'x-merchant-code: YOUR_CODE' \
  -H 'x-merchant-token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"items":[{"productId":"0e070832-acf5-4f49-8996-ebba639c7172","quantity":2}],"couponCode":""}'
import os, requests
q = requests.post(
    "https://www.iplight.net/api/iplt/client/residential/quote",
    json={"items": [{"productId": "0e070832-acf5-4f49-8996-ebba639c7172", "quantity": 2}],
          "couponCode": ""},
    headers={"x-merchant-code": os.environ["IPLIGHT_CODE"],
             "x-merchant-token": os.environ["IPLIGHT_TOKEN"]},
    timeout=30,
).json()
if q["code"] != 200:
    raise RuntimeError(f'{q["code"]}: {q["msg"]}')

d = q["data"]
print("应付", d["payable"], "余额", d["walletBalance"], "够付", d["walletBalance"] >= d["payable"])
print("quoteToken", d["quoteToken"])
技术支持 support@iplight.net · 返回官网 · 使用教程