Bitzsoft.Integrations.ElectronicSignature
1.0.0-alpha.10
This is a prerelease version of Bitzsoft.Integrations.ElectronicSignature.
dotnet add package Bitzsoft.Integrations.ElectronicSignature --version 1.0.0-alpha.10
NuGet\Install-Package Bitzsoft.Integrations.ElectronicSignature -Version 1.0.0-alpha.10
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.ElectronicSignature" Version="1.0.0-alpha.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.ElectronicSignature" Version="1.0.0-alpha.10" />
<PackageReference Include="Bitzsoft.Integrations.ElectronicSignature" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.ElectronicSignature --version 1.0.0-alpha.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bitzsoft.Integrations.ElectronicSignature, 1.0.0-alpha.10"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.ElectronicSignature@1.0.0-alpha.10
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.ElectronicSignature&version=1.0.0-alpha.10&prerelease
#tool nuget:?package=Bitzsoft.Integrations.ElectronicSignature&version=1.0.0-alpha.10&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.ElectronicSignature
电子签章抽象层 — 统一接口定义、基础模型与结果包装。
屏蔽君子签、法大大、e签宝、上上签、爱签、契约锁、安证通、腾讯电子签等供应商差异,提供一致的合同发起、签署、印章、模板与回调验签 API。
功能特性
- 统一供应商接口
IElectronicSignatureProvider:12 个异步方法覆盖合同/签署/印章/模板全生命周期,外加回调验签 - 统一回调解析
IElectronicSignatureCallbackParser:将各供应商原始 Webhook 报文解析为标准CallbackEvent - 配置抽象
IElectronicSignatureConfigProvider:解耦配置来源,支持从 IOptions、数据库或远程配置中心加载 - 统一结果包装
ElectronicSignatureResult<T>:携带成功标志、数据与供应商原始错误码 - 统一异常
ElectronicSignatureException:封装供应商标识、错误码与原始消息 - 不可变模型设计:集合返回
IReadOnlyList<T>,属性使用init保证只读
安装
dotnet add package Bitzsoft.Integrations.ElectronicSignature
<PackageReference Include="Bitzsoft.Integrations.ElectronicSignature" Version="1.0.0" />
接口
IElectronicSignatureProvider
统一的电子签章供应商接口。统一方法仅覆盖最通用的极简场景(单文件、单签署方);复杂签署、企业签、关键字定位等请使用各供应商实现的 partial class 扩展方法。
| 方法 | 返回类型 | 说明 |
|---|---|---|
ProviderName |
string |
供应商标识(如 Qiyuesuo、ESign) |
CreateContractAsync |
Result<string> |
创建并发起签署,返回签署流程 ID |
GetContractDetailAsync |
Result<ContractDetail> |
获取合同详情 |
DownloadContractAsync |
Result<byte[]> |
下载合同文件字节 |
GetContractViewUrlAsync |
Result<string> |
获取在线查看地址 |
CancelContractAsync |
Result<bool> |
撤销签署(可附原因) |
GetSigningUrlAsync |
Result<string> |
获取指定签署方的签署页面 URL |
GetSigningStatusAsync |
Result<SigningStatus> |
获取合同签署状态 |
ListSealsAsync |
Result<IReadOnlyList<SealInfo>> |
获取印章列表 |
GetSealDetailAsync |
Result<SealInfo> |
获取印章详情 |
ListTemplatesAsync |
Result<IReadOnlyList<TemplateInfo>> |
分页获取模板列表 |
GetTemplateDetailAsync |
Result<TemplateDetail> |
获取模板详情 |
VerifyCallback |
bool |
验证 Webhook 回调签名 |
IElectronicSignatureCallbackParser
| 方法 | 返回类型 | 说明 |
|---|---|---|
ParseCallback |
CallbackEvent |
将供应商原始回调报文解析为统一事件 |
核心模型
| 类 | 关键字段 | 说明 |
|---|---|---|
SimpleContractRequest |
FileData、FileName、TemplateId、Title、SignerName、SignerPhone、SignerEmail、ExtensionParams |
极简签署请求(单文件、单签署方) |
ContractDetail |
ContractId、Title、Status、Signers、CreatedTime、CompletedTime、ExpireTime |
合同详情 |
SigningStatus |
ContractId、Status、SignedCount、TotalSignerCount |
签署状态 |
SealInfo |
SealId、Name、Type、ImageUrl、ImageData、OrganizationId |
印章信息 |
SignerInfo |
SignerId、Name、Type、SignStatus、SignedTime、RejectReason |
签署方信息 |
TemplateInfo |
TemplateId、Name、Description、CreatedTime |
模板摘要 |
TemplateDetail |
TemplateId、Name、Description、Fields |
模板详情 |
TemplateField |
FieldId、Name、FieldType、Required |
模板控件/填充项 |
CallbackEvent |
ContractId、Status、SignerId、RejectReason、EventTime、OriginalPayload |
统一回调事件 |
ElectronicSignatureResult<T> |
IsSuccess、Data、ErrorCode、ErrorMessage |
统一结果包装 |
ElectronicSignatureException |
ProviderName、ErrorCode、ProviderMessage |
统一异常 |
枚举
| 枚举 | 说明 |
|---|---|
ContractStatus |
合同状态:Draft / Signing / Completed / Cancelled / Rejected / Expired / Failed |
SignerType |
签署方类型:Personal / Enterprise |
SealType |
印章类型:Official / Personal / Financial / Contract / Other |
TemplateFieldType |
控件类型:Text / Number / Date / Signature / Seal / Checkbox / Image |
使用示例
抽象层本身只定义接口与模型,具体实现由各供应商包提供。以下示例假设已注册某个供应商实现:
public class ContractService(IElectronicSignatureProvider provider)
{
public async Task<string> StartSignAsync(byte[] pdf, string signerPhone)
{
// 1. 创建并发起签署
var createResult = await provider.CreateContractAsync(new SimpleContractRequest
{
Title = "采购合同",
FileName = "contract.pdf",
FileData = pdf,
SignerName = "张三",
SignerPhone = signerPhone
});
if (!createResult.IsSuccess)
throw new ElectronicSignatureException(
provider.ProviderName, createResult.ErrorCode, createResult.ErrorMessage);
var contractId = createResult.Data!;
// 2. 轮询签署状态
var status = await provider.GetSigningStatusAsync(contractId);
Console.WriteLine($"合同 {contractId} 当前状态:{status.Data?.Status}");
return contractId;
}
public async Task DownloadAsync(string contractId)
{
// 3. 签署完成后下载合同
var file = await provider.DownloadContractAsync(contractId);
await File.WriteAllBytesAsync($"signed-{contractId}.pdf", file.Data!);
}
}
回调验签与解析:
// Webhook 入口:先用 provider 验签,再用 parser 解析
var isValid = provider.VerifyCallback(
signature: request.Headers["X-Signature"],
payload: requestBody,
callbackHeaders: request.Headers,
queryString: request.QueryString.Value);
if (!isValid) return Results.Unauthorized();
var parser = serviceProvider.GetRequiredService<IElectronicSignatureCallbackParser>();
var evt = parser.ParseCallback(requestBody);
// evt.ContractId / evt.Status / evt.OriginalPayload
多供应商解析
同一应用注册多个供应商时,通过 ProviderName 路由到目标实现:
var providers = serviceProvider.GetServices<IElectronicSignatureProvider>();
var qiyuesuo = providers.First(p => p.ProviderName == "Qiyuesuo");
依赖
相关包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Core (>= 1.0.0-alpha.10)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Core (>= 1.0.0-alpha.10)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Core (>= 1.0.0-alpha.10)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Bitzsoft.Integrations.ElectronicSignature:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.All
Bitzsoft 第三方集成聚合包 — net5.0 包含传统连接器,net8.0+ 额外包含受上游 TFM 限制的 AI 模块 |
|
|
Bitzsoft.Integrations.ElectronicSignature.All
电子签章聚合包 — 包含君子签 / 法大大 / 爱签 / 上上签 / e签宝 / 契约锁 / 安证通 / 腾讯电子签全部实现 |
|
|
Bitzsoft.Integrations.ElectronicSignature.Qiyuesuo
契约锁电子签章实现 |
|
|
Bitzsoft.Integrations.ElectronicSignature.Junziqian
君子签电子签章实现 |
|
|
Bitzsoft.Integrations.ElectronicSignature.Fadada
法大大电子签章实现 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.10 | 0 | 7/26/2026 |
| 1.0.0-alpha.9 | 89 | 7/12/2026 |
| 1.0.0-alpha.8 | 134 | 7/1/2026 |
| 1.0.0-alpha.7 | 107 | 6/16/2026 |
| 1.0.0-alpha.6 | 105 | 6/16/2026 |
| 1.0.0-alpha.5 | 117 | 6/14/2026 |
| 1.0.0-alpha.4 | 57 | 7/1/2026 |
| 1.0.0-alpha.3 | 98 | 6/7/2026 |