コード例 #1
0
ファイル: AlipayGateway.cs プロジェクト: ziyou268/ICanPay
 /// <summary>
 /// 初始化支付宝网关
 /// </summary>
 /// <param name="merchant">商户数据</param>
 public AlipayGateway(Merchant merchant)
     : base(merchant)
 {
     _merchant = merchant;
 }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.Filters.Add <ApiKeyFilter>();
                options.Filters.Add <ApiExceptionFilter>();
                options.Filters.Add <LogFilter>();
            });
            services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings"));
            services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings"));
            services.AddOptions();

            services.AddICanPay(a =>
            {
                //var gateways = new List<GatewayBase>();
                var gateways = new Gateways();
                // 设置商户数据
                var alipayMerchant = new ICanPay.Alipay.Merchant
                {
                    AppId           = "2017093009005992",
                    NotifyUrl       = "http://localhost:61337/Notify",
                    ReturnUrl       = "http://localhost:61337/Return",
                    AlipayPublicKey = "Varorbc",
                    Privatekey      = "Varorbc"
                };

                var wechatpayMerchant = new ICanPay.Wechatpay.Merchant
                {
                    AppId           = "wx2428e34e0e7dc6ef",
                    MchId           = "1233410002",
                    Key             = "e10adc3849ba56abbe56e056f20f883e",
                    AppSecret       = "51c56b886b5be869567dd389b3e5d1d6",
                    SslCertPath     = "Certs/apiclient_cert.p12",
                    SslCertPassword = "******",
                    NotifyUrl       = "http://localhost:61337/Notify"
                };

                gateways.Add(new AlipayGateway(alipayMerchant));
                gateways.Add(new WechatpayGateway(wechatpayMerchant));

                return(gateways);
            });

            services.AddSingleton <IEventBus, EventBus>();
            services.AddTransient <IEventAggregator, EventAggregator>();

            services.AddSingleton <IServiceConfigurationProxy, ServiceConfigurationProxy>();

            services.AddScoped <IDbUnitOfWork, DbUnitOfWork>();
            services.AddScoped <IDbContextProvider, DbContextProvider>();

            services.AddDbContext <DatabaseContext>(options => {
                options.UseMySql(Configuration.GetConnectionString("ServiceDb"));
            });

            //services.AddTransient<IImageAppService, ImageAppService>();
            //services.AddTransient<IImageRepository, ImageRepository>();

            //services.AddTransient<IDomainEventHandler<VerificationCreatedEvent>, VerificationCreatedEventHandler>();

            var container = services.ToServiceContainer();

            container.Configure(config =>
            {
                config.Interceptors.AddTyped <ExceptionInterceptor>(m => m.DeclaringType.Name.EndsWith("AppService"));
            });

            return(IocProvider.Container = container.Build());
        }