From f149f247d533e3b6e0639a1beba1b7cbba8ff5aa Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:55:07 -0400 Subject: [PATCH] Don't try to credit customer \$0 (#4964) --- .../Implementations/ProviderMigrator.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Core/Billing/Migration/Services/Implementations/ProviderMigrator.cs b/src/Core/Billing/Migration/Services/Implementations/ProviderMigrator.cs index 9ca515a26..ea456e920 100644 --- a/src/Core/Billing/Migration/Services/Implementations/ProviderMigrator.cs +++ b/src/Core/Billing/Migration/Services/Implementations/ProviderMigrator.cs @@ -325,13 +325,16 @@ public class ProviderMigrator( var organizationCancellationCredit = organizationCustomers.Sum(customer => customer.Balance); - await stripeAdapter.CustomerBalanceTransactionCreate(provider.GatewayCustomerId, - new CustomerBalanceTransactionCreateOptions - { - Amount = organizationCancellationCredit, - Currency = "USD", - Description = "Unused, prorated time for client organization subscriptions." - }); + if (organizationCancellationCredit != 0) + { + await stripeAdapter.CustomerBalanceTransactionCreate(provider.GatewayCustomerId, + new CustomerBalanceTransactionCreateOptions + { + Amount = organizationCancellationCredit, + Currency = "USD", + Description = "Unused, prorated time for client organization subscriptions." + }); + } var migrationRecords = await Task.WhenAll(organizations.Select(organization => clientOrganizationMigrationRecordRepository.GetByOrganizationId(organization.Id)));