feat(tenpayv3): 新增商家转账到 QQ 钱包相关接口

This commit is contained in:
Fu Diwei
2025-04-21 17:13:51 +08:00
parent ae2815f7d2
commit 297ccb060c
17 changed files with 672 additions and 8 deletions

View File

@@ -854,6 +854,59 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills")]
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferToQQWalletBillRequest()
{
static Models.CreateFundAppMerchantTransferToQQWalletBillRequest GenerateMockRequestModel()
{
return new Models.CreateFundAppMerchantTransferToQQWalletBillRequest()
{
UserName = MOCK_PLAIN_STR
};
}
static void AssertMockRequestModel(Models.CreateFundAppMerchantTransferToQQWalletBillRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.UserName!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.UserName!));
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.ExecuteCreateFundAppMerchantTransferToQQWalletBillAsync(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.ExecuteCreateFundAppMerchantTransferToQQWalletBillAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /marketing/membercard-open/cards/{card_id}/phone-membercard/import")]
public async Task TestEncryptRequestSensitiveProperty_ImportMarketingMemberCardOpenCardPhoneRequest()
{