diff --git a/backend/app/Http/Controllers/Api/SubscriptionController.php b/backend/app/Http/Controllers/Api/SubscriptionController.php index 39bf06a..fcd35aa 100755 --- a/backend/app/Http/Controllers/Api/SubscriptionController.php +++ b/backend/app/Http/Controllers/Api/SubscriptionController.php @@ -1109,13 +1109,14 @@ private function applyRetentionOffer($user, Subscription $subscription, $feedbac : now()->addMonths(3); $subscription->save(); - // Cancel PayPal subscription for 3 months (pause) - if ($subscription->paypal_subscription_id) { + // Suspend PayPal subscription for 3 months (skip admin-granted subscriptions) + if ($subscription->paypal_subscription_id && !str_starts_with($subscription->paypal_subscription_id, 'ADMIN_GRANTED_')) { try { $this->paypal->suspendSubscription($subscription->paypal_subscription_id); } catch (\Exception $e) { Log::warning('Failed to suspend PayPal subscription', [ 'subscription_id' => $subscription->id, + 'paypal_id' => $subscription->paypal_subscription_id, 'error' => $e->getMessage(), ]); } @@ -1177,13 +1178,14 @@ private function executeCancellation($user, Subscription $subscription, $reason, try { $withinGuaranteePeriod = $subscription->created_at->diffInDays(now()) <= 7; - // Cancel on PayPal if exists - if ($subscription->paypal_subscription_id) { + // Cancel on PayPal if exists (skip admin-granted subscriptions) + if ($subscription->paypal_subscription_id && !str_starts_with($subscription->paypal_subscription_id, 'ADMIN_GRANTED_')) { try { $this->paypal->cancelSubscription($subscription->paypal_subscription_id); } catch (\Exception $e) { Log::warning('Failed to cancel PayPal subscription', [ 'subscription_id' => $subscription->id, + 'paypal_id' => $subscription->paypal_subscription_id, 'error' => $e->getMessage(), ]); } @@ -1213,9 +1215,9 @@ private function executeCancellation($user, Subscription $subscription, $reason, try { Mail::to($user->email)->send(new SubscriptionCancelledMail( $user, - $subscription->plan, - $subscription->ends_at, - $withinGuaranteePeriod + $subscription->plan->name, + $withinGuaranteePeriod, + $withinGuaranteePeriod ? $subscription->plan->formatted_price : null )); } catch (\Exception $e) { Log::warning('Failed to send cancellation email', [