private void CheckResponseSign(WeChatPayResponse response, WeChatPayOptions options, bool signType = true) { if (string.IsNullOrEmpty(response.Body)) { throw new WeChatPayException("sign check fail: Body is Empty!"); } if (response.Parameters.Count == 0) { throw new WeChatPayException("sign check fail: Parameters is Empty!"); } if (response.Parameters["return_code"] == "SUCCESS") { if (!response.Parameters.TryGetValue("sign", out var sign)) { throw new WeChatPayException("sign check fail: sign is Empty!"); } var cal_sign = WeChatPaySignature.SignWithKey(response.Parameters, options.Key, signType); if (cal_sign != sign) { throw new WeChatPayException("sign check fail: check Sign and Data Fail!"); } } }
private void CheckResponseSign(WeChatPayResponse response, bool useMD5 = true, bool excludeSignType = true) { if (string.IsNullOrEmpty(response.Body)) { throw new Exception("sign check fail: Body is Empty!"); } var sign = response?.Sign; if (!response.IsError && !string.IsNullOrEmpty(sign)) { var cal_sign = WeChatPaySignature.SignWithKey(response.Parameters, Options.Key, useMD5, excludeSignType); if (cal_sign != sign) { throw new Exception("sign check fail: check Sign and Data Fail!"); } } }
private void CheckResponseSign(WeChatPayResponse response, bool useMD5 = true, bool excludeSignType = true) { if (string.IsNullOrEmpty(response.Body)) { throw new Exception("sign check fail: Body is Empty!"); } if (response.Parameters.TryGetValue("sign", out var sign)) { if (response.Parameters["return_code"] == "SUCCESS" && !string.IsNullOrEmpty(sign)) { var cal_sign = WeChatPaySignature.SignWithKey(response.Parameters, Options.Key, useMD5, excludeSignType); if (cal_sign != sign) { throw new Exception("sign check fail: check Sign and Data Fail!"); } } } }