Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
30aab22
move billing services+tests to billing namespaces
kdenney Aug 8, 2025
1a77d0e
reorganized methods in file and added comment headers
kdenney Aug 8, 2025
d6a901c
renamed StripeAdapter methods for better clarity
kdenney Aug 8, 2025
ed21043
clean up redundant qualifiers
kdenney Aug 11, 2025
2b19c79
Upgrade Stripe.net to v48.4.0
amorask-bitwarden Aug 13, 2025
cb13c06
Update PreviewTaxAmountCommand
amorask-bitwarden Aug 13, 2025
e804b9e
Remove unused UpcomingInvoiceOptionExtensions
amorask-bitwarden Aug 13, 2025
2dcd8ff
Added SubscriptionExtensions with GetCurrentPeriodEnd
amorask-bitwarden Aug 13, 2025
85b20a2
Update PremiumUserBillingService
amorask-bitwarden Aug 13, 2025
d3255f6
Update OrganizationBillingService
amorask-bitwarden Aug 13, 2025
6c236ff
Update GetOrganizationWarningsQuery
amorask-bitwarden Aug 13, 2025
347756b
Update BillingHistoryInfo
amorask-bitwarden Aug 13, 2025
2458ac7
Update SubscriptionInfo
amorask-bitwarden Aug 13, 2025
cfa3c1a
Remove unused Sql Billing folder
amorask-bitwarden Aug 13, 2025
342dfbc
Update StripeAdapter
amorask-bitwarden Aug 13, 2025
5370dd1
Update StripePaymentService
amorask-bitwarden Aug 13, 2025
319a847
Update InvoiceCreatedHandler
amorask-bitwarden Aug 13, 2025
fb5400f
Update PaymentFailedHandler
amorask-bitwarden Aug 13, 2025
43aa2e0
Update PaymentSucceededHandler
amorask-bitwarden Aug 13, 2025
0928c57
Update ProviderEventService
amorask-bitwarden Aug 13, 2025
5518a59
Update StripeEventUtilityService
amorask-bitwarden Aug 14, 2025
b605a31
Update SubscriptionDeletedHandler
amorask-bitwarden Aug 14, 2025
eb7485b
Update SubscriptionUpdatedHandler
amorask-bitwarden Aug 14, 2025
35906c1
Update UpcomingInvoiceHandler
amorask-bitwarden Aug 14, 2025
c99d222
Update ProviderSubscriptionResponse
amorask-bitwarden Aug 14, 2025
0eb8149
Remove unused Stripe Subscriptions Admin Tool
amorask-bitwarden Aug 14, 2025
e18cf2b
Update RemoveOrganizationFromProviderCommand
amorask-bitwarden Aug 14, 2025
ea9b895
Update ProviderBillingService
amorask-bitwarden Aug 14, 2025
e151ce5
Update RemoveOrganizatinoFromProviderCommandTests
amorask-bitwarden Aug 14, 2025
67e7866
Update PreviewTaxAmountCommandTests
amorask-bitwarden Aug 14, 2025
fc194e3
Update GetCloudOrganizationLicenseQueryTests
amorask-bitwarden Aug 14, 2025
4329d94
Update GetOrganizationWarningsQueryTests
amorask-bitwarden Aug 14, 2025
29eee6b
Update StripePaymentServiceTests
amorask-bitwarden Aug 14, 2025
d5361fc
Update ProviderBillingControllerTests
amorask-bitwarden Aug 14, 2025
c866ca2
Update ProviderEventServiceTests
amorask-bitwarden Aug 14, 2025
b98c450
Update SubscriptionDeletedHandlerTests
amorask-bitwarden Aug 14, 2025
907769f
Update SubscriptionUpdatedHandlerTests
amorask-bitwarden Aug 14, 2025
59fd177
Resolve Billing test failures
amorask-bitwarden Aug 14, 2025
3283009
Resolve Core test failures
amorask-bitwarden Aug 14, 2025
d1a462a
Run dotnet format
amorask-bitwarden Aug 14, 2025
3e18283
Remove unused provider migration
amorask-bitwarden Aug 15, 2025
5d9c8b4
Fixed failing tests
amorask-bitwarden Aug 15, 2025
e85f7d5
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Aug 18, 2025
33656b0
Run dotnet format
amorask-bitwarden Aug 18, 2025
ffe636a
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Aug 18, 2025
a3ad14d
Replace the old webhook secret key with new one (#6223)
cyprain-okeke Aug 21, 2025
ea50cfc
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 3, 2025
b279970
Fix compilation failures in additions
amorask-bitwarden Sep 3, 2025
5af672d
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 3, 2025
57098d7
Run dotnet format
amorask-bitwarden Sep 3, 2025
439064f
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 4, 2025
72be571
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 10, 2025
7643b95
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 10, 2025
7883e0f
Bump Stripe API version
amorask-bitwarden Sep 10, 2025
d729532
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Sep 25, 2025
2a22abc
Fix recent addition: CreatePremiumCloudHostedSubscriptionCommand
amorask-bitwarden Sep 25, 2025
7895b49
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Oct 1, 2025
e36e886
Fix new code in main according to Stripe update
amorask-bitwarden Oct 1, 2025
f1fbd63
Fix InvoiceExtensions
amorask-bitwarden Oct 1, 2025
713d76d
Bump SDK version to match API Version
amorask-bitwarden Oct 2, 2025
2c697fb
Merge branch 'main' into billing/stripe-dotnet-v48
amorask-bitwarden Oct 2, 2025
4e63a43
Merge branch 'main' into beeep/PM-24616-move-stripe-adapter
kdenney Oct 3, 2025
c1bd7dd
Merge branch 'main' into beeep/PM-24616-move-stripe-adapter
kdenney Oct 3, 2025
eee41a9
Merge remote-tracking branch 'origin/billing/stripe-dotnet-v48' into โ€ฆ
kdenney Oct 3, 2025
899c0e3
cleanup
kdenney Oct 3, 2025
61c4007
Merge branch 'main' into beeep/PM-24616-move-stripe-adapter
kdenney Oct 31, 2025
7c8c38a
fixing items missed after the merge
kdenney Oct 31, 2025
57bf2fa
use expression body for all simple returns
kdenney Oct 31, 2025
662d988
Merge branch 'main' into beeep/PM-24616-move-stripe-adapter
kdenney Oct 31, 2025
f47bc55
forgot fixes, format, and pr feedback
kdenney Oct 31, 2025
92e9163
claude pr feedback
kdenney Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ bitwarden_license/src/Sso/Sso.zip
/identity.json
/api.json
/api.public.json
.serena/

# Serena
.serena/
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private async Task ResetOrganizationBillingAsync(
await _providerBillingService.CreateCustomerForClientOrganization(provider, organization);
}

var customer = await _stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
var customer = await _stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
{
Description = string.Empty,
Email = organization.BillingEmail,
Expand All @@ -138,7 +138,7 @@ private async Task ResetOrganizationBillingAsync(

subscriptionCreateOptions.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true };

var subscription = await _stripeAdapter.SubscriptionCreateAsync(subscriptionCreateOptions);
var subscription = await _stripeAdapter.CreateSubscriptionAsync(subscriptionCreateOptions);

organization.GatewaySubscriptionId = subscription.Id;
organization.Status = OrganizationStatusType.Created;
Expand All @@ -148,17 +148,16 @@ private async Task ResetOrganizationBillingAsync(
}
else if (organization.IsStripeEnabled())
{
var subscription = await _stripeAdapter.SubscriptionGetAsync(organization.GatewaySubscriptionId, new SubscriptionGetOptions
var subscription = await _stripeAdapter.GetSubscriptionAsync(organization.GatewaySubscriptionId, new SubscriptionGetOptions
{
Expand = ["customer"]
});

if (subscription.Status is StripeConstants.SubscriptionStatus.Canceled or StripeConstants.SubscriptionStatus.IncompleteExpired)
{
return;
}

await _stripeAdapter.CustomerUpdateAsync(subscription.CustomerId, new CustomerUpdateOptions
await _stripeAdapter.UpdateCustomerAsync(subscription.CustomerId, new CustomerUpdateOptions
{
Email = organization.BillingEmail
});
Expand All @@ -168,7 +167,7 @@ private async Task ResetOrganizationBillingAsync(
await _stripeAdapter.CustomerDeleteDiscountAsync(subscription.CustomerId);
}

await _stripeAdapter.SubscriptionUpdateAsync(organization.GatewaySubscriptionId, new SubscriptionUpdateOptions
await _stripeAdapter.UpdateSubscriptionAsync(organization.GatewaySubscriptionId, new SubscriptionUpdateOptions
{
CollectionMethod = StripeConstants.CollectionMethod.SendInvoice,
DaysUntilDue = 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Bit.Core.Billing.Payment.Models;
using Bit.Core.Billing.Pricing;
using Bit.Core.Billing.Providers.Services;
using Bit.Core.Billing.Services;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
Expand Down Expand Up @@ -426,7 +427,7 @@ public async Task AddOrganization(Guid providerId, Guid organizationId, string k

if (!string.IsNullOrEmpty(organization.GatewayCustomerId))
{
await _stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
await _stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
{
Email = provider.BillingEmail
});
Expand Down Expand Up @@ -486,7 +487,7 @@ private async Task ApplyProviderPriceRateAsync(Organization organization, Provid

private async Task<SubscriptionItem> GetSubscriptionItemAsync(string subscriptionId, string oldPlanId)
{
var subscriptionDetails = await _stripeAdapter.SubscriptionGetAsync(subscriptionId);
var subscriptionDetails = await _stripeAdapter.GetSubscriptionAsync(subscriptionId);
return subscriptionDetails.Items.Data.FirstOrDefault(item => item.Price.Id == oldPlanId);
}

Expand All @@ -496,7 +497,7 @@ private async Task UpdateSubscriptionAsync(SubscriptionItem subscriptionItem, st
{
if (subscriptionItem.Price.Id != extractedPlanType)
{
await _stripeAdapter.SubscriptionUpdateAsync(subscriptionItem.Subscription,
await _stripeAdapter.UpdateSubscriptionAsync(subscriptionItem.Subscription,
new Stripe.SubscriptionUpdateOptions
{
Items = new List<Stripe.SubscriptionItemOptions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Bit.Core.Billing.Providers.Queries;
using Bit.Core.Billing.Services;
using Bit.Core.Context;
using Bit.Core.Services;
using Stripe;
using Stripe.Tax;

Expand Down Expand Up @@ -76,8 +75,8 @@ await subscriberService.GetSubscription(provider,

// Get active and scheduled registrations
var registrations = (await Task.WhenAll(
stripeAdapter.TaxRegistrationsListAsync(new RegistrationListOptions { Status = TaxRegistrationStatus.Active }),
stripeAdapter.TaxRegistrationsListAsync(new RegistrationListOptions { Status = TaxRegistrationStatus.Scheduled })))
stripeAdapter.ListTaxRegistrationsAsync(new RegistrationListOptions { Status = TaxRegistrationStatus.Active }),
stripeAdapter.ListTaxRegistrationsAsync(new RegistrationListOptions { Status = TaxRegistrationStatus.Scheduled })))
.SelectMany(registrations => registrations.Data);

// Find the matching registration for the customer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task<Guid> FinalizeConversion(
providerUser.Status = ProviderUserStatusType.Confirmed;

// Stripe requires that we clear all the custom fields from the invoice settings if we want to replace them.
await stripeAdapter.CustomerUpdateAsync(subscription.CustomerId, new CustomerUpdateOptions
await stripeAdapter.UpdateCustomerAsync(subscription.CustomerId, new CustomerUpdateOptions
{
InvoiceSettings = new CustomerInvoiceSettingsOptions
{
Expand All @@ -116,7 +116,7 @@ public async Task<Guid> FinalizeConversion(
["convertedFrom"] = organization.Id.ToString()
};

var updateCustomer = stripeAdapter.CustomerUpdateAsync(subscription.CustomerId, new CustomerUpdateOptions
var updateCustomer = stripeAdapter.UpdateCustomerAsync(subscription.CustomerId, new CustomerUpdateOptions
{
InvoiceSettings = new CustomerInvoiceSettingsOptions
{
Expand Down Expand Up @@ -148,7 +148,7 @@ public async Task<Guid> FinalizeConversion(

// Replace the existing password manager price with the new business unit price.
var updateSubscription =
stripeAdapter.SubscriptionUpdateAsync(subscription.Id,
stripeAdapter.UpdateSubscriptionAsync(subscription.Id,
new SubscriptionUpdateOptions
{
Items = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public async Task AddExistingOrganization(
Organization organization,
string key)
{
await stripeAdapter.SubscriptionUpdateAsync(organization.GatewaySubscriptionId,
await stripeAdapter.UpdateSubscriptionAsync(organization.GatewaySubscriptionId,
new SubscriptionUpdateOptions { CancelAtPeriodEnd = false });

var subscription =
await stripeAdapter.SubscriptionCancelAsync(organization.GatewaySubscriptionId,
await stripeAdapter.CancelSubscriptionAsync(organization.GatewaySubscriptionId,
new SubscriptionCancelOptions
{
CancellationDetails = new SubscriptionCancellationDetailsOptions
Expand All @@ -83,7 +83,7 @@ await stripeAdapter.SubscriptionCancelAsync(organization.GatewaySubscriptionId,

if (!wasTrialing && subscription.LatestInvoice.Status == InvoiceStatus.Draft)
{
await stripeAdapter.InvoiceFinalizeInvoiceAsync(subscription.LatestInvoiceId,
await stripeAdapter.FinalizeInvoiceAsync(subscription.LatestInvoiceId,
new InvoiceFinalizeOptions { AutoAdvance = true });
}

Expand Down Expand Up @@ -138,7 +138,7 @@ await Task.WhenAll(

if (clientCustomer.Balance != 0)
{
await stripeAdapter.CustomerBalanceTransactionCreate(provider.GatewayCustomerId,
await stripeAdapter.CreateCustomerBalanceTransactionAsync(provider.GatewayCustomerId,
new CustomerBalanceTransactionCreateOptions
{
Amount = clientCustomer.Balance,
Expand Down Expand Up @@ -187,7 +187,7 @@ public async Task ChangePlan(ChangeProviderPlanCommand command)
]
};

await stripeAdapter.SubscriptionUpdateAsync(provider.GatewaySubscriptionId, updateOptions);
await stripeAdapter.UpdateSubscriptionAsync(provider.GatewaySubscriptionId, updateOptions);

// Refactor later to ?ChangeClientPlanCommand? (ProviderPlanId, ProviderId, OrganizationId)
// 1. Retrieve PlanType and PlanName for ProviderPlan
Expand Down Expand Up @@ -275,7 +275,7 @@ await subscriberService.GetCustomerOrThrow(provider,
customerCreateOptions.TaxExempt = TaxExempt.Reverse;
}

var customer = await stripeAdapter.CustomerCreateAsync(customerCreateOptions);
var customer = await stripeAdapter.CreateCustomerAsync(customerCreateOptions);

organization.GatewayCustomerId = customer.Id;

Expand Down Expand Up @@ -525,7 +525,7 @@ public async Task<Customer> SetupCustomer(
case TokenizablePaymentMethodType.BankAccount:
{
var setupIntent =
(await stripeAdapter.SetupIntentList(new SetupIntentListOptions
(await stripeAdapter.ListSetupIntentsAsync(new SetupIntentListOptions
{
PaymentMethod = paymentMethod.Token
}))
Expand Down Expand Up @@ -558,7 +558,7 @@ public async Task<Customer> SetupCustomer(

try
{
return await stripeAdapter.CustomerCreateAsync(options);
return await stripeAdapter.CreateCustomerAsync(options);
}
catch (StripeException stripeException) when (stripeException.StripeError?.Code == ErrorCodes.TaxIdInvalid)
{
Expand All @@ -580,7 +580,7 @@ async Task Revert()
case TokenizablePaymentMethodType.BankAccount:
{
var setupIntentId = await setupIntentCache.GetSetupIntentIdForSubscriber(provider.Id);
await stripeAdapter.SetupIntentCancel(setupIntentId,
await stripeAdapter.CancelSetupIntentAsync(setupIntentId,
new SetupIntentCancelOptions { CancellationReason = "abandoned" });
await setupIntentCache.RemoveSetupIntentForSubscriber(provider.Id);
break;
Expand Down Expand Up @@ -638,7 +638,7 @@ public async Task<Subscription> SetupSubscription(
var setupIntentId = await setupIntentCache.GetSetupIntentIdForSubscriber(provider.Id);

var setupIntent = !string.IsNullOrEmpty(setupIntentId)
? await stripeAdapter.SetupIntentGet(setupIntentId,
? await stripeAdapter.GetSetupIntentAsync(setupIntentId,
new SetupIntentGetOptions { Expand = ["payment_method"] })
: null;

Expand Down Expand Up @@ -673,7 +673,7 @@ public async Task<Subscription> SetupSubscription(

try
{
var subscription = await stripeAdapter.SubscriptionCreateAsync(subscriptionCreateOptions);
var subscription = await stripeAdapter.CreateSubscriptionAsync(subscriptionCreateOptions);

if (subscription is
{
Expand Down Expand Up @@ -708,7 +708,7 @@ await Task.WhenAll(
subscriberService.UpdatePaymentSource(provider, tokenizedPaymentSource),
subscriberService.UpdateTaxInformation(provider, taxInformation));

await stripeAdapter.SubscriptionUpdateAsync(provider.GatewaySubscriptionId,
await stripeAdapter.UpdateSubscriptionAsync(provider.GatewaySubscriptionId,
new SubscriptionUpdateOptions { CollectionMethod = CollectionMethod.ChargeAutomatically });
}

Expand Down Expand Up @@ -791,7 +791,7 @@ public async Task UpdateSeatMinimums(UpdateProviderSeatMinimumsCommand command)

if (subscriptionItemOptionsList.Count > 0)
{
await stripeAdapter.SubscriptionUpdateAsync(provider.GatewaySubscriptionId,
await stripeAdapter.UpdateSubscriptionAsync(provider.GatewaySubscriptionId,
new SubscriptionUpdateOptions { Items = subscriptionItemOptionsList });
}
}
Expand All @@ -807,7 +807,7 @@ private Func<int, Task> CurrySeatScalingUpdate(

var item = subscription.Items.First(item => item.Price.Id == priceId);

await stripeAdapter.SubscriptionUpdateAsync(provider.GatewaySubscriptionId, new SubscriptionUpdateOptions
await stripeAdapter.UpdateSubscriptionAsync(provider.GatewaySubscriptionId, new SubscriptionUpdateOptions
{
Items =
[
Expand Down
3 changes: 2 additions & 1 deletion bitwarden_license/src/Scim/Users/PostUserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
using Bit.Core.AdminConsole.Utilities.Commands;
using Bit.Core.Billing.Pricing;
using Bit.Core.Billing.Services;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
Expand All @@ -24,7 +25,7 @@ public class PostUserCommand(
IOrganizationRepository organizationRepository,
IOrganizationUserRepository organizationUserRepository,
IOrganizationService organizationService,
IPaymentService paymentService,
IStripePaymentService paymentService,
IScimContext scimContext,
IFeatureService featureService,
IInviteOrganizationUsersCommand inviteOrganizationUsersCommand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ await sutProvider.GetDependency<IMailService>().Received(1)
Arg.Is<IEnumerable<string>>(emails => emails.FirstOrDefault() == "[email protected]"));

await sutProvider.GetDependency<IStripeAdapter>().DidNotReceiveWithAnyArgs()
.CustomerUpdateAsync(Arg.Any<string>(), Arg.Any<CustomerUpdateOptions>());
.UpdateCustomerAsync(Arg.Any<string>(), Arg.Any<CustomerUpdateOptions>());
}

[Theory, BitAutoData]
Expand All @@ -156,20 +156,22 @@ public async Task RemoveOrganizationFromProvider_OrganizationStripeEnabled_NonCo
"[email protected]"
]);

sutProvider.GetDependency<IStripeAdapter>().SubscriptionGetAsync(organization.GatewaySubscriptionId, Arg.Is<SubscriptionGetOptions>(
sutProvider.GetDependency<IStripeAdapter>().GetSubscriptionAsync(organization.GatewaySubscriptionId, Arg.Is<SubscriptionGetOptions>(
options => options.Expand.Contains("customer")))
.Returns(GetSubscription(organization.GatewaySubscriptionId, organization.GatewayCustomerId));

await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization);

var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();

await stripeAdapter.Received(1).CustomerUpdateAsync(organization.GatewayCustomerId,
await stripeAdapter.Received(1).UpdateCustomerAsync(organization.GatewayCustomerId,
Arg.Is<CustomerUpdateOptions>(options => options.Email == "[email protected]"));

await stripeAdapter.Received(1).CustomerDeleteDiscountAsync(organization.GatewayCustomerId);

await stripeAdapter.Received(1).SubscriptionUpdateAsync(organization.GatewaySubscriptionId,
await stripeAdapter.Received(1).CustomerDeleteDiscountAsync(organization.GatewayCustomerId);

await stripeAdapter.Received(1).UpdateSubscriptionAsync(organization.GatewaySubscriptionId,
Arg.Is<SubscriptionUpdateOptions>(options =>
options.CollectionMethod == StripeConstants.CollectionMethod.SendInvoice &&
options.DaysUntilDue == 30));
Expand Down Expand Up @@ -226,7 +228,7 @@ public async Task RemoveOrganizationFromProvider_OrganizationStripeEnabled_Conso

var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();

stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, Arg.Is<CustomerUpdateOptions>(options =>
stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, Arg.Is<CustomerUpdateOptions>(options =>
options.Description == string.Empty &&
options.Email == organization.BillingEmail &&
options.Expand[0] == "tax" &&
Expand All @@ -239,14 +241,14 @@ public async Task RemoveOrganizationFromProvider_OrganizationStripeEnabled_Conso
}
});

stripeAdapter.SubscriptionCreateAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
stripeAdapter.CreateSubscriptionAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
{
Id = "subscription_id"
});

await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization);

await stripeAdapter.Received(1).SubscriptionCreateAsync(Arg.Is<SubscriptionCreateOptions>(options =>
await stripeAdapter.Received(1).CreateSubscriptionAsync(Arg.Is<SubscriptionCreateOptions>(options =>
options.Customer == organization.GatewayCustomerId &&
options.CollectionMethod == StripeConstants.CollectionMethod.SendInvoice &&
options.DaysUntilDue == 30 &&
Expand Down Expand Up @@ -315,7 +317,7 @@ public async Task RemoveOrganizationFromProvider_OrganizationStripeEnabled_Conso

var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();

stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, Arg.Is<CustomerUpdateOptions>(options =>
stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, Arg.Is<CustomerUpdateOptions>(options =>
options.Description == string.Empty &&
options.Email == organization.BillingEmail &&
options.Expand[0] == "tax" &&
Expand All @@ -328,14 +330,14 @@ public async Task RemoveOrganizationFromProvider_OrganizationStripeEnabled_Conso
}
});

stripeAdapter.SubscriptionCreateAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
stripeAdapter.CreateSubscriptionAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
{
Id = "subscription_id"
});

await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization);

await stripeAdapter.Received(1).SubscriptionCreateAsync(Arg.Is<SubscriptionCreateOptions>(options =>
await stripeAdapter.Received(1).CreateSubscriptionAsync(Arg.Is<SubscriptionCreateOptions>(options =>
options.Customer == organization.GatewayCustomerId &&
options.CollectionMethod == StripeConstants.CollectionMethod.SendInvoice &&
options.DaysUntilDue == 30 &&
Expand Down Expand Up @@ -434,7 +436,7 @@ public async Task RemoveOrganizationFromProvider_DisabledOrganization_Consolidat

var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();

stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, Arg.Any<CustomerUpdateOptions>())
stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, Arg.Any<CustomerUpdateOptions>())
.Returns(new Customer
{
Id = "customer_id",
Expand All @@ -444,7 +446,7 @@ public async Task RemoveOrganizationFromProvider_DisabledOrganization_Consolidat
}
});

stripeAdapter.SubscriptionCreateAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
stripeAdapter.CreateSubscriptionAsync(Arg.Any<SubscriptionCreateOptions>()).Returns(new Subscription
{
Id = "new_subscription_id"
});
Expand Down
Loading
Loading