public async Task HandleCustomerSubscriptionCancelledAtPeriodEndAsync(string json)
        {
            var subscriptionId = _paymentHandlerEvent.GetSubscriptionId(json);
            var customerId     = _paymentHandlerSubscription.GetCustomerId(subscriptionId);
            var email          = _paymentHandlerCustomer.GetCustomerEmail(customerId);

            await _memberCancellationService.SendFutureCancellationEmailAsync(email);

            var subscriptionPlanName = _paymentHandlerSubscription.GetAssociatedProductName(subscriptionId);
            var billingPeriod        = _paymentHandlerSubscription.GetBillingPeriod(subscriptionId);
            await _memberAddBillingActivityService.AddMemberSubscriptionCancellationBillingActivity(email, subscriptionPlanName, billingPeriod);
        }
        public async Task <IActionResult> Index()
        {
            var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();

            _webhook.Content = $"{json}";
            await _webhook.Send();

            return(Ok());

            try
            {
                var stripeEvent     = EventUtility.ParseEvent(json);
                var stripeEventType = stripeEvent.Type;

                if (stripeEventType.Equals("customer.subscription.created"))
                {
                    var subscription   = stripeEvent.Data.Object as Stripe.Subscription;
                    var subscriptionId = subscription !.Id;
                    var customerId     = subscription.CustomerId;
                    var email          = _paymentHandlerCustomer.GetCustomerEmail(customerId);

                    Invitation invite = await _newMemberService.CreateInvitationAsync(email, subscriptionId);

                    await _newMemberService.SendRegistrationEmailAsync(invite);
                }
                else
                {
                    _logger.LogError("Unhandled event type: {0}", stripeEvent.Type);
                }
                return(Ok());
            }
            catch (StripeException)
            {
                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }