1
0
mirror of https://github.com/bitwarden/server synced 2026-01-10 12:33:49 +00:00

[PM-25088] - refactor premium purchase endpoint (#6262)

* [PM-25088] add feature flag for new premium subscription flow

* [PM-25088] refactor premium endpoint

* forgot the punctuation change in the test

* [PM-25088] - pr feedback

* [PM-25088] - pr feedback round two
This commit is contained in:
Kyle Denney
2025-09-10 10:08:22 -05:00
committed by GitHub
parent d43b00dad9
commit a458db319e
25 changed files with 1309 additions and 21 deletions

View File

@@ -26,4 +26,5 @@ public interface ILicensingService
SubscriptionInfo subscriptionInfo);
Task<string?> CreateUserTokenAsync(User user, SubscriptionInfo subscriptionInfo);
Task WriteUserLicenseAsync(User user, UserLicense license);
}

View File

@@ -389,4 +389,12 @@ public class LicensingService : ILicensingService
var token = tokenHandler.CreateToken(tokenDescriptor);
return tokenHandler.WriteToken(token);
}
public async Task WriteUserLicenseAsync(User user, UserLicense license)
{
var dir = $"{_globalSettings.LicenseDirectory}/user";
Directory.CreateDirectory(dir);
await using var fs = File.OpenWrite(Path.Combine(dir, $"{user.Id}.json"));
await JsonSerializer.SerializeAsync(fs, license, JsonHelpers.Indented);
}
}

View File

@@ -304,7 +304,7 @@ public class PremiumUserBillingService(
{
new ()
{
Price = "premium-annually",
Price = StripeConstants.Prices.PremiumAnnually,
Quantity = 1
}
};

View File

@@ -73,4 +73,9 @@ public class NoopLicensingService : ILicensingService
{
return Task.FromResult<string?>(null);
}
public Task WriteUserLicenseAsync(User user, UserLicense license)
{
return Task.CompletedTask;
}
}