mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-02-11 10:16:20 +08:00
feat(tenpayv3): 新增校园轻松付相关接口
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"appid": "wx8888888888888888",
|
||||
"sub_mchid": "1900000109",
|
||||
"sub_appid": "wx8888888888888888",
|
||||
"description": "中山大学-第二食堂-海鲜炒饭",
|
||||
"attach": "自定义数据",
|
||||
"out_trade_no": "121775250124070332",
|
||||
"goods_tag": "test",
|
||||
"contract_id": "2045011120563805041758214605",
|
||||
"user_id": "20200330tony",
|
||||
"amount": {
|
||||
"total": 888,
|
||||
"currency": "CNY"
|
||||
},
|
||||
"scene_info": {
|
||||
"start_time": "2017-08-26T09:43:39+08:00",
|
||||
"school_id": "18260256813396",
|
||||
"scene_type": "CANTEEN"
|
||||
},
|
||||
"device_info": {
|
||||
"device_id": "12343232",
|
||||
"device_ip": "123.12.12.123"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"mchid": "1230000109",
|
||||
"appid": "wx8888888888888888",
|
||||
"sub_mchid": "1900000109",
|
||||
"sub_appid": "wx8888888888888888",
|
||||
"out_trade_no": "201407033233368018",
|
||||
"transaction_id": "25012014070332333018",
|
||||
"trade_type": "AUTH",
|
||||
"trade_state": "SUCCESS",
|
||||
"trade_state_desc": "支付成功",
|
||||
"bank_type": "ICBC_DEBIT",
|
||||
"attach": "自定义数据",
|
||||
"success_time": "2020-03-26T10:43:39+08:00",
|
||||
"payer": {
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"sub_openid": "oUpF8uMuAJOM2pxb1Q"
|
||||
},
|
||||
"amount": {
|
||||
"total": 888,
|
||||
"payer_total": 888,
|
||||
"discount_total": 100,
|
||||
"currency": "CNY"
|
||||
},
|
||||
"device_info": {
|
||||
"device_id": "12343232",
|
||||
"device_ip": "123.12.12.123"
|
||||
},
|
||||
"promotion_detail": [
|
||||
{
|
||||
"coupon_id": "109519",
|
||||
"name": "单品惠-6",
|
||||
"scope": "GLOBALSINGLE",
|
||||
"type": "DISCOUNTCOUPON",
|
||||
"amount": 5,
|
||||
"stock_id": "931386",
|
||||
"wechatpay_contribute": 0,
|
||||
"merchant_contribute": 0,
|
||||
"other_contribute": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"contract_id": "2045011120563805041758214605",
|
||||
"mchid": "1230000109",
|
||||
"appid": "wx8888888888888888",
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"plan_id": "101164396123311331",
|
||||
"contract_status": "ADD",
|
||||
"create_time": "2017-08-26T09:43:39+08:00",
|
||||
"out_contract_code": "20190806125346"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"mchid": "1230000109",
|
||||
"appid": "wx8888888888888888",
|
||||
"sub_mchid": "1900000109",
|
||||
"sub_appid": "wx8888888888888888",
|
||||
"out_trade_no": "201407033233368018",
|
||||
"transaction_id": "25012014070332333018",
|
||||
"trade_type": "AUTH",
|
||||
"trade_state": "SUCCESS",
|
||||
"trade_state_desc": "支付成功",
|
||||
"bank_type": "ICBC_DEBIT",
|
||||
"attach": "自定义数据",
|
||||
"success_time": "2020-03-26T10:43:39+08:00",
|
||||
"payer": {
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"sub_openid": "oUpF8uMuAJOM2pxb1Q"
|
||||
},
|
||||
"amount": {
|
||||
"total": 888,
|
||||
"payer_total": 888,
|
||||
"discount_total": 100,
|
||||
"currency": "CNY"
|
||||
},
|
||||
"device_info": {
|
||||
"device_id": "12343232",
|
||||
"device_ip": "123.12.12.123"
|
||||
},
|
||||
"promotion_detail": [
|
||||
{
|
||||
"coupon_id": "109519",
|
||||
"name": "单品惠-6",
|
||||
"scope": "GLOBALSINGLE",
|
||||
"type": "DISCOUNTCOUPON",
|
||||
"amount": 5,
|
||||
"stock_id": "931386",
|
||||
"wechatpay_contribute": 0,
|
||||
"merchant_contribute": 0,
|
||||
"other_contribute": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"mchid": "1230000109",
|
||||
"appid": "wx8888888888888888",
|
||||
"sub_mchid": "1900000109",
|
||||
"sub_appid": "wx8888888888888888",
|
||||
"out_trade_no": "201407033233368018",
|
||||
"transaction_id": "25012014070332333018",
|
||||
"trade_type": "AUTH",
|
||||
"trade_state": "SUCCESS",
|
||||
"trade_state_desc": "支付成功",
|
||||
"bank_type": "ICBC_DEBIT",
|
||||
"attach": "自定义数据",
|
||||
"success_time": "2020-03-26T10:43:39+08:00",
|
||||
"payer": {
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"sub_openid": "oUpF8uMuAJOM2pxb1Q"
|
||||
},
|
||||
"amount": {
|
||||
"total": 888,
|
||||
"payer_total": 888,
|
||||
"discount_total": 100,
|
||||
"currency": "CNY"
|
||||
},
|
||||
"device_info": {
|
||||
"device_id": "12343232",
|
||||
"device_ip": "123.12.12.123"
|
||||
},
|
||||
"promotion_detail": [
|
||||
{
|
||||
"coupon_id": "109519",
|
||||
"name": "单品惠-6",
|
||||
"scope": "GLOBALSINGLE",
|
||||
"type": "DISCOUNTCOUPON",
|
||||
"amount": 5,
|
||||
"stock_id": "931386",
|
||||
"wechatpay_contribute": 0,
|
||||
"merchant_contribute": 0,
|
||||
"other_contribute": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"appid": "wx8888888888888888",
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"state": "FORBIDDEN",
|
||||
"debt_count": 2,
|
||||
"update_time": "2017-08-26T09:43:39+08:00"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"appid": "wx8888888888888888",
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"plan_id": "101164396123311331",
|
||||
"user_id": "20200330tony",
|
||||
"school_id": "18260256813396",
|
||||
"out_contract_code": "20190806125346",
|
||||
"contract_mode": "LIMIT_BANK_CARD",
|
||||
"downgrade_default_contract": false,
|
||||
"identity": {
|
||||
"real_name": "6TqLAZvNZ4AXLNHLMbjA1yKq2k5krHM09m3tCuR",
|
||||
"credential_type": "IDENTITY_CARD",
|
||||
"id_card_number": "6TqLAZvNZ4AXLNHLMbjA1yKq2k5krHM09m3tCuR"
|
||||
},
|
||||
"bank_card": {
|
||||
"bank_card_no": "6TqLAZvNZ4AXLNHLMbjA1yKq2k5krHM09m3tCuR",
|
||||
"valid_thru": "08/21",
|
||||
"phone": "j6PlFRRJ4nvGSbtDZzXbXScACvDSnIny67zk3BgT5uIbK4VfGmcjPBEk2mt5ASZ6UUHB4Gy0IZpbuanF9",
|
||||
"bank_type": "CMC"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presign_token": "0044de6c799739c2e8534b"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"contract_id": "2045011120563805041758214605",
|
||||
"mchid": "1230000109",
|
||||
"appid": "wx8888888888888888",
|
||||
"openid": "oUpF8uMuAJOM2pxb1Q",
|
||||
"plan_id": "101164396123311331",
|
||||
"contract_status": "ADD",
|
||||
"create_time": "2017-08-26T09:43:39+08:00",
|
||||
"out_contract_code": "20190806125346"
|
||||
}
|
||||
],
|
||||
"offset": 10,
|
||||
"limit": 20,
|
||||
"total_count": 1234
|
||||
}
|
||||
@@ -487,14 +487,14 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
{
|
||||
return new Models.AddEcommerceProfitSharingReceiverRequest()
|
||||
{
|
||||
EncryptedName = MOCK_PLAIN_STR
|
||||
UserName = MOCK_PLAIN_STR
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.AddEcommerceProfitSharingReceiverRequest request, Func<string, string> decryptor)
|
||||
{
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.EncryptedName!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.EncryptedName!));
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.UserName!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.UserName!));
|
||||
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
|
||||
}
|
||||
|
||||
@@ -515,6 +515,56 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /eduschoolpay/contracts/presign)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_PresignEducationSchoolPayContractRequest()
|
||||
{
|
||||
static Models.PresignEducationSchoolPayContractRequest GenerateMockRequestModel()
|
||||
{
|
||||
return new Models.PresignEducationSchoolPayContractRequest()
|
||||
{
|
||||
Identity = new Models.PresignEducationSchoolPayContractRequest.Types.Identity()
|
||||
{
|
||||
RealName = MOCK_PLAIN_STR,
|
||||
CredentialNumber = MOCK_PLAIN_STR
|
||||
},
|
||||
BankCard = new Models.PresignEducationSchoolPayContractRequest.Types.BankCard()
|
||||
{
|
||||
BankCardNumber = MOCK_PLAIN_STR,
|
||||
MobileNumber = MOCK_PLAIN_STR
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.PresignEducationSchoolPayContractRequest request, Func<string, string> decryptor)
|
||||
{
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identity!.RealName!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identity!.CredentialNumber!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.BankCard!.BankCardNumber!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.BankCard!.MobileNumber!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identity!.RealName!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identity!.CredentialNumber!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.BankCard!.BankCardNumber!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.BankCard!.MobileNumber!));
|
||||
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
|
||||
}
|
||||
|
||||
var reqA1 = GenerateMockRequestModel();
|
||||
CreateMockClientUseRSA(autoEncrypt: false).EncryptRequestSensitiveProperty(reqA1);
|
||||
AssertMockRequestModel(reqA1, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, cipher));
|
||||
|
||||
var reqA2 = GenerateMockRequestModel();
|
||||
CreateMockClientUseSM2(autoEncrypt: false).EncryptRequestSensitiveProperty(reqA2);
|
||||
AssertMockRequestModel(reqA2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
|
||||
|
||||
var reqB1 = GenerateMockRequestModel();
|
||||
await CreateMockClientUseRSA(autoEncrypt: true).ExecutePresignEducationSchoolPayContractAsync(reqB1);
|
||||
AssertMockRequestModel(reqB1, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, cipher));
|
||||
|
||||
var reqB2 = GenerateMockRequestModel();
|
||||
await CreateMockClientUseSM2(autoEncrypt: true).ExecutePresignEducationSchoolPayContractAsync(reqB2);
|
||||
AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /marketing/membercard-open/cards/{card_id}/phone-membercard/import)")]
|
||||
public async Task TestEncryptRequestSensitiveProperty_ImportMarketingMemberCardOpenCardPhoneRequest()
|
||||
{
|
||||
@@ -522,14 +572,14 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
{
|
||||
return new Models.ImportMarketingMemberCardOpenCardPhoneRequest()
|
||||
{
|
||||
EncryptedPhoneNumber = MOCK_PLAIN_STR
|
||||
MobileNumber = MOCK_PLAIN_STR
|
||||
};
|
||||
}
|
||||
|
||||
static void AssertMockRequestModel(Models.ImportMarketingMemberCardOpenCardPhoneRequest request, Func<string, string> decryptor)
|
||||
{
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.EncryptedPhoneNumber!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.EncryptedPhoneNumber!));
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.MobileNumber!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.MobileNumber!));
|
||||
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
|
||||
}
|
||||
|
||||
@@ -1083,8 +1133,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
{
|
||||
Identify = new Models.PreopenVehicleETCRequest.Types.Identify()
|
||||
{
|
||||
EncryptedRealName = MOCK_PLAIN_STR,
|
||||
EncryptedCredentialNumber = MOCK_PLAIN_STR
|
||||
RealName = MOCK_PLAIN_STR,
|
||||
CredentialNumber = MOCK_PLAIN_STR
|
||||
},
|
||||
BankCardNumber = MOCK_PLAIN_STR
|
||||
};
|
||||
@@ -1092,11 +1142,11 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
|
||||
static void AssertMockRequestModel(Models.PreopenVehicleETCRequest request, Func<string, string> decryptor)
|
||||
{
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identify!.EncryptedRealName!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identify!.EncryptedCredentialNumber!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identify!.RealName!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.Identify!.CredentialNumber!);
|
||||
Assert.NotEqual(MOCK_PLAIN_STR, request.BankCardNumber!);
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identify!.EncryptedRealName!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identify!.EncryptedCredentialNumber!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identify!.RealName!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.Identify!.CredentialNumber!));
|
||||
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.BankCardNumber!));
|
||||
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user