mirror of
https://github.com/bitwarden/server.git
synced 2025-02-01 23:31:41 +01:00
Restore original collection method (#804)
This commit is contained in:
parent
d7b00f6c27
commit
a37706eba1
@ -336,6 +336,8 @@ namespace Bit.Core.Services
|
||||
|
||||
var prorationDate = DateTime.UtcNow;
|
||||
var seatItem = sub.Items?.Data?.FirstOrDefault(i => i.Plan.Id == plan.StripeSeatPlanId);
|
||||
// Retain original collection method
|
||||
var collectionMethod = sub.CollectionMethod;
|
||||
|
||||
var subResponse = await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||
{
|
||||
@ -381,17 +383,20 @@ 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",
|
||||
CollectionMethod = collectionMethod,
|
||||
});
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Change back the subscription collection method
|
||||
if (collectionMethod != "send_invoice")
|
||||
{
|
||||
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||
{
|
||||
CollectionMethod = "charge_automatically",
|
||||
CollectionMethod = collectionMethod,
|
||||
});
|
||||
}
|
||||
|
||||
organization.Seats = (short?)newSeatTotal;
|
||||
await ReplaceAndUpdateCache(organization);
|
||||
|
@ -732,6 +732,8 @@ namespace Bit.Core.Services
|
||||
|
||||
var prorationDate = DateTime.UtcNow;
|
||||
var storageItem = sub.Items?.FirstOrDefault(i => i.Plan.Id == storagePlanId);
|
||||
// Retain original collection method
|
||||
var collectionMethod = sub.CollectionMethod;
|
||||
|
||||
var subResponse = await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||
{
|
||||
@ -778,17 +780,20 @@ 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",
|
||||
CollectionMethod = collectionMethod,
|
||||
});
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Change back the subscription collection method
|
||||
if (collectionMethod != "send_invoice")
|
||||
{
|
||||
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||
{
|
||||
CollectionMethod = "charge_automatically",
|
||||
CollectionMethod = collectionMethod,
|
||||
});
|
||||
}
|
||||
|
||||
return paymentIntentClientSecret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user