From d7b00f6c2779948816e888c40937de36336d6e52 Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Mon, 29 Jun 2020 20:29:19 -0400 Subject: [PATCH] Subscription update to maintain auto charge (#803) --- src/Core/Services/Implementations/OrganizationService.cs | 7 +++++++ src/Core/Services/Implementations/StripePaymentService.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 538ff55de..0dcb70f73 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -381,11 +381,18 @@ namespace Bit.Core.Services // This proration behavior prevents a false "credit" from // being applied forward to the next month's invoice ProrationBehavior = "none", + CollectionMethod = "charge_automatically", }); throw; } } + // Change back the subscription collection method + await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions + { + CollectionMethod = "charge_automatically", + }); + organization.Seats = (short?)newSeatTotal; await ReplaceAndUpdateCache(organization); return paymentIntentClientSecret; diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs index 13c378676..ff92c7d12 100644 --- a/src/Core/Services/Implementations/StripePaymentService.cs +++ b/src/Core/Services/Implementations/StripePaymentService.cs @@ -778,11 +778,18 @@ namespace Bit.Core.Services // This proration behavior prevents a false "credit" from // being applied forward to the next month's invoice ProrationBehavior = "none", + CollectionMethod = "charge_automatically", }); throw; } } + // Change back the subscription collection method + await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions + { + CollectionMethod = "charge_automatically", + }); + return paymentIntentClientSecret; }