/// <inheritdoc />
        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var routeData = context.RouteData;

            if (!routeData.TryGetWebHookReceiverName(out var receiverName) ||
                !IsApplicable(receiverName) ||
                _configuration.IsTrue(StripeConstants.PassThroughTestEventsConfigurationKey))
            {
                return;
            }

            var notificationId = (string)routeData.Values[StripeConstants.NotificationIdKeyName];

            if (StripeVerifyNotificationIdFilter.IsTestEvent(notificationId))
            {
                // Short-circuit this test event.
                _logger.LogInformation(1, "Ignoring a Stripe Test Event.");
                context.Result = new OkResult();
            }
        }
        /// <inheritdoc />
        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var routeData = context.RouteData;

            if (!routeData.TryGetReceiverName(out var receiverName) ||
                !IsApplicable(receiverName) ||
                _passThroughTestEvents)
            {
                return;
            }

            if (!context.HttpContext.Items.TryGetValue(typeof(JObject), out var item) || !(item is JObject data))
            {
                _logger.LogCritical(
                    0,
                    "Unable to retrieve '{DataType}' request data from '{ClassName}.{PropertyName}'.",
                    typeof(JObject),
                    nameof(context.HttpContext),
                    nameof(context.HttpContext.Items));

                var message = string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.TestEvent_MissingItem,
                    typeof(JObject),
                    nameof(context.HttpContext),
                    nameof(context.HttpContext.Items));
                throw new InvalidOperationException(message);
            }

            var notificationId = data.Value <string>(StripeConstants.NotificationIdPropertyName);

            if (StripeVerifyNotificationIdFilter.IsTestEvent(notificationId))
            {
                // Short-circuit this test event.
                _logger.LogInformation(1, "Ignoring a Stripe Test Event.");
                context.Result = new OkResult();
            }
        }