diff --git a/app/Http/Controllers/Settings/SubscriptionController.php b/app/Http/Controllers/Settings/SubscriptionController.php index 1957a7c65..f3b6e3997 100644 --- a/app/Http/Controllers/Settings/SubscriptionController.php +++ b/app/Http/Controllers/Settings/SubscriptionController.php @@ -115,7 +115,7 @@ public function change(Request $request, Tier $tier) $period = $request->get('period') === 'yearly' ? PricingPeriod::Yearly : PricingPeriod::Monthly; // If the user has a cancelled sub still ending - if ($user->subscribed('kanka') && $user->subscription('kanka')->onGracePeriod()) { + if ($user->subscribed('kanka') && $user->subscription('kanka')->onGracePeriod() && !$user->hasPayPal()) { return view('settings.subscription.change_blocked') ->with('user', $user); } diff --git a/app/Services/PayPalService.php b/app/Services/PayPalService.php index 2c4a0d6a8..ea68d2063 100644 --- a/app/Services/PayPalService.php +++ b/app/Services/PayPalService.php @@ -47,9 +47,9 @@ public function process(): mixed $oldPrice = $tier->yearly; } // @phpstan-ignore-next-line - $price = (floatval($price) - ($oldPrice)) * ($this->user->subscriptions()->first()->ends_at->diffInDays(Carbon::now()) / 365); - $price = number_format($price, 2); + $price = round(($price - ($oldPrice)) * ($this->user->subscriptions()->first()->ends_at->diffInDays(Carbon::now(), true) / 365), 2); } + $price = max(0, $price); $provider = new PayPal(); $provider->setApiCredentials(config('paypal'));