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"])