# Licentivo 帳號與購買接入

本指南說明當前 Licentivo 提供方。使用其他授權系統的商戶可選擇[自定義 HTTP 提供方](/zh-hant/launch-documents/external-licensing/)；該模式不調用 Licentivo，也不要求其 API 密鑰。

## 管理員配置

1. 在 Licentivo 中創建產品與策略。
2. 在 Launch **系統設置 → Licentivo** 中配置讀寫管理密鑰。Licentivo 來源固定為 `https://www.licentivo.com`。
3. 為每個 Launch 銷售套餐版本選擇策略。Launch 讀取產品、策略版本和運行時顯示設置。
4. Launch 在同一個 Licentivo 管理連接下，為 sandbox/live 分別注冊帳號信任連接，包括身份簽名公鑰和商戶來源。

管理密鑰加密保留在商戶伺服器。客戶端安裝文件只包含公開路由資訊和固定受信的產品公鑰。

## 服務端 API 順序

以下路徑均位于 Licentivo，由 Launch 使用管理憑據調用：

| 接口 | 做什么 |
| --- | --- |
| `GET /api/v1/products` | 發現產品 |
| `GET /api/v1/policies`, `GET /api/v1/policies/{id}` | 發現策略及檢查版本 |
| `GET /api/v1/launch/connections` | 查找來源和環境的信任連接 |
| `POST /api/v1/launch/connections`, `PUT /api/v1/launch/connections/{id}` | 注冊或更新身份公鑰和路由 |
| `PUT /api/v1/launch/connections/{id}/plans/{plan}` | 注冊不可變的銷售套餐版本及 Licentivo 策略映射 |
| `POST /api/v1/launch/connections/{id}/events` | 提交絕對日期的帶版本購買快照 |
| `GET /api/v1/launch/connections/{id}/events/{event}` | 恢復或查詢原始結果 |
| `POST /api/v1/launch/connections/{id}/events/{event}/retry` | 經審核后重試同一事件 |
| `POST /api/v1/launch/connections/{id}/session-revocations` | 通知帳號或會話撤銷 |
| `GET /api/v1/launch/connections/{id}/session-revocations/{event}` | 驗證撤銷回執 |

Launch 在一個本地事務中記錄已驗證付款、不可變的付費覆蓋和待發送任務。工作進程發送完整的絕對購買日期及穩定事件 ID。只有 `applied` 回執才確認同步；僅 HTTP 接收不夠。

退款和已確認的支付撤銷移除對應訂單覆蓋。下一個完整快照可保留有效基礎購買、縮短期限、恢復低檔套餐或終止全部覆蓋。重試絕不會再增加一遍天數。舊許可證綁定使用明確遷移事件，不自動重放舊管理命令。

## 客戶應用流程

1. 應用使用桌面帳號會話登錄 Launch。
2. Launch 的 `POST /api/v1/software/products/{id}/identity` 返回最長 120 秒的身份斷言，綁定真實會話、產品、環境、簽發者和受眾。
3. Launch 包在內存中將其交給官方 SDK，SDK 再通過 `POST /api/v1/launch/exchange` 與 Licentivo 交換。
4. Licentivo 簽發設備憑據和簽名許可。SDK 檢查每次受保護動作、設備策略、運行時狀態及離線規則。

Launch 登錄、已付款訂單或已同步購買都不是運行時許可。舊 `/credential` 接口返回 HTTP 410。自定義提供方交付是獨立且限定所有者范圍的 API，不會恢復該接口。

設備列表、解綁額度、綁定代次和退出恢復仍由 Licentivo 負責。會話或帳號撤銷使用持久通知及各環境回執；離線撤銷仍受 SDK 已簽發許可限制。

參見[應用接入](/zh-hant/launch-documents/software-sdk-integration/)、[購買與帳號職責邊界](/zh-hant/launch-documents/account-purchase-boundary/)、[手動接入](/zh-hant/launch-documents/manual-integration/)和[驗收](/zh-hant/launch-documents/acceptance/)。實現位于 `internal/adapters/licentivo/launch_bridge.go`、`internal/app/launch_trust.go`、`internal/app/purchase_sync.go` 和 `internal/app/identity.go`。
