mirror of
https://github.com/bitwarden/server.git
synced 2025-12-13 02:58:10 -06:00
Enable disabled provider on successful update payment method invocation (#6129)
This commit is contained in:
parent
cff34b9194
commit
db4beb47f7
@ -1,8 +1,8 @@
|
|||||||
#nullable enable
|
using Bit.Api.Billing.Attributes;
|
||||||
using Bit.Api.Billing.Attributes;
|
|
||||||
using Bit.Api.Billing.Models.Requests.Payment;
|
using Bit.Api.Billing.Models.Requests.Payment;
|
||||||
using Bit.Core.AdminConsole.Entities.Provider;
|
using Bit.Core.AdminConsole.Entities.Provider;
|
||||||
using Bit.Core.AdminConsole.Enums.Provider;
|
using Bit.Core.AdminConsole.Enums.Provider;
|
||||||
|
using Bit.Core.AdminConsole.Services;
|
||||||
using Bit.Core.Billing.Payment.Commands;
|
using Bit.Core.Billing.Payment.Commands;
|
||||||
using Bit.Core.Billing.Payment.Queries;
|
using Bit.Core.Billing.Payment.Queries;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
@ -19,6 +19,7 @@ public class ProviderBillingVNextController(
|
|||||||
IGetBillingAddressQuery getBillingAddressQuery,
|
IGetBillingAddressQuery getBillingAddressQuery,
|
||||||
IGetCreditQuery getCreditQuery,
|
IGetCreditQuery getCreditQuery,
|
||||||
IGetPaymentMethodQuery getPaymentMethodQuery,
|
IGetPaymentMethodQuery getPaymentMethodQuery,
|
||||||
|
IProviderService providerService,
|
||||||
IUpdateBillingAddressCommand updateBillingAddressCommand,
|
IUpdateBillingAddressCommand updateBillingAddressCommand,
|
||||||
IUpdatePaymentMethodCommand updatePaymentMethodCommand,
|
IUpdatePaymentMethodCommand updatePaymentMethodCommand,
|
||||||
IVerifyBankAccountCommand verifyBankAccountCommand) : BaseBillingController
|
IVerifyBankAccountCommand verifyBankAccountCommand) : BaseBillingController
|
||||||
@ -82,6 +83,15 @@ public class ProviderBillingVNextController(
|
|||||||
{
|
{
|
||||||
var (paymentMethod, billingAddress) = request.ToDomain();
|
var (paymentMethod, billingAddress) = request.ToDomain();
|
||||||
var result = await updatePaymentMethodCommand.Run(provider, paymentMethod, billingAddress);
|
var result = await updatePaymentMethodCommand.Run(provider, paymentMethod, billingAddress);
|
||||||
|
// TODO: Temporary until we can send Provider notifications from the Billing API
|
||||||
|
if (!provider.Enabled)
|
||||||
|
{
|
||||||
|
await result.TapAsync(async _ =>
|
||||||
|
{
|
||||||
|
provider.Enabled = true;
|
||||||
|
await providerService.UpdateAsync(provider);
|
||||||
|
});
|
||||||
|
}
|
||||||
return Handle(result);
|
return Handle(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,4 +28,10 @@ public class BillingCommandResult<T> : OneOfBase<T, BadRequest, Conflict, Unhand
|
|||||||
public static implicit operator BillingCommandResult<T>(BadRequest badRequest) => new(badRequest);
|
public static implicit operator BillingCommandResult<T>(BadRequest badRequest) => new(badRequest);
|
||||||
public static implicit operator BillingCommandResult<T>(Conflict conflict) => new(conflict);
|
public static implicit operator BillingCommandResult<T>(Conflict conflict) => new(conflict);
|
||||||
public static implicit operator BillingCommandResult<T>(Unhandled unhandled) => new(unhandled);
|
public static implicit operator BillingCommandResult<T>(Unhandled unhandled) => new(unhandled);
|
||||||
|
|
||||||
|
public Task TapAsync(Func<T, Task> f) => Match(
|
||||||
|
f,
|
||||||
|
_ => Task.CompletedTask,
|
||||||
|
_ => Task.CompletedTask,
|
||||||
|
_ => Task.CompletedTask);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user