mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat(tenpayv3): 新增品牌红包相关接口
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"brand_id": 1234,
|
||||
"brand_appid": "wxf636efh567hg4356",
|
||||
"scene": "CUSTOM_SEND",
|
||||
"template_id": "123400001",
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"batch_name": "双十一营销用品牌红包",
|
||||
"batch_remark": "双十一营销用品牌红包",
|
||||
"total_amount": 10000,
|
||||
"total_num": 10,
|
||||
"detail_list": [
|
||||
{
|
||||
"out_detail_no": "x23zy545Bd5436",
|
||||
"amount": 100,
|
||||
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"remark": "来自XX的红包"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"batch_no": "1210000071100999991182020050700019480001",
|
||||
"create_time": "2015-05-20T13:29:35+08:00",
|
||||
"batch_state": "ACCEPTED"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"brand_mchid": "1900001109",
|
||||
"batch_no": "1030000071100999991182020050700019480001",
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"brand_id": 1234,
|
||||
"template_id": "12340000000001",
|
||||
"brand_appid": "wxf636efh567hg4356",
|
||||
"batch_state": "ACCEPTED",
|
||||
"batch_name": "双十一营销发放品牌红包",
|
||||
"batch_remark": "双十一营销发放品牌红包",
|
||||
"close_reason": "SYSTEM_OVERDUE_CLOSE",
|
||||
"total_amount": 10000,
|
||||
"total_num": 10,
|
||||
"create_time": "2015-05-20T13:29:35+08:00",
|
||||
"update_time": "2015-05-20T13:29:35+08:00",
|
||||
"success_amount": 5000,
|
||||
"success_num": 10,
|
||||
"fail_amount": 5000,
|
||||
"fail_num": 10,
|
||||
"detail_list": [
|
||||
{
|
||||
"transfer_detail_no": "1220000071100999991182020050700019500100",
|
||||
"out_detail_no": "x23zy545Bd5436",
|
||||
"detail_state": "DETAIL_SUCCESS"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"brand_mchid": "1900001109",
|
||||
"batch_no": "1030000071100999991182020050700019480001",
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"brand_id": 1234,
|
||||
"template_id": "12340000000001",
|
||||
"brand_appid": "wxf636efh567hg4356",
|
||||
"batch_state": "ACCEPTED",
|
||||
"batch_name": "双十一营销发放品牌红包",
|
||||
"batch_remark": "双十一营销发放品牌红包",
|
||||
"close_reason": "SYSTEM_OVERDUE_CLOSE",
|
||||
"total_amount": 10000,
|
||||
"total_num": 10,
|
||||
"create_time": "2015-05-20T13:29:35+08:00",
|
||||
"update_time": "2015-05-20T13:29:35+08:00",
|
||||
"success_amount": 5000,
|
||||
"success_num": 10,
|
||||
"fail_amount": 5000,
|
||||
"fail_num": 10,
|
||||
"detail_list": [
|
||||
{
|
||||
"transfer_detail_no": "1220000071100999991182020050700019500100",
|
||||
"out_detail_no": "x23zy545Bd5436",
|
||||
"detail_state": "DETAIL_SUCCESS"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"brand_mchid": "1900001109",
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"batch_no": "1030000071100999991182020050700019480001",
|
||||
"out_detail_no": "x23zy545Bd5436",
|
||||
"detail_no": "1040000071100999991182020050700019500100",
|
||||
"detail_state": "DETAIL_SUCCESS",
|
||||
"amount": 100,
|
||||
"remark": "来自XX品牌红包",
|
||||
"fail_reason": "ACCOUNT_FROZEN",
|
||||
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"initiate_time": "2015-05-20T13:29:35+08:00",
|
||||
"update_time": "2015-05-20T13:29:35+08:00",
|
||||
"brand_id": 1234,
|
||||
"template_id": "12340000000001",
|
||||
"brand_appid": "wxf636efh567hg4356"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"brand_mchid": "1900001109",
|
||||
"out_batch_no": "plfk2020042013",
|
||||
"batch_no": "1030000071100999991182020050700019480001",
|
||||
"out_detail_no": "x23zy545Bd5436",
|
||||
"detail_no": "1040000071100999991182020050700019500100",
|
||||
"detail_state": "DETAIL_SUCCESS",
|
||||
"amount": 100,
|
||||
"remark": "来自XX品牌红包",
|
||||
"fail_reason": "ACCOUNT_FROZEN",
|
||||
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"initiate_time": "2015-05-20T13:29:35+08:00",
|
||||
"update_time": "2015-05-20T13:29:35+08:00",
|
||||
"brand_id": 1234,
|
||||
"template_id": "12340000000001",
|
||||
"brand_appid": "wxf636efh567hg4356"
|
||||
}
|
||||
@@ -907,6 +907,65 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/brand-redpacket/brand-merchant-batches)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppBrandRedPacketBrandMerchantBatchRequest()
|
||||
{
|
||||
static Models.CreateFundAppBrandRedPacketBrandMerchantBatchRequest GenerateMockRequestModel()
|
||||
{
|
||||
return new Models.CreateFundAppBrandRedPacketBrandMerchantBatchRequest()
|
||||
{
|
||||
TransferDetailList = new List<Models.CreateFundAppBrandRedPacketBrandMerchantBatchRequest.Types.TransferDetail>()
|
||||
{
|
||||
new Models.CreateFundAppBrandRedPacketBrandMerchantBatchRequest.Types.TransferDetail()
|
||||
{
|
||||
UserName = MOCK_PLAIN_STR
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.CreateFundAppBrandRedPacketBrandMerchantBatchRequest request, Func<string, string> decryptor)
|
||||
{
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.TransferDetailList![0].UserName!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.TransferDetailList![0].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.ExecuteCreateFundAppBrandRedPacketBrandMerchantBatchAsync(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.ExecuteCreateFundAppBrandRedPacketBrandMerchantBatchAsync(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()
|
||||
{
|
||||
|
||||
@@ -553,6 +553,67 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no})")]
|
||||
public async Task TestDecryptResponseSensitiveProperty_GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse()
|
||||
{
|
||||
static Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse GenerateMockResponseModel(Func<string, string> encryptor)
|
||||
{
|
||||
return SetMockResponseRawStatusAsOk(new Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse()
|
||||
{
|
||||
UserName = encryptor.Invoke(MOCK_PLAIN_STR)
|
||||
});
|
||||
}
|
||||
|
||||
static void AssertMockResponseModel(Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse response)
|
||||
{
|
||||
Assert.Equal(MOCK_PLAIN_STR, response.UserName!);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
|
||||
{
|
||||
using (var client = CreateMockClientUseRSA(autoDecrypt: false))
|
||||
{
|
||||
var response = GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)!);
|
||||
client.DecryptResponseSensitiveProperty(response);
|
||||
AssertMockResponseModel(response);
|
||||
}
|
||||
|
||||
using (var client = CreateMockClientUseRSA(
|
||||
autoDecrypt: true,
|
||||
mockResponseContent: new SystemTextJsonSerializer().Serialize(
|
||||
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)!)
|
||||
)
|
||||
))
|
||||
{
|
||||
var request = new Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberRequest();
|
||||
var response = await client.ExecuteGetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberAsync(request);
|
||||
AssertMockResponseModel(response);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
|
||||
{
|
||||
using (var client = CreateMockClientUseSM2(autoDecrypt: false))
|
||||
{
|
||||
var response = GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!);
|
||||
client.DecryptResponseSensitiveProperty(response);
|
||||
AssertMockResponseModel(response);
|
||||
}
|
||||
|
||||
using (var client = CreateMockClientUseSM2(
|
||||
autoDecrypt: true,
|
||||
mockResponseContent: new SystemTextJsonSerializer().Serialize(
|
||||
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!)
|
||||
)
|
||||
))
|
||||
{
|
||||
var request = new Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberRequest();
|
||||
var response = await client.ExecuteGetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberAsync(request);
|
||||
AssertMockResponseModel(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /marketing/shopping-receipt/shoppingreceipts)")]
|
||||
public async Task TestDecryptResponseSensitiveProperty_UploadMarketingShoppingReceiptResponse()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user