跳到內容

與 TripPay 整合

本文包含一個從頭到尾的範例,說明如何與 TripPay 整合。

建議您已閱讀:

以下是成功使用 TripPay 支付訂單的步驟:

  1. 確認您在訂單合約中提及的受益人已完成映射。
  2. 讓旅客選擇他們想預訂的庫存並準備付款。
  3. 使用 TripPay 建立包含欲預訂項目的 應付合約
  4. 讓旅客使用 TripPay 網頁元件付款。

我們假設您已完成 步驟 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 網頁元件。

此時,您已準備好將 付款網頁元件 嵌入您的網站並顯示給使用者。

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

就整合而言,這就是您需要做的全部。後續所有繁重的工作都由 TripPay 負責處理。