public override async Task Build(Action <string, string> logAction) { //注册支付API if (IocManager.IsRegistered <IAlipayAppService>()) { return; } AlipayBuilder.Create() .WithLoggerAction(logAction) .RegisterGetPayConfigFunc(() => GetConfigFromConfigOrSettingsByKey <AlipaySettings>().Result).Build(); IocManager.Register <IAlipayAppService, AlipayAppService>(DependencyLifeStyle.Transient); await Task.FromResult(0); }
/// <summary> /// 支付宝支付配置 /// </summary> /// <param name="logAction"></param> /// <param name="iocManager"></param> /// <param name="config"></param> /// <param name="settingManager"></param> /// <returns></returns> private static async Task <AlipaySettings> AlipayConfig(Action <string, string> logAction, IIocManager iocManager, IConfigurationRoot config, ISettingManager settingManager) { #region 支付宝支付 AlipaySettings alipaySettings = null; if (Convert.ToBoolean(await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.IsActive))) { alipaySettings = new AlipaySettings { AlipayPublicKey = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.AlipayPublicKey), AppId = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.AppId), Uid = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.Uid), PrivateKey = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.PrivateKey), }; var charSet = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.CharSet); if (!charSet.IsNullOrWhiteSpace()) { alipaySettings.CharSet = charSet; } var gatewayurl = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.Gatewayurl); if (!gatewayurl.IsNullOrWhiteSpace()) { alipaySettings.Gatewayurl = gatewayurl; } var notify = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.Notify); if (!notify.IsNullOrWhiteSpace()) { alipaySettings.Notify = notify; } var signType = await settingManager.GetSettingValueAsync(AppSettings.AliPayManagement.SignType); if (!signType.IsNullOrWhiteSpace()) { alipaySettings.SignType = signType; } } else if (!config["Alipay:IsEnabled"].IsNullOrWhiteSpace() && Convert.ToBoolean(config["Alipay:IsEnabled"])) { alipaySettings = new AlipaySettings { AlipayPublicKey = config["Alipay:PublicKey"], AppId = config["Alipay:AppId"], Uid = config["Alipay:Uid"], PrivateKey = config["Alipay:PrivateKey"] }; if (!config["Alipay:CharSet"].IsNullOrWhiteSpace()) { alipaySettings.CharSet = config["Alipay:CharSet"]; } if (!config["Alipay:Gatewayurl"].IsNullOrWhiteSpace()) { alipaySettings.Gatewayurl = config["Alipay:Gatewayurl"]; } if (!config["Alipay:Notify"].IsNullOrWhiteSpace()) { alipaySettings.Notify = config["Alipay:Notify"]; } if (!config["Alipay:SignType"].IsNullOrWhiteSpace()) { alipaySettings.SignType = config["Alipay:SignType"]; } } if (alipaySettings != null) { AlipayBuilder.Create() .WithLoggerAction(logAction) .RegisterGetPayConfigFunc(() => alipaySettings).Build(); //注册支付宝支付API if (!iocManager.IsRegistered <IAlipayAppService>()) { iocManager.Register <IAlipayAppService, AlipayAppService>(DependencyLifeStyle.Transient); } } #endregion return(alipaySettings); }