public static ZebbleBillingServicesBuilder AddGooglePlay(this ZebbleBillingServicesBuilder builder, string configKey = "ZebbleBilling:GooglePlay") { builder.Services.AddOptions <GooglePlayOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.PackageName.HasValue(), $"{nameof(GooglePlayOptions.PackageName)} is empty.") .Validate(opts => opts.ProjectId.HasValue(), $"{nameof(GooglePlayOptions.ProjectId)} is empty.") .Validate(opts => opts.PrivateKeyId.HasValue(), $"{nameof(GooglePlayOptions.PrivateKeyId)} is empty.") .Validate(opts => opts.PrivateKey.HasValue(), $"{nameof(GooglePlayOptions.PrivateKey)} is empty.") .Validate(opts => opts.ClientEmail.HasValue(), $"{nameof(GooglePlayOptions.ClientEmail)} is empty.") .Validate(opts => opts.ClientId.HasValue(), $"{nameof(GooglePlayOptions.ClientId)} is empty.") .Validate(opts => opts.SubscriptionId.HasValue(), $"{nameof(GooglePlayOptions.SubscriptionId)} is empty.") .Validate(opts => opts.QueueProcessorPath.HasValue(), $"{nameof(GooglePlayOptions.QueueProcessorPath)} is empty."); builder.Services.AddSingleton(sp => { var options = sp.GetService <IOptions <GooglePlayOptions> >().Value; var initializer = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(options.ClientEmail) { ProjectId = options.ProjectId, Scopes = new[] { AndroidPublisherService.ScopeConstants.Androidpublisher } }.FromPrivateKey(options.PrivateKey)); return(new AndroidPublisherService(new BaseClientService.Initializer { HttpClientInitializer = initializer })); }); builder.Services.AddStoreConnector <GooglePlayConnector>("GooglePlay"); builder.Services.AddScoped <GooglePlayQueueProcessor>(); return(builder); }
public static ZebbleBillingServicesBuilder AddEntityFramework(this ZebbleBillingServicesBuilder builder, string configKey = "ZebbleBilling:EntityFramework") { builder.Services.AddOptions <EntityFrameworkOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.ConnectionString.HasValue(), $"{nameof(EntityFrameworkOptions.ConnectionString)} is empty."); builder.Services.AddDbContext <SubscriptionDbContext>(); builder.Services.AddScoped <ISubscriptionRepository, SubscriptionRepository>(); return(builder); }
public static ZebbleBillingServicesBuilder AddCafeBazaar(this ZebbleBillingServicesBuilder builder, string configKey = "ZebbleBilling:CafeBazaar") { builder.Services.AddCafeBazaarDeveloperApi($"{configKey}:DeveloperApi"); builder.Services.AddOptions <CafeBazaarOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.PackageName.HasValue(), $"{nameof(CafeBazaarOptions.PackageName)} is empty."); builder.Services.AddStoreConnector <CafeBazaarConnector>("CafeBazaar"); return(builder); }
public static ZebbleBillingServicesBuilder AddVoucher(this ZebbleBillingServicesBuilder builder, Action <ZebbleBillingVoucherServicesBuilder> voucherBuilder = null, string configKey = "ZebbleBilling:Voucher") { builder.Services.AddOptions <VoucherOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.CodeApplyPath.HasValue(), $"{nameof(VoucherOptions.CodeApplyPath)} is empty."); builder.Services.AddStoreConnector <VoucherConnector>("Voucher"); builder.Services.AddScoped <VoucherCodeApplier>(); voucherBuilder?.Invoke(new ZebbleBillingVoucherServicesBuilder(builder.Services)); return(builder); }
public static ZebbleBillingServicesBuilder AddDynamoDb(this ZebbleBillingServicesBuilder builder, bool registerClient = false, string configKey = "ZebbleBilling:DynamoDb") { if (registerClient) { builder.Services.AddScoped(sp => sp.GetRequiredService <IConfiguration>().GetAWSOptions(configKey).CreateServiceClient <IAmazonDynamoDB>()); } builder.Services.AddScoped <SubscriptionDbContext>(); builder.Services.AddScoped <ISubscriptionRepository, SubscriptionRepository>(); return(builder); }
public static ZebbleBillingServicesBuilder AddAppStore(this ZebbleBillingServicesBuilder builder, string configKey = "ZebbleBilling:AppStore") { builder.Services.AddOptions <AppStoreOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.PackageName.HasValue(), $"{nameof(AppStoreOptions.PackageName)} is empty.") .Validate(opts => opts.SharedSecret.HasValue(), $"{nameof(AppStoreOptions.SharedSecret)} is empty.") .Validate(opts => opts.HookInterceptorPath.HasValue(), $"{nameof(AppStoreOptions.HookInterceptorPath)} is empty."); builder.Services.AddOptions <AppleReceiptVerificationSettings>() .Configure <IOptions <AppStoreOptions> >((settings, options) => options.Value.Apply(settings)); builder.Services.RegisterAppleReceiptVerificator(); builder.Services.AddStoreConnector <AppStoreConnector>("AppStore"); builder.Services.AddScoped <AppStoreHookInterceptor>(); return(builder); }
public static ZebbleBillingServicesBuilder AddGooglePlay(this ZebbleBillingServicesBuilder builder, string configKey = "ZebbleBilling:GooglePlay") { builder.Services.AddOptions <GooglePlayOptions>() .Configure <IConfiguration>((opts, config) => config.GetSection(configKey)?.Bind(opts)) .Validate(opts => opts.PackageName.HasValue(), $"{nameof(GooglePlayOptions.PackageName)} is empty.") .Validate(opts => opts.ProjectId.HasValue(), $"{nameof(GooglePlayOptions.ProjectId)} is empty.") .Validate(opts => opts.PrivateKeyId.HasValue(), $"{nameof(GooglePlayOptions.PrivateKeyId)} is empty.") .Validate(opts => opts.PrivateKey.HasValue(), $"{nameof(GooglePlayOptions.PrivateKey)} is empty.") .Validate(opts => opts.ClientEmail.HasValue(), $"{nameof(GooglePlayOptions.ClientEmail)} is empty.") .Validate(opts => opts.ClientId.HasValue(), $"{nameof(GooglePlayOptions.ClientId)} is empty.") .Validate(opts => opts.SubscriptionId.HasValue(), $"{nameof(GooglePlayOptions.SubscriptionId)} is empty.") .Validate(opts => opts.QueueProcessorPath.HasValue(), $"{nameof(GooglePlayOptions.QueueProcessorPath)} is empty."); builder.Services.AddStoreConnector <GooglePlayConnector>("GooglePlay"); builder.Services.AddScoped <GooglePlayQueueProcessor>(); return(builder); }