mirror of
https://github.com/bitwarden/server.git
synced 2026-04-20 11:42:29 -05:00
rename the variable name validatedCoupon
This commit is contained in:
@@ -127,20 +127,17 @@ public class PreviewOrganizationTaxCommand(
|
||||
}
|
||||
|
||||
// Validate coupon and only apply if valid. If invalid, proceed without the discount.
|
||||
if (!string.IsNullOrWhiteSpace(purchase.Coupon))
|
||||
// Only Families plans support user-provided coupons
|
||||
if (!string.IsNullOrWhiteSpace(purchase.Coupon) && purchase.Tier == ProductTierType.Families)
|
||||
{
|
||||
// Only Families plans support user-provided coupons
|
||||
if (purchase.Tier == ProductTierType.Families)
|
||||
{
|
||||
var isValid = await subscriptionDiscountService.ValidateDiscountForUserAsync(
|
||||
user,
|
||||
purchase.Coupon.Trim(),
|
||||
DiscountAudienceType.UserHasNoPreviousSubscriptions);
|
||||
var isValid = await subscriptionDiscountService.ValidateDiscountForUserAsync(
|
||||
user,
|
||||
purchase.Coupon.Trim(),
|
||||
DiscountAudienceType.UserHasNoPreviousSubscriptions);
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
options.Discounts = [new InvoiceDiscountOptions { Coupon = purchase.Coupon.Trim() }];
|
||||
}
|
||||
if (isValid)
|
||||
{
|
||||
options.Discounts = [new InvoiceDiscountOptions { Coupon = purchase.Coupon.Trim() }];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CreatePremiumCloudHostedSubscriptionCommand(
|
||||
return new BadRequest("Already a premium user.");
|
||||
}
|
||||
|
||||
if (subscriptionPurchase.AdditionalStorageGb.HasValue && subscriptionPurchase.AdditionalStorageGb < 0)
|
||||
if (subscriptionPurchase.AdditionalStorageGb is < 0)
|
||||
{
|
||||
return new BadRequest("Additional storage must be greater than 0.");
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public class CreatePremiumCloudHostedSubscriptionCommand(
|
||||
Customer customer,
|
||||
Pricing.Premium.Plan premiumPlan,
|
||||
int? storage,
|
||||
string? coupon)
|
||||
string? validatedCoupon)
|
||||
{
|
||||
|
||||
var subscriptionItemOptionsList = new List<SubscriptionItemOptions>
|
||||
@@ -370,9 +370,9 @@ public class CreatePremiumCloudHostedSubscriptionCommand(
|
||||
OffSession = true
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(coupon))
|
||||
if (!string.IsNullOrWhiteSpace(validatedCoupon))
|
||||
{
|
||||
subscriptionCreateOptions.Discounts = [new SubscriptionDiscountOptions { Coupon = coupon.Trim() }];
|
||||
subscriptionCreateOptions.Discounts = [new SubscriptionDiscountOptions { Coupon = validatedCoupon }];
|
||||
}
|
||||
|
||||
var subscription = await stripeAdapter.CreateSubscriptionAsync(subscriptionCreateOptions);
|
||||
|
||||
Reference in New Issue
Block a user