diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecuteMerchantOperateExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecuteMerchantOperateExtensions.cs new file mode 100644 index 00000000..6ece06e9 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecuteMerchantOperateExtensions.cs @@ -0,0 +1,71 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Flurl.Http; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3 +{ + /// + /// 为 提供电商收付通注销后提现相关的 API 扩展方法。 + /// + public static class WechatTenpayClientExecuteMerchantOperateExtensions + { + /// + /// 异步调用 [POST] /mch_operate/risk/withdrawl-apply 接口。 + /// REF: https://pay.weixin.qq.com/docs/partner/apis/withdrawal-apply/withdrawal-apply/submit-apply.html + /// + /// + /// + /// + /// + public static async Task ExecuteCreateMerchantOperateRiskWithdrawlApplyAsync(this WechatTenpayClient client, Models.CreateMerchantOperateRiskWithdrawlApplyRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Post, "mch_operate", "risk", "withdrawl-apply"); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [GET] /mch_operate/risk/withdrawl-apply/out-request-no/{out_request_no} 接口。 + /// REF: https://pay.weixin.qq.com/docs/partner/apis/withdrawal-apply/withdrawal-apply/get-apply-by-out-request-no.html + /// + /// + /// + /// + /// + public static async Task ExecuteGetMerchantOperateRiskWithdrawlApplyByOutRequestNumberAsync(this WechatTenpayClient client, Models.GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Get, "mch_operate", "risk", "withdrawl-apply", "out-request-no", request.OutRequestNumber); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [GET] /mch_operate/risk/withdrawl-apply/applyment-id/{applyment_id} 接口。 + /// REF: https://pay.weixin.qq.com/docs/partner/apis/withdrawal-apply/withdrawal-apply/get-apply-by-applyment-id.html + /// + /// + /// + /// + /// + public static async Task ExecuteGetMerchantOperateRiskWithdrawlApplyByApplymentIdAsync(this WechatTenpayClient client, Models.GetMerchantOperateRiskWithdrawlApplyByApplymentIdRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Get, "mch_operate", "risk", "withdrawl-apply", "applyment-id", request.ApplymentId); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.cs new file mode 100644 index 00000000..0f7431a6 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.cs @@ -0,0 +1,222 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [POST] /mch_operate/risk/withdrawl-apply 接口的请求。 + /// + [WechatTenpaySensitive] + public class CreateMerchantOperateRiskWithdrawlApplyRequest : WechatTenpayRequest + { + public static class Types + { + public class PayeeInfo + { + public static class Types + { + public class BankAccount + { + /// + /// 获取或设置开户名称(需使用平台公钥/证书加密)。 + /// + [Newtonsoft.Json.JsonProperty("account_name")] + [System.Text.Json.Serialization.JsonPropertyName("account_name")] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)] + public string AccountName { get; set; } = string.Empty; + + /// + /// 获取或设置银行账号(需使用平台公钥/证书加密)。 + /// + [Newtonsoft.Json.JsonProperty("account_number")] + [System.Text.Json.Serialization.JsonPropertyName("account_number")] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)] + public string AccountNumber { get; set; } = string.Empty; + + /// + /// 获取或设置开户银行。 + /// + [Newtonsoft.Json.JsonProperty("account_bank")] + [System.Text.Json.Serialization.JsonPropertyName("account_bank")] + public string AccountBank { get; set; } = string.Empty; + + /// + /// 获取或设置开户银行联行号。与字段 二选一。 + /// + [Newtonsoft.Json.JsonProperty("bank_branch_id")] + [System.Text.Json.Serialization.JsonPropertyName("bank_branch_id")] + public string? BankBranchId { get; set; } + + /// + /// 获取或设置开户银行全称(含支行)。与字段 二选一。 + /// + [Newtonsoft.Json.JsonProperty("bank_name")] + [System.Text.Json.Serialization.JsonPropertyName("bank_name")] + public string? BankBranchName { get; set; } + } + + public class Identity + { + /// + /// 获取或设置证件类型。 + /// + [Newtonsoft.Json.JsonProperty("id_doc_type")] + [System.Text.Json.Serialization.JsonPropertyName("id_doc_type")] + public string? IdentityType { get; set; } + + /// + /// 获取或设置证件姓名(需使用平台公钥/证书加密)。 + /// + [Newtonsoft.Json.JsonProperty("identification_name")] + [System.Text.Json.Serialization.JsonPropertyName("identification_name")] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)] + public string? IdName { get; set; } + + /// + /// 获取或设置证件号码(需使用平台公钥/证书加密)。 + /// + [Newtonsoft.Json.JsonProperty("identification_no")] + [System.Text.Json.Serialization.JsonPropertyName("identification_no")] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)] + [WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)] + public string? IdNumber { get; set; } + } + } + + /// + /// 获取或设置出款子账户类型。 + /// + [Newtonsoft.Json.JsonProperty("account_type")] + [System.Text.Json.Serialization.JsonPropertyName("account_type")] + public string AccountType { get; set; } = string.Empty; + + /// + /// 获取或设置银行账户信息。 + /// + [Newtonsoft.Json.JsonProperty("bank_account_info")] + [System.Text.Json.Serialization.JsonPropertyName("bank_account_info")] + public Types.BankAccount BankAccount { get; set; } = new Types.BankAccount(); + + /// + /// 获取或设置收款人身份证件信息。 + /// + [Newtonsoft.Json.JsonProperty("identity_info")] + [System.Text.Json.Serialization.JsonPropertyName("identity_info")] + public Types.Identity? Identity { get; set; } + + } + + public class Proof + { + public static class Types + { + public class PayeeProof + { + /// + /// 获取或设置证明材料 ID。 + /// + [Newtonsoft.Json.JsonProperty("proof_media_type")] + [System.Text.Json.Serialization.JsonPropertyName("proof_media_type")] + public string ProofId { get; set; } = string.Empty; + + /// + /// 获取或设置证明材料 MediaId。 + /// + [Newtonsoft.Json.JsonProperty("proof_media")] + [System.Text.Json.Serialization.JsonPropertyName("proof_media")] + public string ProofMediaId { get; set; } = string.Empty; + } + } + + /// + /// 获取或设置申请证明材料表。 + /// + [Newtonsoft.Json.JsonProperty("proof_payee_media")] + [System.Text.Json.Serialization.JsonPropertyName("proof_payee_media")] + public IList? PayeeProofList { get; set; } + } + + public class AdditionalInformation + { + /// + /// 获取或设置补充材料 MediaId 列表。 + /// + [Newtonsoft.Json.JsonProperty("additional_media")] + [System.Text.Json.Serialization.JsonPropertyName("additional_media")] + public IList? AdditionalMaterialMediaIdList { get; set; } + } + } + + /// + /// 获取或设置从业机构特约商户号 。 + /// + [Newtonsoft.Json.JsonProperty("sub_mchid")] + [System.Text.Json.Serialization.JsonPropertyName("sub_mchid")] + public string SubMerchantId { get; set; } = string.Empty; + + /// + /// 获取或设置商户提现申请单号。 + /// + [Newtonsoft.Json.JsonProperty("out_request_no")] + [System.Text.Json.Serialization.JsonPropertyName("out_request_no")] + public string OutRequestNumber { get; set; } = string.Empty; + + /// + /// 获取或设置出款子账户类型。 + /// + [Newtonsoft.Json.JsonProperty("out_account_type")] + [System.Text.Json.Serialization.JsonPropertyName("out_account_type")] + public string OutAccountType { get; set; } = string.Empty; + + /// + /// 获取或设置提现金额(单位:分)。 + /// + [Newtonsoft.Json.JsonProperty("amount")] + [System.Text.Json.Serialization.JsonPropertyName("amount")] + public int Amount { get; set; } + + /// + /// 获取或设置收款对象类型。 + /// + [Newtonsoft.Json.JsonProperty("payee_type")] + [System.Text.Json.Serialization.JsonPropertyName("payee_type")] + public string PayeeType { get; set; } = string.Empty; + + /// + /// 获取或设置收款对象对应的商户号。 + /// + [Newtonsoft.Json.JsonProperty("payee_mchid")] + [System.Text.Json.Serialization.JsonPropertyName("payee_mchid")] + public string? PayeeMerchantId { get; set; } + + /// + /// 获取或设置收款账号信息。 + /// + [Newtonsoft.Json.JsonProperty("payee_info")] + [System.Text.Json.Serialization.JsonPropertyName("payee_info")] + public Types.PayeeInfo PayeeInfo { get; set; } = new Types.PayeeInfo(); + + /// + /// 获取或设置付款申请证明信息。 + /// + [Newtonsoft.Json.JsonProperty("proof_media_list")] + [System.Text.Json.Serialization.JsonPropertyName("proof_media_list")] + public Types.Proof? Proof { get; set; } + + /// + /// 获取或设置补充材料信息。 + /// + [Newtonsoft.Json.JsonProperty("additional_materials")] + [System.Text.Json.Serialization.JsonPropertyName("additional_materials")] + public Types.AdditionalInformation? AdditionalInformation { get; set; } + + /// + /// 获取或设置备注。 + /// + [Newtonsoft.Json.JsonProperty("remark")] + [System.Text.Json.Serialization.JsonPropertyName("remark")] + public string? Remark { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.cs new file mode 100644 index 00000000..6d98681c --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [POST] /mch_operate/risk/withdrawl-apply 接口的响应。 + /// + public class CreateMerchantOperateRiskWithdrawlApplyResponse : WechatTenpayResponse + { + /// + /// 获取或设置商户提现申请单号。 + /// + [Newtonsoft.Json.JsonProperty("out_request_no")] + [System.Text.Json.Serialization.JsonPropertyName("out_request_no")] + public string OutRequestNumber { get; set; } = default!; + + /// + /// 获取或设置提现申请单号。 + /// + [Newtonsoft.Json.JsonProperty("applyment_id")] + [System.Text.Json.Serialization.JsonPropertyName("applyment_id")] + public string ApplymentId { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdRequest.cs new file mode 100644 index 00000000..2d5e6656 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /mch_operate/risk/withdrawl-apply/applyment-id/{applyment_id} 接口的请求。 + /// + public class GetMerchantOperateRiskWithdrawlApplyByApplymentIdRequest : WechatTenpayRequest + { + /// + /// 获取或设置提现申请单号。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ApplymentId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.cs new file mode 100644 index 00000000..a81a20a4 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /mch_operate/risk/withdrawl-apply/applyment-id/{applyment_id} 接口的响应。 + /// + public class GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse : WechatTenpayResponse + { + public static class Types + { + public class WithdrawApplyment : GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.Types.WithdrawApplyment + { + } + } + + /// + /// 获取或设置提现申请单信息。 + /// + [Newtonsoft.Json.JsonProperty("withdrawl_apply")] + [System.Text.Json.Serialization.JsonPropertyName("withdrawl_apply")] + public Types.WithdrawApplyment WithdrawApplyment { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberRequest.cs new file mode 100644 index 00000000..83869f44 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /mch_operate/risk/withdrawl-apply/out-request-no/{out_request_no} 接口的请求。 + /// + public class GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberRequest : WechatTenpayRequest + { + /// + /// 获取或设置商户提现申请单号。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string OutRequestNumber { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.cs new file mode 100644 index 00000000..eb58087d --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.cs @@ -0,0 +1,60 @@ +using System; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /mch_operate/risk/withdrawl-apply/out-request-no/{out_request_no} 接口的响应。 + /// + public class GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse : WechatTenpayResponse + { + public static class Types + { + public class WithdrawApplyment + { + /// + /// 获取或设置商户提现申请单号。 + /// + [Newtonsoft.Json.JsonProperty("out_request_no")] + [System.Text.Json.Serialization.JsonPropertyName("out_request_no")] + public string OutRequestNumber { get; set; } = default!; + + /// + /// 获取或设置提现申请单号。 + /// + [Newtonsoft.Json.JsonProperty("applyment_id")] + [System.Text.Json.Serialization.JsonPropertyName("applyment_id")] + public string ApplymentId { get; set; } = default!; + + /// + /// 获取或设置申请单状态。 + /// + [Newtonsoft.Json.JsonProperty("state")] + [System.Text.Json.Serialization.JsonPropertyName("state")] + public string State { get; set; } = default!; + + /// + /// 获取或设置失败原因。 + /// + [Newtonsoft.Json.JsonProperty("fail_reason")] + [System.Text.Json.Serialization.JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + + /// + /// 获取或设置最后更新时间。 + /// + [Newtonsoft.Json.JsonProperty("modify_time")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))] + [System.Text.Json.Serialization.JsonPropertyName("modify_time")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))] + public DateTimeOffset? ModifyTime { get; set; } + } + } + + /// + /// 获取或设置提现申请单信息。 + /// + [Newtonsoft.Json.JsonProperty("withdrawl_apply")] + [System.Text.Json.Serialization.JsonPropertyName("withdrawl_apply")] + public Types.WithdrawApplyment WithdrawApplyment { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.json new file mode 100644 index 00000000..4f6e32ac --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyRequest.json @@ -0,0 +1,37 @@ +{ + "sub_mchid": "1900000109", + "out_account_type": "BASIC_ACCOUNT", + "amount": 101, + "out_request_no": "2019061122222222122", + "payee_type": "CONTRIBUTION_MERCHANT", + "payee_mchid": "1900000109", + "payee_info": { + "account_type": "ACCOUNT_TYPE_CORPORATE", + "bank_account_info": { + "account_name": "AOZdYGISxo4y44/UgZ69bdu9X+tfMUJ9dl+LetjM45/zMbrYu+wWZ8gn4CTdo+D/m9MrPg+V4sm73oxqdQu/hj7aWyDl4GQtPXVdaztB9jVbVZh3QFzV+BEmytMNQp9dt1uWJktlfdDdLR3AMWyMB377xd+m9bSr/ioDTzagEcGe+vLYiKrzcroQv3OR0p3ppFYoQ3IfYeU/04S4t9rNFL+kyblK2FCCqQ11NdbbHoCrJc7NV4oASq6ZFonjTtgjjgKsadIKHXtb3JZKGZjduGdtkRJJp0/0eow96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw==", + "account_bank": "工商银行", + "bank_branch_id": "402713354941", + "bank_name": "施秉县农村信用合作联社城关信用社", + "account_number": "d+xT+MQCvrLHUVDWv/8MR/dB7TkXM2YYZlokmXzFsWs35NXUot7C0NcxIrUF5FnxqCJHkNgKtxa6RxEYyba1+VBRLnqKG2fSy/Y5qDN08Ej9zHCwJjq52Wg1VG8MRugli9YMI1fI83KGBxhuXyemgS/hqFKsfYGiOkJqjTUpgY5VqjtL2N4l4z11T0ECB/aSyVXUysOFGLVfSrUxMPZy6jWWYGvT1+4P633f+R+ki1gT4WF/2KxZOYmli385ZgVhcR30mr4/G3HBcxi13zp7FnEeOsLlvBmI1PHN4C7Rsu3WL8sPndjXTd75kPkyjqnoMRrEEaYQE8ZRGYoeorwC+w==" + }, + "identity_info": { + "id_doc_type": "IDENTIFICATION_TYPE_IDCARD", + "identification_name": "pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+F6mfjbzQIzfb3HHLEjZ4YiR/cJiCrZxnAqi+pjeKIEdkwzXRAI7FUhrfPK3SNjaBTEu9GmsugMIA9r3x887Q+ODuC8HH2nzAn7NGpE/e3yiHgWhk0ps5k5DP/2qIdGdONoDzZelrxCl/NWWNUyB93K9F+jC1JX2IMttdY+aQ6zBlw0xnOiNW6Hzy7UtC+xriudjD5APomty7/mYNxLMpRSvWKIjOv/69bDnuC4EL5Kz4jBHLiCyOb+tI0m2qhZ9evAM+Jv1z0NVa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg==", + "identification_no": "AOZdYGISxo4y44/UgZ69bdu9X+tfMUJ9dl+LetjM45/zMbrYu+wWZ8gn4CTdo+D/m9MrPg+V4sm73oxqdQu/hj7aWyDl4GQtPXVdaztB9jVbVZh3QFzV+BEmytMNQp9dt1uWJktlfdDdLR3AMWyMB377xd+m9bSr/ioDTzagEcGe+vLYiKrzcroQv3OR0p3ppFYoQ3IfYeU/04S4t9rNFL+kyblK2FCCqQ11NdbbHoCrJc7NV4oASq6ZFonjTtgjjgKsadIKHXtb3JZKGZjduGdtkRJJp0/0eow96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw==" + } + }, + "proof_media_list": { + "proof_payee_media": [ + { + "proof_media_type": "WECHAT_PAY_WITHDRAWAL_APPLICATION_TYPE_1", + "proof_media": "jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ" + } + ] + }, + "additional_materials": { + "additional_media": [ + "jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ" + ] + }, + "remark": "特殊理由" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.json new file mode 100644 index 00000000..75d9446c --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/CreateMerchantOperateRiskWithdrawlApplyResponse.json @@ -0,0 +1,4 @@ +{ + "applyment_id": "20220101332222", + "out_request_no": "1234567" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.json new file mode 100644 index 00000000..f873ec1d --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByApplymentIdResponse.json @@ -0,0 +1,9 @@ +{ + "withdrawl_apply": { + "applyment_id": "20220101332222", + "out_request_no": "1234567", + "state": "SUBMITTED", + "fail_reason": "银行卡信息有误", + "modify_time": "2015-05-20T13:29:35+08:00" + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.json new file mode 100644 index 00000000..f873ec1d --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/MerchantOperate/GetMerchantOperateRiskWithdrawlApplyByOutRequestNumberResponse.json @@ -0,0 +1,9 @@ +{ + "withdrawl_apply": { + "applyment_id": "20220101332222", + "out_request_no": "1234567", + "state": "SUBMITTED", + "fail_reason": "银行卡信息有误", + "modify_time": "2015-05-20T13:29:35+08:00" + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/TestCase_RequestEncryptionTests.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/TestCase_RequestEncryptionTests.cs index 7ad9d5bf..1cad0632 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/TestCase_RequestEncryptionTests.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/TestCase_RequestEncryptionTests.cs @@ -27,13 +27,16 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests { return new Models.ModifyApplyForSubMerchantSettlementRequest() { + AccountName = MOCK_PLAIN_STR, AccountNumber = MOCK_PLAIN_STR }; } static void AssertMockRequestModel(Models.ModifyApplyForSubMerchantSettlementRequest request, Func decryptor) { + Assert.NotEqual(MOCK_PLAIN_STR, request.AccountName!); Assert.NotEqual(MOCK_PLAIN_STR, request.AccountNumber!); + Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.AccountName!)); Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.AccountNumber!)); Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true); } @@ -547,6 +550,59 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher)); } + [Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /mch_operate/risk/withdrawl-apply)")] + public async Task TestEncryptRequestSensitiveProperty_CreateMerchantOperateRiskWithdrawlApplyRequest() + { + static Models.CreateMerchantOperateRiskWithdrawlApplyRequest GenerateMockRequestModel() + { + return new Models.CreateMerchantOperateRiskWithdrawlApplyRequest() + { + PayeeInfo = new Models.CreateMerchantOperateRiskWithdrawlApplyRequest.Types.PayeeInfo() + { + BankAccount = new Models.CreateMerchantOperateRiskWithdrawlApplyRequest.Types.PayeeInfo.Types.BankAccount() + { + AccountName = MOCK_PLAIN_STR, + AccountNumber = MOCK_PLAIN_STR + }, + Identity = new Models.CreateMerchantOperateRiskWithdrawlApplyRequest.Types.PayeeInfo.Types.Identity() + { + IdName = MOCK_PLAIN_STR, + IdNumber = MOCK_PLAIN_STR, + } + } + }; + } + + static void AssertMockRequestModel(Models.CreateMerchantOperateRiskWithdrawlApplyRequest request, Func decryptor) + { + Assert.NotEqual(MOCK_PLAIN_STR, request.PayeeInfo!.BankAccount!.AccountName); + Assert.NotEqual(MOCK_PLAIN_STR, request.PayeeInfo!.BankAccount!.AccountNumber); + Assert.NotEqual(MOCK_PLAIN_STR, request.PayeeInfo!.Identity!.IdName!); + Assert.NotEqual(MOCK_PLAIN_STR, request.PayeeInfo!.Identity!.IdNumber!); + Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.PayeeInfo!.BankAccount!.AccountName)); + Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.PayeeInfo!.BankAccount!.AccountNumber)); + Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.PayeeInfo!.Identity!.IdName!)); + Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.PayeeInfo!.Identity!.IdNumber!)); + 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).ExecuteCreateMerchantOperateRiskWithdrawlApplyAsync(reqB1); + AssertMockRequestModel(reqB1, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, cipher)); + + var reqB2 = GenerateMockRequestModel(); + await CreateMockClientUseSM2(autoEncrypt: true).ExecuteCreateMerchantOperateRiskWithdrawlApplyAsync(reqB2); + AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher)); + } + [Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /merchants)")] public async Task TestEncryptRequestSensitiveProperty_AddHKSubMerchantRequest() {