public async Task HandleNewCustomerSubscriptionAsync(string json)
    {
        var paymentHandlerEvent = _paymentHandlerEventService.FromJson(json);

        if (string.IsNullOrEmpty(paymentHandlerEvent.SubscriptionId))
        {
            _logger.LogWarning("Payment handler subscriptionId is null or empty", json);
        }
        var paymentAmount = _paymentHandlerInvoice.GetPaymentAmount(json);

        var newSubscriberIsAlreadyMember = await IsNewCustomerSubscriptionWithEmailAlreadyMember(paymentHandlerEvent.SubscriptionId);

        if (newSubscriberIsAlreadyMember)
        {
            _logger.LogInformation("New subscriber is an existing devBetter member", json);

            await HandleNewCustomerSubscriptionWithEmailAlreadyMember(paymentHandlerEvent.SubscriptionId, paymentAmount);
        }
        else
        {
            var status = _paymentHandlerSubscription.GetStatus(paymentHandlerEvent.SubscriptionId);
            _logger.LogInformation($"Subscription status: {status}");

            if (status == "active")
            {
                var customerId             = _paymentHandlerSubscription.GetCustomerId(paymentHandlerEvent.SubscriptionId);
                var paymentHandlerCustomer = _paymentHandlerCustomerService.GetCustomer(customerId);

                if (string.IsNullOrEmpty(paymentHandlerCustomer.Email))
                {
                    throw new InvalidEmailException();
                }

                Invitation invite = await _newMemberService.CreateInvitationAsync(paymentHandlerCustomer.Email, paymentHandlerEvent.SubscriptionId);

                var webhookMessage = $"A new customer with email {paymentHandlerCustomer.Email} has subscribed to DevBetter. They will be receiving a registration email.";
                await _webhook.Send($"Webhook:\n{webhookMessage}");

                await _newMemberService.SendRegistrationEmailAsync(invite);

                // moved to NewMemberRegister.cshtml.cs
                //await AddNewSubscriberBillingActivity(paymentHandlerSubscriptionId, email, paymentAmount);
            }
        }
    }
        public async Task HandleNewCustomerSubscriptionAsync(string json)
        {
            var subscriptionId = _paymentHandlerEvent.GetSubscriptionId(json);
            var paymentAmount  = _paymentHandlerInvoice.GetPaymentAmount(json);

            var newSubscriberIsAlreadyMember = await NewCustomerSubscriptionWithEmailAlreadyMember(subscriptionId);

            if (newSubscriberIsAlreadyMember)
            {
                await HandleNewCustomerSubscriptionWithEmailAlreadyMember(subscriptionId, paymentAmount);
            }
            else
            {
                var status = _paymentHandlerSubscription.GetStatus(subscriptionId);

                if (status == "active")
                {
                    var customerId = _paymentHandlerSubscription.GetCustomerId(subscriptionId);
                    var email      = _paymentHandlerCustomer.GetCustomerEmail(customerId);

                    if (string.IsNullOrEmpty(email))
                    {
                        throw new InvalidEmailException();
                    }

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

                    var webhookMessage = $"A new customer with email {email} has subscribed to DevBetter. They will be receiving a registration email.";
                    await _webhook.Send($"Webhook:\n{webhookMessage}");

                    await _newMemberService.SendRegistrationEmailAsync(invite);

                    await AddNewSubscriberBillingActivity(subscriptionId, email, paymentAmount);
                }
            }
        }