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:
@@ -26,4 +26,5 @@ public interface ILicensingService
|
||||
SubscriptionInfo subscriptionInfo);
|
||||
|
||||
Task<string?> CreateUserTokenAsync(User user, SubscriptionInfo subscriptionInfo);
|
||||
Task WriteUserLicenseAsync(User user, UserLicense license);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public class PremiumUserBillingService(
|
||||
{
|
||||
new ()
|
||||
{
|
||||
Price = "premium-annually",
|
||||
Price = StripeConstants.Prices.PremiumAnnually,
|
||||
Quantity = 1
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,4 +73,9 @@ public class NoopLicensingService : ILicensingService
|
||||
{
|
||||
return Task.FromResult<string?>(null);
|
||||
}
|
||||
|
||||
public Task WriteUserLicenseAsync(User user, UserLicense license)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user