Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public string Sign(IRequestContent content)
        {
            if (content.SignType != "RSA" && content.SignType != "RSA2")
            {
                throw new PaymentArgumentException(GateWay.Name, "sign_type", $"不支持的sign_type:{content.SignType}");
            }
            if (content.Encoding == null)
            {
                throw new PaymentArgumentException(GateWay.Name, "charset", "编码格式错误");
            }

            if (!(GateWay.MerchantConfigure is AlipayMerchantConfigure merchantConfigure))
            {
                throw new PaymentException(GateWay.Name, "商户信息错误");
            }

            return(SecurityUtiity.RSA(GetSignOrigin(content), merchantConfigure.PrivateKey, content.Encoding.BodyName, content.SignType, false));
        }