1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

alloe sub cancellation when deleting account

This commit is contained in:
Kyle Spearrin 2019-09-20 13:45:47 -04:00
parent 0bc034f620
commit b72744eafc
4 changed files with 9 additions and 7 deletions

View File

@ -16,7 +16,8 @@ namespace Bit.Core.Services
Task<string> PurchasePremiumAsync(User user, PaymentMethodType paymentMethodType, string paymentToken,
short additionalStorageGb);
Task<string> AdjustStorageAsync(IStorableSubscriber storableSubscriber, int additionalStorage, string storagePlanId);
Task CancelSubscriptionAsync(ISubscriber subscriber, bool endOfPeriod = false);
Task CancelSubscriptionAsync(ISubscriber subscriber, bool endOfPeriod = false,
bool skipInAppPurchaseCheck = false);
Task ReinstateSubscriptionAsync(ISubscriber subscriber);
Task<bool> UpdatePaymentMethodAsync(ISubscriber subscriber, PaymentMethodType paymentMethodType,
string paymentToken, bool allowInAppPurchases = false);

View File

@ -49,7 +49,7 @@ namespace Bit.Core.Services
Task UpdateLicenseAsync(User user, UserLicense license);
Task<string> AdjustStorageAsync(User user, short storageAdjustmentGb);
Task ReplacePaymentMethodAsync(User user, string paymentToken, PaymentMethodType paymentMethodType);
Task CancelPremiumAsync(User user, bool? endOfPeriod = null);
Task CancelPremiumAsync(User user, bool? endOfPeriod = null, bool accountDelete = false);
Task ReinstatePremiumAsync(User user);
Task EnablePremiumAsync(Guid userId, DateTime? expirationDate);
Task EnablePremiumAsync(User user, DateTime? expirationDate);

View File

@ -1049,7 +1049,8 @@ namespace Bit.Core.Services
return new Tuple<bool, string>(invoiceNow, paymentIntentClientSecret);
}
public async Task CancelSubscriptionAsync(ISubscriber subscriber, bool endOfPeriod = false)
public async Task CancelSubscriptionAsync(ISubscriber subscriber, bool endOfPeriod = false,
bool skipInAppPurchaseCheck = false)
{
if(subscriber == null)
{
@ -1061,7 +1062,7 @@ namespace Bit.Core.Services
throw new GatewayException("No subscription.");
}
if(!string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
if(!string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId) && !skipInAppPurchaseCheck)
{
var customerService = new CustomerService();
var customer = await customerService.GetAsync(subscriber.GatewayCustomerId);

View File

@ -210,7 +210,7 @@ namespace Bit.Core.Services
{
try
{
await CancelPremiumAsync(user);
await CancelPremiumAsync(user, null, true);
}
catch(GatewayException) { }
}
@ -835,7 +835,7 @@ namespace Bit.Core.Services
}
}
public async Task CancelPremiumAsync(User user, bool? endOfPeriod = null)
public async Task CancelPremiumAsync(User user, bool? endOfPeriod = null, bool accountDelete = false)
{
var eop = endOfPeriod.GetValueOrDefault(true);
if(!endOfPeriod.HasValue && user.PremiumExpirationDate.HasValue &&
@ -843,7 +843,7 @@ namespace Bit.Core.Services
{
eop = false;
}
await _paymentService.CancelSubscriptionAsync(user, eop);
await _paymentService.CancelSubscriptionAsync(user, eop, accountDelete);
}
public async Task ReinstatePremiumAsync(User user)