mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 09:54:44 +08:00
feat(tenpayv3): 新增商家转账用户免确认收款相关接口
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"out_authorization_no": "plfk2020042013",
|
||||
"appid": "102022609",
|
||||
"openid": "216BE837A39456BD6729F6F47D7C0EEE",
|
||||
"user_display_name": "wx_123456",
|
||||
"authorization_id": "201202504101000123456789012",
|
||||
"state": "TAKING_EFFECT",
|
||||
"authorize_time": "2015-05-20T13:29:35.120+08:00"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"appid": "wxf636efh567hg4356",
|
||||
"out_bill_no": "plfk2020042013",
|
||||
"transfer_scene_id": "1000",
|
||||
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"transfer_amount": 400000,
|
||||
"transfer_remark": "新会员开通有礼",
|
||||
"notify_url": "https://www.weixin.qq.com/wxpay/pay.php",
|
||||
"user_recv_perception": "现金奖励",
|
||||
"transfer_scene_report_infos": [
|
||||
{
|
||||
"info_type": "活动名称",
|
||||
"info_content": "新会员有礼"
|
||||
}
|
||||
],
|
||||
"authorization_info": {
|
||||
"user_display_name": "wx_123456",
|
||||
"out_authorization_no": "plfk2020042013",
|
||||
"authorization_notify_url": "https://www.weixin.qq.com/wxpay/pay.php"
|
||||
},
|
||||
"sponsor_mchid": "1900001109"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"out_bill_no": "plfk2020042013",
|
||||
"transfer_bill_no": "1330000071100999991182020050700019480001",
|
||||
"create_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"state": "ACCEPTED",
|
||||
"package_info": "affffddafdfafddffda==",
|
||||
"user_display_name": "wx_123456",
|
||||
"out_authorization_no": "plfk2020042013"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"appid": "wxf636efh567hg4356",
|
||||
"out_bill_no": "plfk2020042013",
|
||||
"transfer_scene_id": "1000",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"transfer_amount": 400000,
|
||||
"transfer_remark": "新会员开通有礼",
|
||||
"notify_url": "https://www.weixin.qq.com/wxpay/pay.php",
|
||||
"user_recv_perception": "现金奖励",
|
||||
"transfer_scene_report_infos": [
|
||||
{
|
||||
"info_type": "活动名称",
|
||||
"info_content": "新会员有礼"
|
||||
}
|
||||
],
|
||||
"authorization_id": "201202504101000123456789012",
|
||||
"sponsor_mchid": "1900001109"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"mch_id": "1900001109",
|
||||
"out_bill_no": "plfk2020042013",
|
||||
"transfer_bill_no": "1330000071100999991182020050700019480001",
|
||||
"appid": "wxf636efh567hg4356",
|
||||
"state": "SUCCESS",
|
||||
"transfer_amount": 400000,
|
||||
"transfer_remark": "新会员开通有礼",
|
||||
"fail_reason": "PAYEE_ACCOUNT_ABNORMAL",
|
||||
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
|
||||
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
|
||||
"create_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"update_time": "2015-05-20T13:29:35.120+08:00"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"out_authorization_no": "plfk2020042013",
|
||||
"appid": "102022609",
|
||||
"openid": "216BE837A39456BD6729F6F47D7C0EEE",
|
||||
"user_display_name": "wx_123456",
|
||||
"authorization_id": "201202504101000123456789012",
|
||||
"state": "TAKING_EFFECT",
|
||||
"authorize_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"close_info": {
|
||||
"close_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"close_reason": "USER_CLOSE"
|
||||
}
|
||||
}
|
||||
@@ -854,6 +854,112 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-bills/pre-transfer-with-authorization)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest()
|
||||
{
|
||||
static Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest GenerateMockRequestModel()
|
||||
{
|
||||
return new Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest()
|
||||
{
|
||||
UserName = MOCK_PLAIN_STR
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest 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.ExecuteCreateFundAppMerchantTransferBillPreTransferWithAuthorizationAsync(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.ExecuteCreateFundAppMerchantTransferBillPreTransferWithAuthorizationAsync(request);
|
||||
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-bills/transfer)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferBillTransferRequest()
|
||||
{
|
||||
static Models.CreateFundAppMerchantTransferBillTransferRequest GenerateMockRequestModel()
|
||||
{
|
||||
return new Models.CreateFundAppMerchantTransferBillTransferRequest()
|
||||
{
|
||||
UserName = MOCK_PLAIN_STR
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.CreateFundAppMerchantTransferBillTransferRequest 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.ExecuteCreateFundAppMerchantTransferBillTransferAsync(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.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
|
||||
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferToQQWalletBillRequest()
|
||||
{
|
||||
|
||||
@@ -370,6 +370,67 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([POST] /ecommerce/mch-transfer/transfer-bills/transfer)")]
|
||||
public async Task TestDecryptResponseSensitiveProperty_CreateFundAppMerchantTransferBillTransferResponse()
|
||||
{
|
||||
static Models.CreateFundAppMerchantTransferBillTransferResponse GenerateMockResponseModel(Func<string, string> encryptor)
|
||||
{
|
||||
return SetMockResponseRawStatusAsOk(new Models.CreateFundAppMerchantTransferBillTransferResponse()
|
||||
{
|
||||
UserName = encryptor.Invoke(MOCK_PLAIN_STR)
|
||||
});
|
||||
}
|
||||
|
||||
static void AssertMockResponseModel(Models.CreateFundAppMerchantTransferBillTransferResponse 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.CreateFundAppMerchantTransferBillTransferRequest();
|
||||
var response = await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(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.CreateFundAppMerchantTransferBillTransferRequest();
|
||||
var response = await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
|
||||
AssertMockResponseModel(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /ecommerce/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no})")]
|
||||
public async Task TestDecryptResponseSensitiveProperty_GetEcommerceMerchantTransferBillByTransferBillNumberResponse()
|
||||
{
|
||||
@@ -553,7 +614,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no})")]
|
||||
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no}/out-details/{out_detail_no})")]
|
||||
public async Task TestDecryptResponseSensitiveProperty_GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse()
|
||||
{
|
||||
static Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse GenerateMockResponseModel(Func<string, string> encryptor)
|
||||
|
||||
Reference in New Issue
Block a user