Bitzsoft.Integrations.Finance.Invoice.Baiwang
1.0.0-alpha.10
dotnet add package Bitzsoft.Integrations.Finance.Invoice.Baiwang --version 1.0.0-alpha.10
NuGet\Install-Package Bitzsoft.Integrations.Finance.Invoice.Baiwang -Version 1.0.0-alpha.10
<PackageReference Include="Bitzsoft.Integrations.Finance.Invoice.Baiwang" Version="1.0.0-alpha.10" />
<PackageVersion Include="Bitzsoft.Integrations.Finance.Invoice.Baiwang" Version="1.0.0-alpha.10" />
<PackageReference Include="Bitzsoft.Integrations.Finance.Invoice.Baiwang" />
paket add Bitzsoft.Integrations.Finance.Invoice.Baiwang --version 1.0.0-alpha.10
#r "nuget: Bitzsoft.Integrations.Finance.Invoice.Baiwang, 1.0.0-alpha.10"
#:package Bitzsoft.Integrations.Finance.Invoice.Baiwang@1.0.0-alpha.10
#addin nuget:?package=Bitzsoft.Integrations.Finance.Invoice.Baiwang&version=1.0.0-alpha.10&prerelease
#tool nuget:?package=Bitzsoft.Integrations.Finance.Invoice.Baiwang&version=1.0.0-alpha.10&prerelease
Bitzsoft.Integrations.Finance.Invoice.Baiwang
百旺金赋发票服务实现 -- 对接百旺金穗云 SaaS 开放平台 API,提供发票全生命周期管理。
功能特性
- 完整开票能力:开具蓝字发票、红字冲销、作废(基于
IInvoiceProvider) - 特有开票模式:
IBaiwangIssueProvider提供数电蓝字发票、数电纸票、折扣行、差额征收开票(digitalBlueInvoice/digitalPaperInvoice/discountInvoice/differentialInvoice) - 精确查询:
IBaiwangQueryProvider按业务订单号或发票号码精确查询 - 查验与采集:
IBaiwangVerifyProvider提供新版查验、乐企查验、采集发票保存与查询,并继承IInvoiceOcrProvider - 企业信息:
IBaiwangEnterpriseProvider提供智能抬头查询、税控设备查询、开票终端查询、票种查询 - 进项全流程:
IBaiwangInputProvider提供进项同步、版式文件下载、勾选 / 取消勾选、入账、统计查询 - 库存管理:
IBaiwangStockProvider提供剩余票量查询、待开票号获取 - 税局登录与实人认证:
IBaiwangInvoiceProvider提供电子税务局登录、实人认证二维码与结果轮询、数电红冲结果查询 - 聚合接口:
IBaiwangInvoiceProvider一次性聚合上述全部能力
安装
.NET CLI
dotnet add package Bitzsoft.Integrations.Finance.Invoice.Baiwang
PackageReference
<PackageReference Include="Bitzsoft.Integrations.Finance.Invoice.Baiwang" Version="1.0.0" />
配置
appsettings.json
{
"Finance": {
"Invoice": {
"Baiwang": {
"GatewayKey": "百旺提供的网关密钥标识",
"Secret": "双方约定的网关密钥",
"TaxNumber": "企业税号",
"BaseUrl": "https://api.baiwangjs.com"
}
}
}
}
| 配置项 | 必填 | 默认值 | 说明 |
|---|---|---|---|
GatewayKey |
是 | — | 百旺金穗云网关密钥标识 |
Secret |
是 | — | 双方约定的网关密钥(用于 HMAC 签名) |
TaxNumber |
是 | — | 销方纳税人识别号 |
BaseUrl |
否 | https://api.baiwangjs.com |
百旺金穗云 SaaS API 基地址 |
HttpClientName |
否 | BaiwangInvoice |
命名 HttpClient 名称 |
UserAgent |
否 | Bitzsoft.Integrations/1.0.0 |
用户代理标识 |
含网关密钥等敏感信息,严禁序列化、日志输出或暴露给前端。
注册服务
从 IConfiguration 绑定(推荐)
using Bitzsoft.Integrations.Finance.Invoice.Baiwang;
builder.Services.AddBitzsoftBaiwangInvoice(
builder.Configuration,
"Finance:Invoice:Baiwang");
委托配置
builder.Services.AddBitzsoftBaiwangInvoice(options =>
{
options.GatewayKey = "百旺提供的网关密钥标识";
options.Secret = "双方约定的网关密钥";
options.TaxNumber = "企业税号";
});
注册后 Provider 为 Singleton,通过 BaiwangAuthHandler 自动完成 HMAC 签名,同时注册聚合接口 IBaiwangInvoiceProvider 与各角色接口。
第三方请求日志
内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认使用 NullRequestLogStore 不持久化。
// 持久化:宿主注册 IRequestLogStore 实现后,所有出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
opts.MaxInMemoryBodyBytes = 64 * 1024; // 仅控制内存/加密临时文件切换,不截断正文
opts.SensitiveFields.Add("Secret");
});
services.AddBitzsoftBaiwangInvoice(options => { /* ... */ });
使用示例
using Bitzsoft.Integrations.Finance.Invoice.Baiwang;
using Bitzsoft.Integrations.Finance.Invoice.Models;
// 注入聚合接口(含全部能力)
public class BaiwangService(IBaiwangInvoiceProvider baiwang)
{
// 基础开票(来自 IInvoiceProvider)
public Task<InvoiceIssueResult> IssueAsync(InvoiceIssueRequest req) => baiwang.IssueAsync(req);
// 数电蓝字发票
public Task<InvoiceIssueResult> IssueDigitalAsync(InvoiceIssueRequest req)
=> baiwang.IssueDigitalBlueInvoiceAsync(req);
// 智能抬头查询
public Task<IReadOnlyList<SmartTitleInfo>> GetTitleAsync(string keyword)
=> baiwang.GetSmartTitleAsync(keyword);
}
// 或仅注入所需角色接口
public class InputOnlyService(IBaiwangInputProvider input)
{
public Task SyncAsync(DateTime start, DateTime end)
=> input.SyncInputInvoicesAsync(start, end);
}
核心类型一览
Provider 与注册
| 类型 | 说明 |
|---|---|
BaiwangInvoiceProvider |
百旺发票服务实现(sealed partial,Singleton) |
ServiceCollectionExtensions.AddBitzsoftBaiwangInvoice |
DI 注册扩展(Action<BaiwangOptions> 与 IConfiguration 双重载) |
BaiwangOptions |
配置选项(见上表) |
扩展接口
| 接口 | 能力 | 主要方法 |
|---|---|---|
IBaiwangInvoiceProvider |
聚合接口(含下列全部 + 红冲结果查询 + 税局登录 + 实人认证) | 继承全部角色接口 |
IBaiwangIssueProvider |
特有开票模式 | IssueDigitalBlueInvoiceAsync / IssueDigitalPaperInvoiceAsync / IssueDiscountInvoiceAsync / IssueDifferentialInvoiceAsync |
IBaiwangQueryProvider |
精确查询 | QueryByOrderNoAsync / QueryByNumberAsync |
IBaiwangVerifyProvider |
查验与采集(继承 IInvoiceOcrProvider) |
VerifyInvoiceAsync / LeqiVerifyAsync / SaveCollectedInvoiceAsync / QueryCollectedInvoiceAsync |
IBaiwangEnterpriseProvider |
企业信息 | GetSmartTitleAsync / QueryTaxDevicesAsync / QueryTerminalsAsync / QueryDigitalPaperTypesAsync / GetEnterpriseBasicInfoAsync |
IBaiwangInputProvider |
进项管理 | SyncInputInvoicesAsync / DownloadInputFileAsync / TickInputInvoiceAsync / SubmitInputAccountingAsync / QueryInputStatisticsAsync |
IBaiwangStockProvider |
库存管理 | QueryRemainingQuantityAsync / GetPendingInvoiceNumberAsync |
IBaiwangInvoiceProvider 还提供:QueryRedFlushResultAsync(数电红冲结果轮询)、LoginTaxBureauAsync(电子税务局登录)、GetRealPersonAuthQRCodeAsync / QueryAuthResultAsync(实人认证)。
同时实现抽象层接口:IInvoiceProvider、IInvoiceOcrProvider。
依赖
| 包 | 说明 |
|---|---|
Bitzsoft.Integrations.Finance.Invoice |
发票管理抽象层 |
Bitzsoft.Integrations.RequestLogging |
出站请求记录管道 |
Microsoft.Extensions.Http |
IHttpClientFactory(Typed Client 连接池) |
Microsoft.Extensions.Options.ConfigurationExtensions |
Options 配置节点绑定 |
相关包
- Bitzsoft.Integrations.Finance.Invoice -- 发票管理抽象层
- Bitzsoft.Integrations.Finance.Invoice.All -- 发票管理聚合包(含本实现)
- Bitzsoft.Integrations.Finance.All -- 财税管理全量聚合包
- Bitzsoft.Integrations.Compatibility -- 基础工具库
- Bitzsoft.Integrations.RequestLogging -- 出站请求记录
| 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. |
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Finance.Invoice (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Finance.Invoice (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.Finance.Invoice (>= 1.0.0-alpha.10)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.Finance.Invoice.Baiwang:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.Finance.Invoice.All
发票管理服务聚合包 — 包含所有供应商实现 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.10 | 32 | 7/26/2026 |
| 1.0.0-alpha.9 | 63 | 7/12/2026 |
| 1.0.0-alpha.8 | 63 | 7/1/2026 |
| 1.0.0-alpha.7 | 77 | 6/16/2026 |
| 1.0.0-alpha.6 | 72 | 6/16/2026 |
| 1.0.0-alpha.5 | 68 | 6/14/2026 |