[PM-21878] update gateway/stripe fields for business units (#6186)
* [PM-21878] also update gateway/stripe fields for business units
* pr feedback: replacing switch with extension method
* [PM-21878] prevent invalid stripe ids from crashing the edit provider page
* pr feedback: adding service methods to validate stripe ids
and added unit tests for the new methods
* pr feedback: move validation to SubscriberService and cleanup
* pr feedback: use subscriber service to remove dependency on stripe adapter
@ -6,6 +6,7 @@ using Bit.Core.AdminConsole.Entities.Provider;
@@ -6,6 +6,7 @@ using Bit.Core.AdminConsole.Entities.Provider;
usingBit.Core.AdminConsole.Enums.Provider;
usingBit.Core.AdminConsole.Models.Data.Provider;
usingBit.Core.Billing.Enums;
usingBit.Core.Billing.Extensions;
usingBit.Core.Billing.Providers.Entities;
usingBit.Core.Enums;
usingBit.SharedWeb.Utilities;
@ -87,14 +88,13 @@ public class ProviderEditModel : ProviderViewModel, IValidatableObject
@@ -87,14 +88,13 @@ public class ProviderEditModel : ProviderViewModel, IValidatableObject
@ -157,4 +157,22 @@ public interface ISubscriberService
@@ -157,4 +157,22 @@ public interface ISubscriberService
TaskVerifyBankAccount(
ISubscribersubscriber,
stringdescriptorCode);
/// <summary>
/// Validates whether the <paramref name="subscriber"/>'s <see cref="ISubscriber.GatewayCustomerId"/> exists in the gateway.
/// If the <paramref name="subscriber"/>'s <see cref="ISubscriber.GatewayCustomerId"/> is <see langword="null"/> or empty, returns <see langword="true"/>.
/// </summary>
/// <param name="subscriber">The subscriber whose gateway customer ID should be validated.</param>
/// <returns><see langword="true"/> if the gateway customer ID is valid or empty; <see langword="false"/> if the customer doesn't exist in the gateway.</returns>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="subscriber"/> is <see langword="null"/>.</exception>
/// Validates whether the <paramref name="subscriber"/>'s <see cref="ISubscriber.GatewaySubscriptionId"/> exists in the gateway.
/// If the <paramref name="subscriber"/>'s <see cref="ISubscriber.GatewaySubscriptionId"/> is <see langword="null"/> or empty, returns <see langword="true"/>.
/// </summary>
/// <param name="subscriber">The subscriber whose gateway subscription ID should be validated.</param>
/// <returns><see langword="true"/> if the gateway subscription ID is valid or empty; <see langword="false"/> if the subscription doesn't exist in the gateway.</returns>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="subscriber"/> is <see langword="null"/>.</exception>