public SwiftpassPayResponseHandler(SwiftpassKey options, string xmlContent) { this.options = options; this.shopDb = ZRui.Web.BLL.DbContextFactory.ShopDb; parameters = new Hashtable(); setContent(xmlContent); //this.options = shopDb.SwiftpassKey.FirstOrDefault(r => r.ShopFlag == this.Attach); //if (this.options == null) //{ // throw new Exception("商家支付密钥未配置"); //} }
public SwiftpassPayProxy(ShopPayInfo payinfo, IPayOption payOption, ILogger _logger) : base(payOption, _logger) { // options.WftPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKF4mYjBMHkRqwNWWJ5t9sMriHPBOfMpJLUhMJE6ri28RHHEbYoRWYV7g3Lt2BZpcopoIpblcC07Kn9Mgur3/RcCAwEAAQ=="; //options.MchPrivateKey = @"MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAoXiZiMEweRGrA1ZY //nm32wyuIc8E58ykktSEwkTquLbxEccRtihFZhXuDcu3YFmlyimgiluVwLTsqf0yC //6vf9FwIDAQABAkBANuTgNOwhCby33AvsHZEn9tUSK8LvB+q4OdXFu89vEjFttOLJ //9yyACYvOjmii6e5ThqDjX1codbXuzbXE06KpAiEAztVBPzd/ZDJReOQq4raYIRhX //eYkay8ko2f1mIdiRrnMCIQDH2tyUQqiGhtHMerjKW+mgSP0KguGwpC7u1rWqHY3J //zQIgMsHs0Cm7bohWrBc6Wwa6UKzbkqzN0aLdDpn7/WRbY/cCIQC8V9O8nT042mFp //NNZlTk1T0rU1bLbIw1G/n/TABu4SmQIgH7UBuIqvA6b2O4RANl+c97PuC9+Mdmpr //TBP3JwCg5yE="; // options.NotifyUrl = "https://wxapi.91huichihuihe.com/SwiftpassPay/Notify"; //options.ReqUrl = "https://pay.swiftpass.cn/pay/gateway"; // this.options = options; this.payinfo = payinfo; this._logger = _logger; this.shopDb = ZRui.Web.BLL.DbContextFactory.ShopDb; this.swifpasskey = shopDb.SwiftpassKey.FirstOrDefault(r => r.ShopFlag == payinfo.ShopFlag && r.IsEnable); if (swifpasskey == null) { throw new Exception("商家支付密钥未配置"); } }
public SwiftpassPayRequestHandler(SwiftpassKey key) { this.key = key; parameters = new Hashtable(); }
public APIResult SetPayInfo([FromBody] SetPayInfoArgsModel args) { if (!args.shopid.HasValue) { throw new ArgumentNullException("shopid"); } var model = db.Query <ShopPayInfo>() .Where(m => !m.IsDel) .Where(m => m.ShopId == args.shopid.Value && m.PayWay == args.payway) .FirstOrDefault(); var isenablecount = db.Query <ShopPayInfo>() .Where(m => !m.IsDel) .Where(m => m.ShopId == args.shopid.Value && m.IsEnable == true).FirstOrDefault(); //PayWay payWay = Enum.Parse<PayWay>(args.payway.ToString()); if (isenablecount != null) { if (isenablecount.PayWay != args.payway && args.isenable) { throw new Exception("一个商户同时只能开启一个支付通道!"); } } //微信支付 if (args.payway == PayWay.Wechat) { if (string.IsNullOrEmpty(args.mchid)) { throw new ArgumentNullException("商户号"); } if (string.IsNullOrEmpty(args.secretkey)) { throw new ArgumentNullException("密钥"); } ExPayInfo(args, model); } else if (args.payway == PayWay.Swiftpass) { ExPayInfo(args, model); model = db.Query <ShopPayInfo>() .Where(m => !m.IsDel) .Where(m => m.ShopId == args.shopid.Value && m.PayWay == args.payway) .FirstOrDefault(); //中信支付 var swifpasskey = db.SwiftpassKey.FirstOrDefault(r => r.ShopFlag == model.ShopFlag); if (swifpasskey == null) { SwiftpassKey key = new SwiftpassKey() { ShopFlag = model.ShopFlag, ReqUrl = args.reqUrl, PublicKey = args.publicKey, PrviateKey = args.prviateKey, Notify = args.notify, IsEnable = args.isenable }; db.Add(key); db.SaveChanges(); } else { if (string.IsNullOrEmpty(args.reqUrl) || string.IsNullOrEmpty(args.publicKey) || string.IsNullOrEmpty(args.prviateKey) || string.IsNullOrEmpty(args.notify) ) { throw new Exception("配置信息必须全部配置"); } swifpasskey.ShopFlag = model.ShopFlag; swifpasskey.ReqUrl = args.reqUrl; swifpasskey.PublicKey = args.publicKey; swifpasskey.PrviateKey = args.prviateKey; swifpasskey.Notify = args.notify; swifpasskey.IsEnable = args.isenable; model.IsEnable = args.isenable; db.Update(swifpasskey); } } db.SaveChanges(); return(Success()); }