Example #1
0
        protected CloudPaymentsMiddlewareBase(
            RequestDelegate next,
            IOptions <CloudPaymentsOptions> options,
            ILoggerFactory loggerFactory,
            ITempDataDictionaryFactory tempDataFactory,
            ICloudPaymentsClient client,
            IAntiforgery antiforgery)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _next            = next ?? throw new ArgumentNullException(nameof(next));
            _options         = options.Value;
            _logger          = loggerFactory.CreateLogger <CloudPaymentsMiddleware>();
            _tempDataFactory = tempDataFactory ?? throw new ArgumentNullException(nameof(tempDataFactory));
            _client          = client ?? throw new ArgumentNullException(nameof(client));
            _antiforgery     = antiforgery ?? throw new ArgumentNullException(nameof(antiforgery));
        }
Example #2
0
        public static IApplicationBuilder UseCloudPayments(
            this IApplicationBuilder builder,
            CloudPaymentsOptions options)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var iOptions = Options.Create(options);

            builder.MapWhen(context => context.Request.Path == CloudPaymentsDefaults.PayPath,
                            app => app.UseMiddleware <CloudPaymentsMiddleware>(iOptions));

            builder.MapWhen(context => context.Request.Path == CloudPaymentsDefaults.Secure3dPath,
                            app => app.UseMiddleware <CloudPaymentsMiddleware3dSecure>(iOptions));

            return(builder);
        }