2022-11-24 11:45:00 +08:00
|
|
|
using System;
|
2022-11-09 20:48:03 +08:00
|
|
|
using System.Threading.Tasks;
|
2021-05-10 15:30:00 +08:00
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
|
|
|
{
|
2022-01-21 14:30:17 +08:00
|
|
|
internal class TestClients
|
2021-05-10 15:30:00 +08:00
|
|
|
{
|
|
|
|
static TestClients()
|
|
|
|
{
|
2022-11-28 12:10:04 +08:00
|
|
|
var manager = new Settings.InMemoryCertificateManager();
|
|
|
|
InstanceUseRSA = new WechatTenpayClient(new WechatTenpayClientOptions()
|
2022-01-21 14:30:17 +08:00
|
|
|
{
|
2021-05-10 15:30:00 +08:00
|
|
|
MerchantId = TestConfigs.WechatMerchantId,
|
|
|
|
MerchantV3Secret = TestConfigs.WechatMerchantSecret,
|
2022-11-28 12:10:04 +08:00
|
|
|
MerchantCertificateSerialNumber = TestConfigs.WechatMerchantRSACertificateSerialNumber,
|
|
|
|
MerchantCertificatePrivateKey = TestConfigs.WechatMerchantRSACertificatePrivateKey,
|
|
|
|
PlatformCertificateManager = manager
|
|
|
|
});
|
|
|
|
InstanceUseSM2 = new WechatTenpayClient(new WechatTenpayClientOptions()
|
|
|
|
{
|
|
|
|
MerchantId = TestConfigs.WechatMerchantId,
|
|
|
|
MerchantV3Secret = TestConfigs.WechatMerchantSecret,
|
|
|
|
SignScheme = Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3,
|
|
|
|
MerchantCertificateSerialNumber = TestConfigs.WechatMerchantSM2CertificateSerialNumber!,
|
|
|
|
MerchantCertificatePrivateKey = TestConfigs.WechatMerchantSM2CertificatePrivateKey!,
|
|
|
|
PlatformCertificateManager = manager
|
2021-05-10 15:30:00 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-26 02:40:40 +08:00
|
|
|
internal static async Task InitializeCertificateManagerAsync()
|
|
|
|
{
|
2022-11-28 12:10:04 +08:00
|
|
|
var request = new Models.QueryCertificatesRequest() { AlgorithmType = "ALL" };
|
|
|
|
var response = await InstanceUseRSA.ExecuteQueryCertificatesAsync(request);
|
2022-11-24 11:45:00 +08:00
|
|
|
|
|
|
|
if (!response.IsSuccessful())
|
|
|
|
throw new Exception();
|
|
|
|
|
2022-11-28 12:10:04 +08:00
|
|
|
foreach (var certificate in InstanceUseRSA.DecryptResponseSensitiveProperty(response).CertificateList)
|
2021-11-26 02:40:40 +08:00
|
|
|
{
|
2022-11-28 12:10:04 +08:00
|
|
|
InstanceUseRSA.PlatformCertificateManager.AddEntry(new Settings.CertificateEntry(certificate));
|
2021-11-26 02:40:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 12:10:04 +08:00
|
|
|
public static readonly WechatTenpayClient InstanceUseRSA;
|
|
|
|
public static readonly WechatTenpayClient InstanceUseSM2;
|
2021-05-10 15:30:00 +08:00
|
|
|
}
|
|
|
|
}
|