POST/v1/transfers/pricing

接送服务定价

确认所选报价的最终价格,并获取预订所需的令牌。

分享
POST/v1/transfers/pricing

API 控制台

试一试

向沙箱 API 发送真实请求并查看响应。

凭证

登录后即可从已保存的 API 密钥中选择,无需手动粘贴。

请求体

cURL 请求

cURL
bash
curl -X POST 'https://api.sandbox.travelandz.com/v1/transfers/pricing' \
  -H 'Authorization: Bearer YOUR_SECRET_KEY' \
  -H 'X-Travelandz-Id: YOUR_PUBLIC_KEY:YOUR_PROFILE_CODE' \
  -H 'Content-Type: application/json' \
  -d '{"gdsprovider":0,"bookingToken":"opaque_offer_token_generated_by_travelandz","searchId":"73a5670b476649a985f0535db1077c05","resultId":"fe94b51ccd0623a9f1adabfbe0614d34","selectedAmenities":["baby_seats","child_booster"],"currency":"USD"}'

请填写凭证以发送请求。

此请求需要来自上一次调用的标识符或令牌。请先运行前一个步骤,然后把它的值粘贴到这里。

响应

点击「试一试!」发送请求,响应将显示在此处。

确认所选报价的最终价格,并获取预订所需的令牌。

认证和请求头

请求头说明
AuthorizationBearer <secret_key>。密钥只能保存在服务器端,不能写入客户端日志。
X-Travelandz-Id<public_key>:<profile_code>,持久化的 profile code 格式为 dp_<12 位字母数字>
LANG推荐的语言请求头,也支持 Accept-Language
Content-Type带 JSON body 的请求使用 application/json

请求

发送 gdsprovider、所选报价的 bookingToken,以及与之匹配的 searchIdresultId。在 selectedAmenities 中加入旅客选择的设施 key。若发送 currency,必须与搜索的货币一致;省略则继承。

请求体结构

gdsprovider
enum
0
Transfer content selector. Currently 0.
bookingToken
string
Copy the bookingToken of the selected offer.
searchId
string
Must be the searchId of the selected offer.
resultId
string
Must be the resultId of the selected offer.
selectedAmenities
array
selectedAmenities[]
string[]
When sent, needs at least one unique, non-empty key available in the offer.
currency
enum
EURUSDINRCHFJPYGBPAUDCADCNYSGDNZDMXN
Lowercase values are accepted and normalized. Defaults to USD on a new search and is inherited afterwards.
language
enum
en-USes-ESde-DEfr-FRpt-BRzh-CNit-IT
Legacy field. Prefer the LANG or Accept-Language header.

请求示例

不含设施

json
json
{
  "gdsprovider": 0,
  "bookingToken": "opaque_offer_token_generated_by_travelandz",
  "searchId": "73a5670b476649a985f0535db1077c05",
  "resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
  "currency": "USD"
}

含设施

json
json
{
  "gdsprovider": 0,
  "bookingToken": "opaque_offer_token_generated_by_travelandz",
  "searchId": "73a5670b476649a985f0535db1077c05",
  "resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
  "selectedAmenities": [
    "baby_seats",
    "child_booster"
  ],
  "currency": "USD"
}

成功响应

返回 finalPrice、标准化的设施选择,以及不透明的 pricingToken

finalPrice.amount 就是应向旅客收取的金额。切勿根据搜索响应或设施数据自行重新计算价格。

响应体结构

finalPrice
object
finalPriceamount
number
Amount to charge, rounded to two decimals.
finalPricecurrency
enum
EURUSDINRCHFJPYGBPAUDCADCNYSGDNZDMXN
selectedAmenities
array
selectedAmenities[]key
string
Value to send in selectedAmenities.
selectedAmenities[]name
string
Localized name.
selectedAmenities[]description
string
selectedAmenities[]imageUrl
string
格式: URL
selectedAmenities[]pngImageUrl
string
格式: URL
selectedAmenities[]inputType
enum
booleannumeric
selectedAmenities[]included
boolean
True when the amenity is already part of the offer.
selectedAmenities[]selectable
boolean
True when the amenity can be added to this offer.
selectedAmenities[]selected
boolean
True when the amenity is part of the priced selection.
pricingToken
string
Opaque value. Send it to booking or to a reservation change; never decode or modify it.

响应示例

json
json
{
  "finalPrice": {
    "amount": 181.97,
    "currency": "USD"
  },
  "selectedAmenities": [
    {
      "key": "baby_seats",
      "name": "Baby seats",
      "description": "Your vehicle will have a child safety seat to keep children under age 4 safe.",
      "imageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/baby-seats.svg",
      "pngImageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/baby-seats.png",
      "inputType": "numeric",
      "included": false,
      "selected": true,
      "selectable": true
    },
    {
      "key": "child_booster",
      "name": "Child booster",
      "description": "Your vehicle will have a child booster seat to keep children from age 4-8 safe.",
      "imageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/child-booster.svg",
      "pngImageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/child-booster.png",
      "inputType": "numeric",
      "included": false,
      "selected": true,
      "selectable": true
    }
  ],
  "pricingToken": "opaque_public_pricing_token_generated_by_travelandz"
}

错误

HTTP代码含义建议操作
400请求体、查询参数或路径无效,或包含未知属性。根据 message 数组修正请求。
400transfer_invalid_currency该货币不在支持列表中。使用受支持的货币。
400transfer_invalid_language请求的语言不受支持。使用文档中列出的语言值之一。
429transfer_provider_error服务暂时被限流。使用指数退避重试。
502transfer_provider_error请求无法完成。不要假定成功。保留标识符,并在该操作可能已创建时查询预订。
400transfer_invalid_booking_tokenbooking token 已过期、被修改,或不属于该报价。重新搜索,并使用新选报价的令牌。
400transfer_invalid_amenitiesamenity key 重复、为空,或该报价不提供。发送取自报价或设施目录的唯一 key。
400transfer_currency_mismatch货币与报价、报价单或预订不一致。复用上一步返回的货币,或省略该字段以继承它。
503当前无法确认价格。稍后重试。不要预订,也不要向旅客收费。

使用说明

每次预订以及确认每次预订变更之前都必须先定价,即使没有选择任何设施。

pricingToken 是不透明的,且仅属于其创建时对应的报价。请原样复制到下一次调用,不要解码或修改;若报价过期,请重新定价。

cURL 示例

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/transfers/pricing" \
  -H "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  -H "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  -H "Content-Type: application/json" \
  --data '{
  "gdsprovider": 0,
  "bookingToken": "opaque_offer_token_generated_by_travelandz",
  "searchId": "73a5670b476649a985f0535db1077c05",
  "resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
  "selectedAmenities": [
    "baby_seats",
    "child_booster"
  ],
  "currency": "USD"
}'