feat: implement upgrade validation to prevent downgrades and enhance service upgrade process with improved error handling
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user