跳转到内容

与 TripPay 集成

本文包含一个端到端的示例,展示如何与 TripPay 集成。

建议您已经阅读过:

以下是成功使用 TripPay 支付预订的步骤:

  1. 确保您在预订合同中提到的受益人已完成映射。
  2. 让旅客选择他们想预订的库存,并准备付款。
  3. 使用 TripPay 创建包含要预订项目的 应付合同
  4. 让旅客使用 TripPay Web 组件进行支付。

我们假设您已经完成了 步骤 1步骤 2,并准备让 TripPay 知晓预订信息。

以下是一个 JSON 示例请求,包含创建首个应付合同所需的所有内容。

{
"user": {
"userIdentifier": "191d5729-0b90-4000-85df-1bea7a6e9a01",
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]"
},
"affiliateAccountIdentifier": "291d5729-0b91-4001-95df-2bec7a6e9a01",
"affiliateAccountIdentifierType": "INTERNAL",
"displayCurrency": "USD",
"traceId": "trace-1",
"redirectUrl": "/thank-you",
"sourceUrl": "https://www.travel.com",
"contractList": [
{
"identifier": "191d5729-0b90-4000-8298-72431beb1701",
"supplierIdentifier": "191d5729-0b90-4000-8b72-58186a642401",
"supplierIdentifierType": "EXTERNAL",
"contractItemList": [
{
"user": {
"userIdentifier": "191d5729-0b90-4000-8596-ed18f9876801",
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]",
"telephone": "+1 212 555 1212",
},
"nameInEnglish": "Deluxe King",
"descriptionInEnglish": "This is the best deluxe king that money can buy.",
"price": {
"amount": 100,
"currency": "USD"
},
"itinerary": {
"startDate": "2024-12-24T00:00:00.000Z",
"endDate": "2024-12-25T00:00:00.000Z",
"adults": 2
},
"pricingType": "PER_STAY",
"type": "LODGING",
"payable": "PREPAY",
"policy": {
"refundable": true
},
"externalIdentifier": "room-type-1",
"dailyRateList": [
{
"date": "2024-12-24",
"price": {
"amount": 100,
"currency": "USD"
}
}
],
"beneficiaryList": [
{
"identifier": "account-0",
"identifierType": "INTERNAL",
"amountDue": {
"type": "PERCENTAGE",
"percent": 0.015
},
"type": "PLATFORM_FEE"
},
{
"identifier": "account-1",
"identifierType": "INTERNAL",
"amountDue": {
"type": "PERCENTAGE",
"percent": 0.0985
},
"type": "COMMISSION"
},
{
"identifier": "account-2",
"identifierType": "INTERNAL",
"amountDue": {
"type": "PERCENTAGE",
"percent": 0.8865
},
"type": "SALE"
}
]
}
]
}
]
}

说明:

这里不会详细解释每个数据点,因为它们已在 API 文档中涵盖。

  • 行:2 - 7 是负责预订的用户。有两种预订者类型:
    • 旅客。
    • 旅行社。
  • 行:8 - 9 是促成预订的 TripPay 账户。它可以是:
    • 您的 TripPay 集成账户。
    • 如果您运营联盟网络,则可以是您的联盟账户。
  • 使用 traceId 来将多个供应商的多个预订分组。这样您可以取消一组预订。
  • redirectUrl 告诉 TripPay 支付完成后重定向到哪个页面。
  • sourceUrl 是发生预订的网站/应用。

contractList 数组包含旅客想从多个供应商购买的项目。每个项目包含:

  • identifier 是您生成的有效 UUID。
  • 您想从中预订库存的供应商。
  • 您想从该供应商预订的库存。这些都在嵌套数组 contractItemList 中指定。
  • contractItemList 下的每个条目包含:
    • 客人用户 这是将入住场所的用户。
    • 英文名称 库存的英文名称。
    • 英文描述 库存的英文详细描述。
    • 价格 该项目的价格。
    • 行程 该项目应预订的时间。
    • 定价类型 价格的计算方式。
    • 库存类型 该库存的类型。
    • 应付时间 旅客应被收费的时间。我们目前仅支持即时付款选项。
    • 政策 包含取消政策规则。
    • 每日价格列表 如果预订的是房间,您可以选择包含客人每晚住宿的房价。
    • 受益人 包含应分配给哪些 TripPay 账户及其对应金额。支持固定金额/百分比。

当 TripPay 响应您的请求时,格式大致如下:

[
{
"id": "contract-1",
"traceId": "trace-1",
"supplierContractIdentifier": "191d5729-0b90-4000-8298-72431beb1701",
"supplierIdentifier": "191d5729-0b90-4000-8b72-58186a642401",
"supplierName": "Hilton",
"totalPrice": {
"amount": 100,
"currency": "USD"
},
"totalDisplayPrice": {
"amount": 100,
"currency": "USD"
},
"totalSupplierPrice": {
"amount": 100,
"currency": "USD"
},
"totalInternalPrice": {
"amount": 100,
"currency": "USD"
},
"totalCapturePrice": {
"amount": 100,
"currency": "USD"
}
}
]

请保存第 3 行的 id,您将用它注入 TripPay Web 组件。

此时,您已准备好将 Payment Web Component 嵌入您的网站并向用户展示。

<trip-pay id="contract-1"></trip-pay>

就集成而言,这就是您需要做的全部。后续所有繁重的工作都由 TripPay 负责完成。