Bitzsoft.Integrations.Finance.Invoice.Baiwang 1.0.0-alpha.10

This is a prerelease version of Bitzsoft.Integrations.Finance.Invoice.Baiwang.
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
                    
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.Finance.Invoice.Baiwang" 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.Finance.Invoice.Baiwang" Version="1.0.0-alpha.10" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.Finance.Invoice.Baiwang" />
                    
Project file
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.Finance.Invoice.Baiwang --version 1.0.0-alpha.10
                    
#r "nuget: Bitzsoft.Integrations.Finance.Invoice.Baiwang, 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.Finance.Invoice.Baiwang@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.Finance.Invoice.Baiwang&version=1.0.0-alpha.10&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.Finance.Invoice.Baiwang&version=1.0.0-alpha.10&prerelease
                    
Install as a Cake Tool

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(实人认证)。

同时实现抽象层接口:IInvoiceProviderIInvoiceOcrProvider

依赖

说明
Bitzsoft.Integrations.Finance.Invoice 发票管理抽象层
Bitzsoft.Integrations.RequestLogging 出站请求记录管道
Microsoft.Extensions.Http IHttpClientFactory(Typed Client 连接池)
Microsoft.Extensions.Options.ConfigurationExtensions Options 配置节点绑定

相关包

Product 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.

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