Пример #1
0
        public async Task Notify(CustomerSubscriptionInvoiceUpdated busEvent)
        {
            var customer = await customerRepo.FindByBillingId(busEvent.CustomerBillingId) ?? throw new EntityNotFoundException();

            var user = await userRepo.FindById(customer.UserId) ?? throw new EntityNotFoundException();


            switch (busEvent.SubscriptionStatus)
            {
            case SubscriptionStatus.Active:
            case SubscriptionStatus.Trialing:
            case SubscriptionStatus.Incomplete:
            case SubscriptionStatus.Unpaid:
                var plan = await subscriptionPlanRepo.FindById(busEvent.PlanId) ?? throw new EntityNotFoundException();

                await roleAssigner.ReplaceRoles(user, (Guid)plan.RoleId !);    //TODO: Fix this

                break;

            case SubscriptionStatus.IncompleteExpired:
            case SubscriptionStatus.PastDue:
            case SubscriptionStatus.Canceled:
                await roleAssigner.ReplaceRoles(user, "Free");

                break;
            }
        }
Пример #2
0
        public async Task Notify(CheckoutSessionCompletedSuccessfully busEvent)
        {
            var c = await repo.FindByBillingId(busEvent.CustomerBillingId) ?? throw new EntityNotFoundException();

            await customerService.Refresh(c);

            // Delete out old payment methods besides latest one (on our side).
            c.PaymentMethods = c.PaymentMethods.Where(pm => pm.BillingReference.BillingId == busEvent.NewPaymentMethodBillingId).ToList();
            await repo.Update(c);
        }
Пример #3
0
        public async Task Notify(CustomerSubscriptionInvoiceUpdated busEvent)
        {
            var customer = await customerRepo.FindByBillingId(busEvent.CustomerBillingId) ?? throw new EntityNotFoundException();

            var user = await userRepo.FindById(customer.UserId) ?? throw new EntityNotFoundException();

            MailMessage message = new MailMessage();

            message.To.Add(user.Email);
            message.Subject      = "An error occured processing your subscription payment";
            message.Body         = @$ "Hello! Just wanted to reach out and let you know there was an issue processing your payment for your Detailing Arsenal subscription. If you enjoy using our service, and would like to continue using it, please update the payment method on file for your account. Thanks!";
            message.IsBodyHtml   = false;
            message.BodyEncoding = UTF8Encoding.UTF8;

            await emailClient.Send(message);
        }
Пример #4
0
        public async Task Notify(CustomerTrialWillEndSoon busEvent)
        {
            var customer = await customerRepo.FindByBillingId(busEvent.CustomerBillingId) ?? throw new EntityNotFoundException();

            var user = await userRepo.FindById(customer.UserId) ?? throw new EntityNotFoundException();

            try {
                MailMessage message = new MailMessage();
                message.To.Add("*****@*****.**");
                message.Subject      = "User trial ending soon!";
                message.Body         = $"User trial is going to end soon. Email them. {user.Email}";
                message.IsBodyHtml   = false;
                message.BodyEncoding = UTF8Encoding.UTF8;

                await emailClient.Send(message);
            } catch (Exception e) {
                Log.Fatal(e, "Something went wrong sending an email to Ed.");
            }
        }
Пример #5
0
        public async Task Notify(CustomerSubscriptionInvoiceUpdated busEvent)
        {
            var customer = await repo.FindByBillingId(busEvent.CustomerBillingId) ?? throw new EntityNotFoundException();

            await customerService.Refresh(customer);
        }