Bitzsoft.Integrations.Payment.All 1.0.1

dotnet add package Bitzsoft.Integrations.Payment.All --version 1.0.1
                    
NuGet\Install-Package Bitzsoft.Integrations.Payment.All -Version 1.0.1
                    
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.Payment.All" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.Payment.All" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.Payment.All" />
                    
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.Payment.All --version 1.0.1
                    
#r "nuget: Bitzsoft.Integrations.Payment.All, 1.0.1"
                    
#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.Payment.All@1.0.1
                    
#: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.Payment.All&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.Payment.All&version=1.0.1
                    
Install as a Cake Tool

Bitzsoft.Integrations.Payment.All

支付服务聚合包,按配置节自动注册已实现的全部支付供应商。

本包是元包(meta-package),本身不含代码,仅聚合传递引用五个供应商实现包 + 抽象层。

功能特性

  • 统一 IPaymentProvider 接口:屏蔽支付宝、微信支付、Stripe、PayPal、银联等供应商差异
  • 多供应商配置驱动:按配置节自动注册,仅注册配置中存在的供应商(section.Exists() 判定)
  • 跨领域统一解析:通过 IIntegrationProviderResolver<IPaymentProvider> 按供应商编码解析
  • 供应商元数据可枚举IIntegrationProviderCatalog 可枚举当前配置的供应商,读取 API、鉴权、地区、环境、稳定性与限制元数据

安装

dotnet add package Bitzsoft.Integrations.Payment.All
<PackageReference Include="Bitzsoft.Integrations.Payment.All" Version="1.0.0" />

安装后自动引入:

配置

appsettings.json -- 按需配置启用的供应商,未配置的供应商不会注册。

{
  "Payment": {
    "Alipay": {
      "AppId": "your-app-id",
      "MerchantPrivateKey": "your-private-key"
    },
    "WeChatPay": {
      "AppId": "your-app-id",
      "MchId": "your-mch-id",
      "ApiV3Key": "your-api-v3-key"
    },
    "Stripe": {
      "SecretKey": "sk_live_xxx",
      "WebhookSecret": "whsec_xxx"
    },
    "PayPal": {
      "ClientId": "your-client-id",
      "ClientSecret": "your-client-secret",
      "UseSandbox": true
    },
    "UnionPay": {
      "MerId": "your-mer-id",
      "CertPath": "/path/to/your.pfx",
      "CertPassword": "your-cert-password"
    }
  }
}

仅配置中存在的供应商节会被注册,无需删除不想用的供应商节以外的配置。

注册服务

using Microsoft.Extensions.DependencyInjection;

// 一行注册配置中存在的全部供应商
builder.Services.AddBitzsoftPaymentAll(builder.Configuration, "Payment");

单供应商应用可直接注入 IPaymentProvider;多供应商应用请通过 IIntegrationProviderResolver<IPaymentProvider> 按编码解析,不要依赖注册顺序。

使用示例

通过 Resolver 按编码解析(推荐)

using Bitzsoft.Integrations.Core;
using Bitzsoft.Integrations.Payment;

public sealed class CheckoutService(
    IIntegrationProviderResolver<IPaymentProvider> providers)
{
    public async Task<string> CreatePaymentAsync(
        string providerCode, string outTradeNo, long amountCents, string subject)
    {
        // providerCode: "alipay" / "wechatpay" / "stripe" / "paypal" / "unionpay"
        var provider = providers.GetRequired(providerCode);

        var result = await provider.CreateOrderAsync(new PaymentOrderRequest
        {
            OutTradeNo = outTradeNo,
            Subject = subject,
            TotalAmount = amountCents,
            Currency = "CNY",
            Scene = PaymentScene.Web
        });

        if (!result.IsSuccess)
            throw new PaymentException(provider.Code, result.ErrorCode, result.ErrorMessage);

        return result.Data!.PayUrl!;
    }

    public async Task<bool> IsPaidAsync(string providerCode, string outTradeNo)
    {
        var provider = providers.GetRequired(providerCode);
        var result = await provider.QueryStatusAsync(outTradeNo);
        return result.IsSuccess && result.Data!.Status == PaymentStatus.Success;
    }
}

供应商编码对照表

编码 常量 供应商
alipay PaymentProviderCode.Alipay 支付宝
wechatpay PaymentProviderCode.WeChatPay 微信支付
stripe PaymentProviderCode.Stripe Stripe
paypal PaymentProviderCode.PayPal PayPal
unionpay PaymentProviderCode.UnionPay 银联

依赖

说明
Bitzsoft.Integrations.Payment 抽象层(IPaymentProvider 接口 / 模型)
Bitzsoft.Integrations.Payment.Alipay 支付宝实现
Bitzsoft.Integrations.Payment.WeChatPay 微信支付实现
Bitzsoft.Integrations.Payment.Stripe Stripe 实现
Bitzsoft.Integrations.Payment.PayPal PayPal 实现
Bitzsoft.Integrations.Payment.UnionPay 银联实现
Bitzsoft.Integrations.Compatibility 基础工具库

相关包

供应商 包名
统一抽象 Bitzsoft.Integrations.Payment
支付宝 Bitzsoft.Integrations.Payment.Alipay
微信支付 Bitzsoft.Integrations.Payment.WeChatPay
Stripe Bitzsoft.Integrations.Payment.Stripe
PayPal Bitzsoft.Integrations.Payment.PayPal
银联 Bitzsoft.Integrations.Payment.UnionPay
聚合包 Bitzsoft.Integrations.Payment.All
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 0 8/3/2026
1.0.0 32 8/2/2026
1.0.0-alpha.10 43 7/26/2026
1.0.0-alpha.9 400 7/12/2026