diff --git a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayClient.cs b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayClient.cs index 1ca27cd18..e9dacac2c 100644 --- a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayClient.cs +++ b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayClient.cs @@ -265,7 +265,7 @@ private async Task CheckResponseSignAsync(WeChatPayHeaders headers, string body, throw new WeChatPayException($"sign check fail: {nameof(headers.Signature)} is empty!"); } - if (headers.Serial.StartsWith("PUB_KEY_ID_")) // 微信支付公钥 + if (headers.Serial.StartsWith(WeChatPayConsts.WeChatPayPublicKeyIdPrefix)) // 微信支付公钥 { if (!string.IsNullOrEmpty(options.WeChatPayPublicKeyId) && headers.Serial == options.WeChatPayPublicKeyId) { diff --git a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyClient.cs b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyClient.cs index 77bbfcff7..b6df46fb4 100644 --- a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyClient.cs +++ b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyClient.cs @@ -114,7 +114,7 @@ private async Task CheckNotifySignAsync(WeChatPayHeaders headers, string body, W throw new WeChatPayException("sign check fail: body is empty!"); } - if(headers.Serial.StartsWith("PUB_KEY_ID_")) // 微信支付公钥 + if(headers.Serial.StartsWith(WeChatPayConsts.WeChatPayPublicKeyIdPrefix)) // 微信支付公钥 { if (!string.IsNullOrEmpty(options.WeChatPayPublicKeyId) && headers.Serial == options.WeChatPayPublicKeyId) { diff --git a/src/Essensoft.Paylink.WeChatPay/WeChatPayConsts.cs b/src/Essensoft.Paylink.WeChatPay/WeChatPayConsts.cs index 753a61f68..ad7cfad93 100644 --- a/src/Essensoft.Paylink.WeChatPay/WeChatPayConsts.cs +++ b/src/Essensoft.Paylink.WeChatPay/WeChatPayConsts.cs @@ -41,5 +41,7 @@ public class WeChatPayConsts public const string Wechatpay_Timestamp = "Wechatpay-Timestamp"; public const string Wechatpay_Nonce = "Wechatpay-Nonce"; public const string Wechatpay_Signature = "Wechatpay-Signature"; + + public const string WeChatPayPublicKeyIdPrefix = "PUB_KEY_ID_"; } }