feat(tenpayv3): 新增平台收付通账号托管模式相关接口

This commit is contained in:
Fu Diwei
2025-09-24 13:29:40 +08:00
parent dff1f69fb1
commit 587dc0251b
45 changed files with 1035 additions and 4 deletions

View File

@@ -1324,6 +1324,68 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /mchalterapply/mchcontactalterapplyment")]
public async Task TestEncryptRequestSensitiveProperty_CreateMerchantAlterApplyMerchantContactAlterApplymentRequest()
{
static Models.CreateMerchantAlterApplyMerchantContactAlterApplymentRequest GenerateMockRequestModel()
{
return new Models.CreateMerchantAlterApplyMerchantContactAlterApplymentRequest()
{
Contact = new Models.CreateMerchantAlterApplyMerchantContactAlterApplymentRequest.Types.Contact()
{
ContactName = MOCK_PLAIN_STR,
IdNumber = MOCK_PLAIN_STR,
MobileNumber = MOCK_PLAIN_STR
}
};
}
static void AssertMockRequestModel(Models.CreateMerchantAlterApplyMerchantContactAlterApplymentRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.Contact!.ContactName!);
Assert.NotEqual(MOCK_PLAIN_STR, request.Contact!.IdNumber!);
Assert.NotEqual(MOCK_PLAIN_STR, request.Contact!.MobileNumber!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Contact!.ContactName!));
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Contact!.IdNumber!));
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Contact!.MobileNumber!));
Assert.Equal(MOCK_CERT_SN, request.WechatpaySerialNumber!, ignoreCase: true);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseRSA(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateMerchantAlterApplyMerchantContactAlterApplymentAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseSM2(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateMerchantAlterApplyMerchantContactAlterApplymentAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /mchalterapply/mchsubjectalterapplyment")]
public async Task TestEncryptRequestSensitiveProperty_CreateMerchantAlterApplyMerchantSubjectAlterApplymentRequest()
{