基于腾讯电子签 API 实现,采用腾讯云签名 v3(TC3-HMAC-SHA256)鉴权机制。
包信息
- NuGet 包:
Bitzsoft.Integrations.ElectronicSignature.Tencent - 接口:
IElectronicSignatureProvider - 鉴权:TC3-HMAC-SHA256(SecretId / SecretKey)
- Provider ID:
Tencent
配置
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
SecretId | string | 是 | — | 腾讯云访问密钥 ID |
SecretKey | string | 是 | — | 腾讯云访问密钥 Key |
Version | string | 否 | API 常量值 | API 版本 |
Endpoint | string | 否 | 默认接入点 | 业务接口接入点 |
BaseUrl | string | 否 | https://{Endpoint} | 派生自 Endpoint |
FileEndpoint | string | 否 | 默认文件接入点 | UploadFiles 接口使用的文件服务域名 |
Region | string? | 否 | — | 腾讯云地域(可选) |
OperatorUserId | string | 是 | — | 自建应用经办人 UserId |
ProxyOrganizationId | string? | 否 | — | 代理企业 ID(集团子公司代发场景) |
DefaultFlowType | string? | 否 | — | 默认合同类型 |
DefaultSignUrlJumpUrl | string? | 否 | — | 默认 H5 签署完成后跳转地址 |
UseSandbox | bool | 否 | false | 是否使用测试环境 |
Timeout | TimeSpan | 否 | 00:01:40 | HTTP 请求超时 |
HttpClientName | string | 否 | TencentElectronicSignature | HttpClient 注册名称 |
{ "ElectronicSignature": { "Tencent": { "SecretId": "your-secret-id", "SecretKey": "your-secret-key", "OperatorUserId": "your-operator-user-id", "UseSandbox": false } }}注册
using Bitzsoft.Integrations.ElectronicSignature.Tencent;
// 方式一:IConfiguration(默认读取 "ElectronicSignature:Tencent" 配置节)services.AddBitzsoftTencentElectronicSignature(configuration);
// 方式二:委托配置services.AddBitzsoftTencentElectronicSignature(options =>{ options.SecretId = "your-secret-id"; options.SecretKey = "your-secret-key"; options.OperatorUserId = "your-operator-user-id";});使用示例
var createResult = await provider.CreateContractAsync(new SimpleContractRequest{ Title = "服务协议", FileName = "contract.pdf", FileData = await File.ReadAllBytesAsync("contract.pdf"), SignerName = "吴十", SignerPhone = "13200000000"});
var contractId = createResult.Data!;var detail = await provider.GetContractDetailAsync(contractId);var status = await provider.GetSigningStatusAsync(contractId);鉴权机制
- 采用腾讯云签名 v3 规范:按规范拼接规范请求串,再派生签名串,逐层 HMAC-SHA256 计算签名。
TencentElectronicSignatureHttpClient以 Typed Client 模式注册。
已知限制
OperatorUserId 为必填项(自建应用经办人)。统一接口覆盖极简场景,复杂业务通过 partial class 扩展。