feat: implement upgrade validation to prevent downgrades and enhance service upgrade process with improved error handling

This commit is contained in:
2025-12-04 06:21:10 -05:00
parent 3e3f5187d1
commit 97b15e07c5
3 changed files with 356 additions and 45 deletions

View File

@@ -191,8 +191,14 @@ class Service extends Model
// Only get the upgrades that have the exact same billing cycle as the service
if ($plan->count() > 0) {
$product->plan = $plan->first();
return $product;
// Only allow upgrades (not downgrades) - check if new price is greater than or equal to current price
$currentPrice = $this->plan->price()->price;
$newPrice = $product->plan->price()->price;
if ($newPrice >= $currentPrice) {
return $product;
}
}
return null;