Ejemplo n.º 1
0
        private static IServiceCollection AddSingletonDefaultSdk(
            IServiceCollection serviceCollection,
            CheckoutOptions checkoutOptions,
            ILoggerFactory loggerFactory,
            IHttpClientFactory httpClientFactory)
        {
            var checkoutSdkBuilder = CheckoutSdk.Builder()
                                     .StaticKeys()
                                     .SecretKey(checkoutOptions.SecretKey)
                                     .PublicKey(checkoutOptions.PublicKey);

            SetCommonAttributes <CheckoutSdkBuilder.CheckoutStaticKeysSdkBuilder, Checkout.ICheckoutApi>(
                checkoutSdkBuilder, checkoutOptions, loggerFactory, httpClientFactory);
            return(serviceCollection.AddSingleton(checkoutSdkBuilder.Build()));
        }
Ejemplo n.º 2
0
        private static void SetCommonAttributes <TB, TC>(
            TB builder,
            CheckoutOptions options,
            ILoggerFactory loggerFactory,
            IHttpClientFactory httpClientFactory)
            where TB : AbstractCheckoutSdkBuilder <TC>
            where TC : ICheckoutApiClient
        {
            builder.Environment(options.Environment);
            if (loggerFactory != null)
            {
                builder.LogProvider(loggerFactory);
            }

            if (httpClientFactory != null)
            {
                builder.HttpClientFactory(httpClientFactory);
            }
        }
Ejemplo n.º 3
0
        private static IServiceCollection AddSingletonDefaultOAuthSdk(
            IServiceCollection serviceCollection,
            CheckoutOptions checkoutOptions,
            ILoggerFactory loggerFactory,
            IHttpClientFactory httpClientFactory)
        {
            var checkoutSdkBuilder = CheckoutSdk.Builder()
                                     .OAuth()
                                     .ClientCredentials(checkoutOptions.ClientId, checkoutOptions.ClientSecret);

            if (checkoutOptions.AuthorizationUri != null)
            {
                checkoutSdkBuilder.AuthorizationUri(checkoutOptions.AuthorizationUri);
            }

            if (checkoutOptions.Scopes != null)
            {
                checkoutSdkBuilder.Scopes(checkoutOptions.Scopes);
            }

            SetCommonAttributes <CheckoutSdkBuilder.CheckoutOAuthSdkBuilder, Checkout.ICheckoutApi>(
                checkoutSdkBuilder, checkoutOptions, loggerFactory, httpClientFactory);
            return(serviceCollection.AddSingleton(checkoutSdkBuilder.Build()));
        }