# Licentivo 账号与购买接入

本指南说明当前 Licentivo 提供方。使用其他授权系统的商户可选择[自定义 HTTP 提供方](/zh/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/launch-documents/software-sdk-integration/)、[购买与账号职责边界](/zh/launch-documents/account-purchase-boundary/)、[手动接入](/zh/launch-documents/manual-integration/)和[验收](/zh/launch-documents/acceptance/)。实现位于 `internal/adapters/licentivo/launch_bridge.go`、`internal/app/launch_trust.go`、`internal/app/purchase_sync.go` 和 `internal/app/identity.go`。
