diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 36c56ad013..9d8b709abc 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -37,7 +37,7 @@
-
+
diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs
index 67d9b2eb69..de1503d778 100644
--- a/src/Core/Services/Implementations/OrganizationService.cs
+++ b/src/Core/Services/Implementations/OrganizationService.cs
@@ -185,6 +185,7 @@ namespace Bit.Core.Services
// They must have been on a free plan. Create new sub.
var subCreateOptions = new StripeSubscriptionCreateOptions
{
+ CustomerId = organization.GatewayCustomerId,
TrialPeriodDays = newPlan.TrialPeriodDays,
Items = new List(),
Metadata = new Dictionary {
@@ -210,7 +211,7 @@ namespace Bit.Core.Services
});
}
- await subscriptionService.CreateAsync(organization.GatewayCustomerId, subCreateOptions);
+ await subscriptionService.CreateAsync(subCreateOptions);
}
else
{
@@ -468,6 +469,7 @@ namespace Bit.Core.Services
var subCreateOptions = new StripeSubscriptionCreateOptions
{
+ CustomerId = customer.Id,
TrialPeriodDays = plan.TrialPeriodDays,
Items = new List(),
Metadata = new Dictionary {
@@ -504,7 +506,7 @@ namespace Bit.Core.Services
try
{
- subscription = await subscriptionService.CreateAsync(customer.Id, subCreateOptions);
+ subscription = await subscriptionService.CreateAsync(subCreateOptions);
}
catch(StripeException)
{
diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs
index 8f74177f50..d95153c311 100644
--- a/src/Core/Services/Implementations/StripePaymentService.cs
+++ b/src/Core/Services/Implementations/StripePaymentService.cs
@@ -26,6 +26,7 @@ namespace Bit.Core.Services
var subCreateOptions = new StripeSubscriptionCreateOptions
{
+ CustomerId = customer.Id,
Items = new List(),
Metadata = new Dictionary
{
@@ -52,7 +53,7 @@ namespace Bit.Core.Services
try
{
var subscriptionService = new StripeSubscriptionService();
- subscription = await subscriptionService.CreateAsync(customer.Id, subCreateOptions);
+ subscription = await subscriptionService.CreateAsync(subCreateOptions);
}
catch(StripeException)
{
@@ -114,7 +115,8 @@ namespace Bit.Core.Services
if(!string.IsNullOrWhiteSpace(subscriber.GatewaySubscriptionId))
{
var subscriptionService = new StripeSubscriptionService();
- await subscriptionService.CancelAsync(subscriber.GatewaySubscriptionId, false);
+ await subscriptionService.CancelAsync(subscriber.GatewaySubscriptionId,
+ new StripeSubscriptionCancelOptions());
}
if(string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
@@ -158,7 +160,7 @@ namespace Bit.Core.Services
try
{
// Owes more than prorateThreshold on next invoice.
- // Invoice them and pay now instead of waiting until next month.
+ // Invoice them and pay now instead of waiting until next billing cycle.
var invoice = await invoiceService.CreateAsync(subscriber.GatewayCustomerId,
new StripeInvoiceCreateOptions
{
@@ -167,7 +169,7 @@ namespace Bit.Core.Services
if(invoice.AmountDue > 0)
{
- await invoiceService.PayAsync(invoice.Id);
+ await invoiceService.PayAsync(invoice.Id, new StripeInvoicePayOptions());
}
}
catch(StripeException) { }
@@ -201,7 +203,10 @@ namespace Bit.Core.Services
try
{
- var canceledSub = await subscriptionService.CancelAsync(sub.Id, endOfPeriod);
+ var canceledSub = endOfPeriod ?
+ await subscriptionService.UpdateAsync(sub.Id,
+ new StripeSubscriptionUpdateOptions { CancelAtPeriodEnd = true }) :
+ await subscriptionService.CancelAsync(sub.Id, new StripeSubscriptionCancelOptions());
if(!canceledSub.CanceledAt.HasValue)
{
throw new GatewayException("Unable to cancel subscription.");