mirror of
https://github.com/bitwarden/server
synced 2025-12-21 02:33:30 +00:00
[PM-25123] Remove VerifyBankAsync Code (#6355)
* refactor: remove VerifyBankAsync from interface and implementation * refactor: remove controller endpoint
This commit is contained in:
@@ -211,18 +211,6 @@ public class OrganizationsController(
|
|||||||
return new PaymentResponseModel { Success = true, PaymentIntentClientSecret = result };
|
return new PaymentResponseModel { Success = true, PaymentIntentClientSecret = result };
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id:guid}/verify-bank")]
|
|
||||||
[SelfHosted(NotSelfHostedOnly = true)]
|
|
||||||
public async Task PostVerifyBank(Guid id, [FromBody] OrganizationVerifyBankRequestModel model)
|
|
||||||
{
|
|
||||||
if (!await currentContext.EditSubscription(id))
|
|
||||||
{
|
|
||||||
throw new NotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
await organizationService.VerifyBankAsync(id, model.Amount1.Value, model.Amount2.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("{id}/cancel")]
|
[HttpPost("{id}/cancel")]
|
||||||
public async Task PostCancel(Guid id, [FromBody] SubscriptionCancellationRequestModel request)
|
public async Task PostCancel(Guid id, [FromBody] SubscriptionCancellationRequestModel request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public interface IOrganizationService
|
|||||||
Task UpdateSubscription(Guid organizationId, int seatAdjustment, int? maxAutoscaleSeats);
|
Task UpdateSubscription(Guid organizationId, int seatAdjustment, int? maxAutoscaleSeats);
|
||||||
Task AutoAddSeatsAsync(Organization organization, int seatsToAdd);
|
Task AutoAddSeatsAsync(Organization organization, int seatsToAdd);
|
||||||
Task<string> AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
|
Task<string> AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
|
||||||
Task VerifyBankAsync(Guid organizationId, int amount1, int amount2);
|
|
||||||
Task UpdateExpirationDateAsync(Guid organizationId, DateTime? expirationDate);
|
Task UpdateExpirationDateAsync(Guid organizationId, DateTime? expirationDate);
|
||||||
Task UpdateAsync(Organization organization, bool updateBilling = false);
|
Task UpdateAsync(Organization organization, bool updateBilling = false);
|
||||||
Task<Organization> UpdateCollectionManagementSettingsAsync(Guid organizationId, OrganizationCollectionManagementSettings settings);
|
Task<Organization> UpdateCollectionManagementSettingsAsync(Guid organizationId, OrganizationCollectionManagementSettings settings);
|
||||||
|
|||||||
@@ -325,49 +325,6 @@ public class OrganizationService : IOrganizationService
|
|||||||
return paymentIntentClientSecret;
|
return paymentIntentClientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task VerifyBankAsync(Guid organizationId, int amount1, int amount2)
|
|
||||||
{
|
|
||||||
var organization = await GetOrgById(organizationId);
|
|
||||||
if (organization == null)
|
|
||||||
{
|
|
||||||
throw new NotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(organization.GatewayCustomerId))
|
|
||||||
{
|
|
||||||
throw new GatewayException("Not a gateway customer.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var bankService = new BankAccountService();
|
|
||||||
var customer = await _stripeAdapter.CustomerGetAsync(organization.GatewayCustomerId,
|
|
||||||
new CustomerGetOptions { Expand = new List<string> { "sources" } });
|
|
||||||
if (customer == null)
|
|
||||||
{
|
|
||||||
throw new GatewayException("Cannot find customer.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var bankAccount = customer.Sources
|
|
||||||
.FirstOrDefault(s => s is BankAccount && ((BankAccount)s).Status != "verified") as BankAccount;
|
|
||||||
if (bankAccount == null)
|
|
||||||
{
|
|
||||||
throw new GatewayException("Cannot find an unverified bank account.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = await bankService.VerifyAsync(organization.GatewayCustomerId, bankAccount.Id,
|
|
||||||
new BankAccountVerifyOptions { Amounts = new List<long> { amount1, amount2 } });
|
|
||||||
if (result.Status != "verified")
|
|
||||||
{
|
|
||||||
throw new GatewayException("Unable to verify account.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (StripeException e)
|
|
||||||
{
|
|
||||||
throw new GatewayException(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateExpirationDateAsync(Guid organizationId, DateTime? expirationDate)
|
public async Task UpdateExpirationDateAsync(Guid organizationId, DateTime? expirationDate)
|
||||||
{
|
{
|
||||||
var org = await GetOrgById(organizationId);
|
var org = await GetOrgById(organizationId);
|
||||||
|
|||||||
Reference in New Issue
Block a user