Ejemplo n.º 1
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 <IGlobalAlipaySettings> GlobalAlipayConfig(Action <string, string> logAction, IIocManager iocManager, IConfigurationRoot config, ISettingManager settingManager)
        {
            #region 支付宝支付
            IGlobalAlipaySettings alipaySettings = null;
            if (Convert.ToBoolean(await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.IsActive)))
            {
                alipaySettings = new GlobalAlipaySettings
                {
                    Key        = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Key),
                    Partner    = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Partner),
                    Gatewayurl = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Gatewayurl),
                    Notify     = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Notify),
                    ReturnUrl  = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.ReturnUrl),
                    Currency   = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Currency),
                };
                var splitFundSettingsString =
                    await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.SplitFundSettings);

                if (!splitFundSettingsString.IsNullOrWhiteSpace())
                {
                    alipaySettings.SplitFundInfo = JsonConvert.DeserializeObject <List <SplitFundSettingInfoDto> >(splitFundSettingsString);
                }
            }
            else if (!config["GlobalAlipay:IsEnabled"].IsNullOrWhiteSpace() && Convert.ToBoolean(config["Alipay:IsEnabled"]))
            {
                alipaySettings = new GlobalAlipaySettings
                {
                    Key        = config["GlobalAlipay:Key"],
                    Partner    = config["GlobalAlipay:Partner"],
                    Gatewayurl = config["GlobalAlipay:Gatewayurl"],
                    Notify     = config["GlobalAlipay:Notify"],
                    ReturnUrl  = config["GlobalAlipay:ReturnUrl"],
                    Currency   = config["GlobalAlipay:Currency"],
                };
                var splitFundSettingsString = config["GlobalAlipay:SplitFundInfo"];
                if (!splitFundSettingsString.IsNullOrWhiteSpace())
                {
                    alipaySettings.SplitFundInfo = JsonConvert.DeserializeObject <List <SplitFundSettingInfoDto> >(splitFundSettingsString);
                }
            }

            if (alipaySettings != null)
            {
                GlobalAlipayBuilder.Create()
                .WithLoggerAction(logAction)
                .RegisterGetPayConfigFunc(() => alipaySettings).Build();

                //注册支付宝支付API
                if (!iocManager.IsRegistered <IGlobalAlipayAppService>())
                {
                    iocManager.Register <IGlobalAlipayAppService, GlobalAlipayAppService>(DependencyLifeStyle.Transient);
                }
            }
            #endregion
            return(alipaySettings);
        }
Ejemplo n.º 2
0
        public override async Task Build(Action <string, string> logAction)
        {
            //注册支付API
            if (IocManager.IsRegistered <IGlobalAlipayAppService>())
            {
                return;
            }

            GlobalAlipayBuilder.Create()
            .WithLoggerAction(logAction)
            .RegisterGetPayConfigFunc(() => GetConfigFromConfigOrSettingsByKey <GlobalAlipaySettings>().Result).Build();

            IocManager.Register <IGlobalAlipayAppService, GlobalAlipayAppService>(DependencyLifeStyle.Transient);
            await Task.FromResult(0);
        }