Skip to content

Commit 579d800

Browse files
[PM-29224] Remove unused billing endpoints and code paths (#6692)
* Remove unused endpoints and code paths * MOAR DELETE * Run dotnet format
1 parent 3e12cfc commit 579d800

24 files changed

+28
-2056
lines changed

src/Api/Billing/Controllers/AccountsBillingController.cs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#nullable enable
2-
using Bit.Api.Billing.Models.Responses;
1+
using Bit.Api.Billing.Models.Responses;
32
using Bit.Core.Billing.Services;
4-
using Bit.Core.Billing.Tax.Requests;
53
using Bit.Core.Services;
64
using Bit.Core.Utilities;
75
using Microsoft.AspNetCore.Authorization;
@@ -16,6 +14,7 @@ public class AccountsBillingController(
1614
IUserService userService,
1715
IPaymentHistoryService paymentHistoryService) : Controller
1816
{
17+
// TODO: Migrate to Query / AccountBillingVNextController
1918
[HttpGet("history")]
2019
[SelfHosted(NotSelfHostedOnly = true)]
2120
public async Task<BillingHistoryResponseModel> GetBillingHistoryAsync()
@@ -30,20 +29,7 @@ public async Task<BillingHistoryResponseModel> GetBillingHistoryAsync()
3029
return new BillingHistoryResponseModel(billingInfo);
3130
}
3231

33-
[HttpGet("payment-method")]
34-
[SelfHosted(NotSelfHostedOnly = true)]
35-
public async Task<BillingPaymentResponseModel> GetPaymentMethodAsync()
36-
{
37-
var user = await userService.GetUserByPrincipalAsync(User);
38-
if (user == null)
39-
{
40-
throw new UnauthorizedAccessException();
41-
}
42-
43-
var billingInfo = await paymentService.GetBillingAsync(user);
44-
return new BillingPaymentResponseModel(billingInfo);
45-
}
46-
32+
// TODO: Migrate to Query / AccountBillingVNextController
4733
[HttpGet("invoices")]
4834
public async Task<IResult> GetInvoicesAsync([FromQuery] string? status = null, [FromQuery] string? startAfter = null)
4935
{
@@ -62,6 +48,7 @@ public async Task<IResult> GetInvoicesAsync([FromQuery] string? status = null, [
6248
return TypedResults.Ok(invoices);
6349
}
6450

51+
// TODO: Migrate to Query / AccountBillingVNextController
6552
[HttpGet("transactions")]
6653
public async Task<IResult> GetTransactionsAsync([FromQuery] DateTime? startAfter = null)
6754
{
@@ -78,18 +65,4 @@ public async Task<IResult> GetTransactionsAsync([FromQuery] DateTime? startAfter
7865

7966
return TypedResults.Ok(transactions);
8067
}
81-
82-
[HttpPost("preview-invoice")]
83-
public async Task<IResult> PreviewInvoiceAsync([FromBody] PreviewIndividualInvoiceRequestBody model)
84-
{
85-
var user = await userService.GetUserByPrincipalAsync(User);
86-
if (user == null)
87-
{
88-
throw new UnauthorizedAccessException();
89-
}
90-
91-
var invoice = await paymentService.PreviewInvoiceAsync(model, user.GatewayCustomerId, user.GatewaySubscriptionId);
92-
93-
return TypedResults.Ok(invoice);
94-
}
9568
}

src/Api/Billing/Controllers/AccountsController.cs

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#nullable enable
2-
3-
using Bit.Api.Models.Request;
1+
using Bit.Api.Models.Request;
42
using Bit.Api.Models.Request.Accounts;
53
using Bit.Api.Models.Response;
64
using Bit.Api.Utilities;
@@ -29,6 +27,7 @@ public class AccountsController(
2927
IFeatureService featureService,
3028
ILicensingService licensingService) : Controller
3129
{
30+
// TODO: Remove when pm-24996-implement-upgrade-from-free-dialog is removed
3231
[HttpPost("premium")]
3332
public async Task<PaymentResponseModel> PostPremiumAsync(
3433
PremiumRequestModel model,
@@ -76,6 +75,7 @@ public async Task<PaymentResponseModel> PostPremiumAsync(
7675
};
7776
}
7877

78+
// TODO: Migrate to Query / AccountBillingVNextController as part of Premium -> Organization upgrade work.
7979
[HttpGet("subscription")]
8080
public async Task<SubscriptionResponseModel> GetSubscriptionAsync(
8181
[FromServices] GlobalSettings globalSettings,
@@ -114,29 +114,7 @@ public async Task<SubscriptionResponseModel> GetSubscriptionAsync(
114114
}
115115
}
116116

117-
[HttpPost("payment")]
118-
[SelfHosted(NotSelfHostedOnly = true)]
119-
public async Task PostPaymentAsync([FromBody] PaymentRequestModel model)
120-
{
121-
var user = await userService.GetUserByPrincipalAsync(User);
122-
if (user == null)
123-
{
124-
throw new UnauthorizedAccessException();
125-
}
126-
127-
await userService.ReplacePaymentMethodAsync(user, model.PaymentToken, model.PaymentMethodType!.Value,
128-
new TaxInfo
129-
{
130-
BillingAddressLine1 = model.Line1,
131-
BillingAddressLine2 = model.Line2,
132-
BillingAddressCity = model.City,
133-
BillingAddressState = model.State,
134-
BillingAddressCountry = model.Country,
135-
BillingAddressPostalCode = model.PostalCode,
136-
TaxIdNumber = model.TaxId
137-
});
138-
}
139-
117+
// TODO: Migrate to Command / AccountBillingVNextController as PUT /account/billing/vnext/subscription
140118
[HttpPost("storage")]
141119
[SelfHosted(NotSelfHostedOnly = true)]
142120
public async Task<PaymentResponseModel> PostStorageAsync([FromBody] StorageRequestModel model)
@@ -151,8 +129,11 @@ public async Task<PaymentResponseModel> PostStorageAsync([FromBody] StorageReque
151129
return new PaymentResponseModel { Success = true, PaymentIntentClientSecret = result };
152130
}
153131

154-
155-
132+
/*
133+
* TODO: A new version of this exists in the AccountBillingVNextController.
134+
* The individual-self-hosting-license-uploader.component needs to be updated to use it.
135+
* Then, this can be removed.
136+
*/
156137
[HttpPost("license")]
157138
[SelfHosted(SelfHostedOnly = true)]
158139
public async Task PostLicenseAsync(LicenseRequestModel model)
@@ -172,6 +153,7 @@ public async Task PostLicenseAsync(LicenseRequestModel model)
172153
await userService.UpdateLicenseAsync(user, license);
173154
}
174155

156+
// TODO: Migrate to Command / AccountBillingVNextController as DELETE /account/billing/vnext/subscription
175157
[HttpPost("cancel")]
176158
public async Task PostCancelAsync(
177159
[FromBody] SubscriptionCancellationRequestModel request,
@@ -189,6 +171,7 @@ await subscriberService.CancelSubscription(user,
189171
user.IsExpired());
190172
}
191173

174+
// TODO: Migrate to Command / AccountBillingVNextController as POST /account/billing/vnext/subscription/reinstate
192175
[HttpPost("reinstate-premium")]
193176
[SelfHosted(NotSelfHostedOnly = true)]
194177
public async Task PostReinstateAsync()
@@ -202,41 +185,6 @@ public async Task PostReinstateAsync()
202185
await userService.ReinstatePremiumAsync(user);
203186
}
204187

205-
[HttpGet("tax")]
206-
[SelfHosted(NotSelfHostedOnly = true)]
207-
public async Task<TaxInfoResponseModel> GetTaxInfoAsync(
208-
[FromServices] IPaymentService paymentService)
209-
{
210-
var user = await userService.GetUserByPrincipalAsync(User);
211-
if (user == null)
212-
{
213-
throw new UnauthorizedAccessException();
214-
}
215-
216-
var taxInfo = await paymentService.GetTaxInfoAsync(user);
217-
return new TaxInfoResponseModel(taxInfo);
218-
}
219-
220-
[HttpPut("tax")]
221-
[SelfHosted(NotSelfHostedOnly = true)]
222-
public async Task PutTaxInfoAsync(
223-
[FromBody] TaxInfoUpdateRequestModel model,
224-
[FromServices] IPaymentService paymentService)
225-
{
226-
var user = await userService.GetUserByPrincipalAsync(User);
227-
if (user == null)
228-
{
229-
throw new UnauthorizedAccessException();
230-
}
231-
232-
var taxInfo = new TaxInfo
233-
{
234-
BillingAddressPostalCode = model.PostalCode,
235-
BillingAddressCountry = model.Country,
236-
};
237-
await paymentService.SaveTaxInfoAsync(user, taxInfo);
238-
}
239-
240188
private async Task<IEnumerable<Guid>> GetOrganizationIdsClaimingUserAsync(Guid userId)
241189
{
242190
var organizationsClaimingUser = await userService.GetOrganizationsClaimingUserAsync(userId);

src/Api/Billing/Controllers/InvoicesController.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/Api/Billing/Controllers/LicensesController.cs

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)