/// <summary> /// 获取网关 /// </summary> /// <param name="gateways">网关列表</param> /// <returns></returns> public static BaseGateway GetGateway(IGateways gateways) { var gatewayData = ReadNotifyData(); BaseGateway gateway = null; foreach (var item in gateways.GetList()) { if (ExistParameter(item.NotifyVerifyParameter, gatewayData)) { if (item.Merchant.AppId == gatewayData .GetStringValue(item.NotifyVerifyParameter.FirstOrDefault())) { gateway = item; break; } } } if (gateway is null) { gateway = new NullGateway(); } gateway.GatewayData = gatewayData; return(gateway); }
private DGateway GetGateway() { var gatewayData = ReadNotifyData(); _logger.Info($"orginal:{gatewayData.OriginalData}"); _logger.Info($"json:{gatewayData.ToJson()}"); DGateway gateway = null; foreach (var item in _gateways.GetList()) { if (ExistParameter(item.NotifyVerifyParameter, gatewayData)) { if (item.Merchant.AppId == gatewayData .GetValue <string>(item.NotifyVerifyParameter.FirstOrDefault())) { gateway = item; break; } } } if (gateway is null) { gateway = new NullGateway(); } gateway.GatewayData = gatewayData; return(gateway); }
private IGateway GetGatewayByStore(int storeId) { var gatewayList = _gateways.GetList() .Where(a => a is WechatpayGateway && (a.Merchant.StoreId == storeId || a.Merchant.StoreId == 0)) .OrderByDescending(a => a.Merchant.StoreId) .ToList(); var gateway = gatewayList.Count > 0 ? gatewayList[0] : throw new GatewayException("找不到指定网关"); return(gateway); }
/// <summary> /// 获取网关 /// </summary> /// <param name="gateways">网关列表</param> /// <returns></returns> public static GatewayBase GetGateway(IGateways gateways) { var gatewayData = ReadNotifyData(); GatewayBase gateway = null; foreach (var item in gateways.GetList()) { if (ExistParameter(item.NotifyVerifyParameter, gatewayData)) { gateway = item; break; } } if (gateway is null) { gateway = new NullGateway(); } gateway.GatewayData = gatewayData; return(gateway); }