mirror of
https://github.com/bitwarden/server.git
synced 2025-04-23 14:05:10 -05: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 prorationDate = DateTime.UtcNow;
|
||||||
var seatItem = sub.Items?.Data?.FirstOrDefault(i => i.Plan.Id == plan.StripeSeatPlanId);
|
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
|
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
|
// This proration behavior prevents a false "credit" from
|
||||||
// being applied forward to the next month's invoice
|
// being applied forward to the next month's invoice
|
||||||
ProrationBehavior = "none",
|
ProrationBehavior = "none",
|
||||||
CollectionMethod = "charge_automatically",
|
CollectionMethod = collectionMethod,
|
||||||
});
|
});
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change back the subscription collection method
|
// Change back the subscription collection method
|
||||||
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
if (collectionMethod != "send_invoice")
|
||||||
{
|
{
|
||||||
CollectionMethod = "charge_automatically",
|
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||||
});
|
{
|
||||||
|
CollectionMethod = collectionMethod,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
organization.Seats = (short?)newSeatTotal;
|
organization.Seats = (short?)newSeatTotal;
|
||||||
await ReplaceAndUpdateCache(organization);
|
await ReplaceAndUpdateCache(organization);
|
||||||
|
@ -732,6 +732,8 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var prorationDate = DateTime.UtcNow;
|
var prorationDate = DateTime.UtcNow;
|
||||||
var storageItem = sub.Items?.FirstOrDefault(i => i.Plan.Id == storagePlanId);
|
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
|
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
|
// This proration behavior prevents a false "credit" from
|
||||||
// being applied forward to the next month's invoice
|
// being applied forward to the next month's invoice
|
||||||
ProrationBehavior = "none",
|
ProrationBehavior = "none",
|
||||||
CollectionMethod = "charge_automatically",
|
CollectionMethod = collectionMethod,
|
||||||
});
|
});
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change back the subscription collection method
|
// Change back the subscription collection method
|
||||||
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
if (collectionMethod != "send_invoice")
|
||||||
{
|
{
|
||||||
CollectionMethod = "charge_automatically",
|
await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
|
||||||
});
|
{
|
||||||
|
CollectionMethod = collectionMethod,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return paymentIntentClientSecret;
|
return paymentIntentClientSecret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user