public bool Verify(IBackContent content) { if (content.SignType != "RSA" && content.SignType != "RSA2") { throw new PaymentArgumentException(GateWay.Name, "sign_type", $"不支持的sign_type:{content.SignType}"); } var chatset = string.IsNullOrEmpty(content["chatset"]) ? "utf-8" : content["chatset"]; if (!(GateWay.MerchantConfigure is AlipayMerchantConfigure merchantConfigure)) { throw new PaymentException(GateWay.Name, "商户信息错误"); } return(SecurityUtiity.RSAVerifyData(GetSignOrigin(content), content.Sign, merchantConfigure.PublicKey, chatset, content.SignType, false)); }
protected virtual string GetSignOrigin(IBackContent content) { var originBuilder = new StringBuilder(); foreach (var paramater in content.Paramaters.OrderBy(x => x.Key)) { if (paramater.Key.ToLower() == "sign") { continue; } if (paramater.Key.ToLower() == "sign_type") { continue; } originBuilder.Append($"{paramater.Key}={paramater.Value}&"); } return(originBuilder.ToString().TrimEnd('&')); }
public VerifyException(string platformName = null, IBackContent content = null, string message = null, Exception inner = null) : base(platformName, message, inner) { Content = content; }
protected VerifyException(SerializationInfo info, StreamingContext context) : base(info, context)//让基类反序列化其内定义的字段 { Content = (INotifyContent)info.GetValue("Content", typeof(INotifyContent)); }