Пример #1
0
        public void SetOption(IAlipayOptions options)
        {
            if (options == null)
            {
                throw new ArgumentException(nameof(options));
            }

            //SignType私钥检查
            if (string.IsNullOrEmpty(options.SignType))
            {
                throw new Exception("您的支付宝配置未能通过检查,详细信息:签名类型未指定!");
            }

            //RSA私钥检查
            if (string.IsNullOrEmpty(options.PrivateKey))
            {
                throw new Exception("您的支付宝配置未能通过检查,详细信息:未能获取到商户私钥!");
            }

            //RSA私钥格式检查
            RSA rsaCsp = AlipaySignature.LoadCertificateString(options.PrivateKey, options.SignType);

            if (rsaCsp == null)
            {
                throw new Exception("您的支付宝配置未能通过检查,详细信息:商户私钥格式错误,未能导入!");
            }

            this.Uid             = options.Uid;
            this.AlipayPublicKey = options.AlipayPublicKey;
            this.AppId           = options.AppId;
            this.CharSet         = options.CharSet;
            this.Gatewayurl      = options.Gatewayurl;
            this.PrivateKey      = options.PrivateKey;
            this.SignType        = options.SignType;
        }
Пример #2
0
 public AlipayService(IOptions <AlipayOptions> alipayOptions)
 {
     Options    = alipayOptions.Value;
     _aopClient = new DefaultAopClient(Options.Gatewayurl, Options.AppId, Options.PrivateKey, "json", "1.0",
                                       Options.SignType, Options.AlipayPublicKey, Options.CharSet, Options.IsKeyFromFile);
 }