Example #1
0
        //public static void AddPay(this IServiceCollection services, Action<AlipayConfig> aliPaySetupAction = null, Action<WechatpayConfig> wechatPaySetupAction = null)
        //{
        //    services.AddAliPay(aliPaySetupAction);
        //    services.AddWechatPay(wechatPaySetupAction);
        //    services.AddPayService();
        //}

        //public static void AddPay<TWechatpayConfigProvider, TAlipayConfigProvider>(this IServiceCollection services) where TWechatpayConfigProvider : class, IWechatpayConfigProvider where TAlipayConfigProvider : class, IAlipayConfigProvider
        //{
        //    //services.AddAliPay<TAlipayConfigProvider>();
        //    services.AddWechatPay<TWechatpayConfigProvider>();
        //    services.AddPayService();
        //}

        private static void AddPayService(this IServiceCollection services, PayOriginType payOriginType)
        {
            AddPayService(services, new List <PayOriginType>()
            {
                payOriginType
            });
        }
Example #2
0
        /// <summary>
        /// 注册阿里支付
        /// </summary>
        /// <param name="services"></param>
        /// <param name="setupAction"></param>
        //public static void AddAliPay(this IServiceCollection services, Action<AlipayConfig> setupAction = null)
        //{
        //    var alipayConfig = new AlipayConfig();
        //    setupAction?.Invoke(alipayConfig);
        //    services.AddSingleton<IAlipayConfigProvider>(new AlipayConfigProvider(alipayConfig));
        //    services.TryAddScoped<IAlipayNotifyService, AlipayNotifyService>();
        //    services.TryAddScoped<IAlipayReturnService, AlipayReturnService>();
        //    services.AddPayService(PayOriginType.AliPay);
        //}

        /// <summary>
        /// 注册阿里支付
        /// </summary>
        /// <typeparam name="TAlipayConfigProvider"></typeparam>
        /// <param name="services"></param>
        //public static void AddAliPay<TAlipayConfigProvider>(this IServiceCollection services) where TAlipayConfigProvider : class, IAlipayConfigProvider
        //{
        //    services.AddSingleton<IAlipayConfigProvider, TAlipayConfigProvider>();
        //    services.TryAddScoped<IAlipayNotifyService, AlipayNotifyService>();
        //    services.TryAddScoped<IAlipayReturnService, AlipayReturnService>();
        //    services.AddPayService(PayOriginType.AliPay);
        //}
        /// <summary>
        /// 注册微信支付
        /// </summary>
        /// <param name="services"></param>
        /// <param name="setupAction"></param>
        //public static IServiceCollection AddWechatPay(this IServiceCollection services, Action<IDictionary<string, WechatPayConfig>> action = null)
        //{
        //    var WechatPayConfig = new WechatPayConfig();
        //    setupAction?.Invoke(WechatPayConfig);
        //    services.AddHttpClient("wechat", WechatPayConfig);
        //    services.AddSingleton<IWechatPayConfigStorage>(new WechatPayConfigProvider(WechatPayConfig));
        //    services.TryAddScoped<IWechatPayNotifyService, WechatPayNotifyService>();
        //    services.AddPayService(PayOriginType.WechatPay);
        //    return services;
        //}

        //public static IServiceCollection AddWechatPay(this IServiceCollection services, Action<WechatPayConfig> action = null)
        //{
        //    var WechatPayConfig = new WechatPayConfig();
        //    setupAction?.Invoke(WechatPayConfig);
        //    services.AddHttpClient("wechat", WechatPayConfig);
        //    services.AddSingleton<IWechatPayConfigStorage>(new WechatPayConfigProvider(WechatPayConfig));
        //    services.TryAddScoped<IWechatPayNotifyService, WechatPayNotifyService>();
        //    services.AddPayService(PayOriginType.WechatPay);
        //    return services;
        //}


        //public static void AddPay(this IServiceCollection services, Action<AlipayConfig> aliPaySetupAction = null, Action<WechatPayConfig> WechatPaySetupAction = null)
        //{
        //    services.AddAliPay(aliPaySetupAction);
        //    services.AddWechatPay(WechatPaySetupAction);
        //    services.AddPayService();
        //}

        //public static void AddPay<TWechatPayConfigProvider, TAlipayConfigProvider>(this IServiceCollection services) where TWechatPayConfigProvider : class, IWechatPayConfigStorage where TAlipayConfigProvider : class, IAlipayConfigProvider
        //{
        //    //services.AddAliPay<TAlipayConfigProvider>();
        //    services.AddWechatPay<TWechatPayConfigProvider>();
        //    services.AddPayService();
        //}



        public static IServiceCollection AddPayService(this IServiceCollection services, Assembly assembly, PayOriginType payOriginType)
        {
            return(AddPayService(services, assembly, new List <PayOriginType>()
            {
                payOriginType
            }));
        }
Example #3
0
 public PayServiceAttribute(string Name, PayOriginType PayOriginType)
 {
     this.Name          = Name;
     this.PayOriginType = PayOriginType;
 }