mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 01:58:14 +08:00
chore: 升级示例项目为基于 .NET 6.0 的实现
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
</PropertyGroup>
|
@@ -26,14 +26,14 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.HttpClients.Imple
|
||||
|
||||
public WechatApiClient Create(string appId)
|
||||
{
|
||||
var wechatAccount = _wechatOptions.Accounts?.FirstOrDefault(e => string.Equals(appId, e.AppId));
|
||||
if (wechatAccount == null)
|
||||
var wechatAccountOptions = _wechatOptions.Accounts?.FirstOrDefault(e => string.Equals(appId, e.AppId));
|
||||
if (wechatAccountOptions == null)
|
||||
throw new Exception("未在配置项中找到该 AppId 对应的微信账号。");
|
||||
|
||||
return new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = wechatAccount.AppId,
|
||||
AppSecret = wechatAccount.AppSecret
|
||||
AppId = wechatAccountOptions.AppId,
|
||||
AppSecret = wechatAccountOptions.AppSecret
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
</PropertyGroup>
|
@@ -15,6 +15,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample_Net5.Services.HttpClients.
|
||||
|
||||
public CertificateManager Create(string merchantId)
|
||||
{
|
||||
// 注意:这里的工厂方法是为了演示多租户而存在的;如果你的项目只存在唯一一个租户,那么直接注入 `CertificateManager` 就可以
|
||||
|
||||
return _dict.GetOrAdd(merchantId, new InMemoryCertificateManager());
|
||||
}
|
||||
}
|
@@ -29,17 +29,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample_Net5.Services.HttpClients.
|
||||
|
||||
public WechatTenpayClient Create(string merchantId)
|
||||
{
|
||||
var merchantOptions = _tenpayOptions.Merchants?.FirstOrDefault(e => string.Equals(merchantId, e.MerchantId));
|
||||
if (merchantOptions == null)
|
||||
// 注意:这里的工厂方法是为了演示多租户而存在的;如果你的项目只存在唯一一个租户,那么直接注入 `WechatTenpayClient` 就可以
|
||||
|
||||
var tenpayMerchantOptions = _tenpayOptions.Merchants?.FirstOrDefault(e => string.Equals(merchantId, e.MerchantId));
|
||||
if (tenpayMerchantOptions == null)
|
||||
throw new Exception("未在配置项中找到该 MerchantId 对应的微信商户号。");
|
||||
|
||||
return new WechatTenpayClient(new WechatTenpayClientOptions()
|
||||
{
|
||||
MerchantId = merchantOptions.MerchantId,
|
||||
MerchantV3Secret = merchantOptions.SecretV3,
|
||||
MerchantCertSerialNumber = merchantOptions.CertSerialNumber,
|
||||
MerchantCertPrivateKey = merchantOptions.CertPrivateKey,
|
||||
CertificateManager = _tenpayCertificateManagerFactory.Create(merchantOptions.MerchantId),
|
||||
MerchantId = tenpayMerchantOptions.MerchantId,
|
||||
MerchantV3Secret = tenpayMerchantOptions.SecretV3,
|
||||
MerchantCertSerialNumber = tenpayMerchantOptions.CertSerialNumber,
|
||||
MerchantCertPrivateKey = tenpayMerchantOptions.CertPrivateKey,
|
||||
CertificateManager = _tenpayCertificateManagerFactory.Create(tenpayMerchantOptions.MerchantId),
|
||||
AutoEncryptRequestSensitiveProperty = true,
|
||||
AutoDecryptResponseSensitiveProperty = true
|
||||
});
|
Reference in New Issue
Block a user