From 73692a0c73a1795379d8d597e6b04f6c59d02334 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 24 Jun 2024 11:52:12 +0200 Subject: [PATCH] fix: remove cloud stripe notifications --- app/Http/Controllers/Webhook/Stripe.php | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Webhook/Stripe.php b/app/Http/Controllers/Webhook/Stripe.php index e404a8ebc..230525c0e 100644 --- a/app/Http/Controllers/Webhook/Stripe.php +++ b/app/Http/Controllers/Webhook/Stripe.php @@ -72,14 +72,14 @@ public function events(Request $request) } $subscription = Subscription::where('team_id', $teamId)->first(); if ($subscription) { - send_internal_notification('Old subscription activated for team: '.$teamId); + // send_internal_notification('Old subscription activated for team: '.$teamId); $subscription->update([ 'stripe_subscription_id' => $subscriptionId, 'stripe_customer_id' => $customerId, 'stripe_invoice_paid' => true, ]); } else { - send_internal_notification('New subscription for team: '.$teamId); + // send_internal_notification('New subscription for team: '.$teamId); Subscription::create([ 'team_id' => $teamId, 'stripe_subscription_id' => $subscriptionId, @@ -92,7 +92,7 @@ public function events(Request $request) $customerId = data_get($data, 'customer'); $planId = data_get($data, 'lines.data.0.plan.id'); if (Str::contains($excludedPlans, $planId)) { - send_internal_notification('Subscription excluded.'); + // send_internal_notification('Subscription excluded.'); break; } $subscription = Subscription::where('stripe_customer_id', $customerId)->first(); @@ -108,33 +108,33 @@ public function events(Request $request) $customerId = data_get($data, 'customer'); $subscription = Subscription::where('stripe_customer_id', $customerId)->first(); if (! $subscription) { - send_internal_notification('invoice.payment_failed failed but no subscription found in Coolify for customer: '.$customerId); + // send_internal_notification('invoice.payment_failed failed but no subscription found in Coolify for customer: '.$customerId); return response('No subscription found in Coolify.'); } $team = data_get($subscription, 'team'); if (! $team) { - send_internal_notification('invoice.payment_failed failed but no team found in Coolify for customer: '.$customerId); + // send_internal_notification('invoice.payment_failed failed but no team found in Coolify for customer: '.$customerId); return response('No team found in Coolify.'); } if (! $subscription->stripe_invoice_paid) { SubscriptionInvoiceFailedJob::dispatch($team); - send_internal_notification('Invoice payment failed: '.$customerId); + // send_internal_notification('Invoice payment failed: '.$customerId); } else { - send_internal_notification('Invoice payment failed but already paid: '.$customerId); + // send_internal_notification('Invoice payment failed but already paid: '.$customerId); } break; case 'payment_intent.payment_failed': $customerId = data_get($data, 'customer'); $subscription = Subscription::where('stripe_customer_id', $customerId)->first(); if (! $subscription) { - send_internal_notification('payment_intent.payment_failed, no subscription found in Coolify for customer: '.$customerId); + // send_internal_notification('payment_intent.payment_failed, no subscription found in Coolify for customer: '.$customerId); return response('No subscription found in Coolify.'); } if ($subscription->stripe_invoice_paid) { - send_internal_notification('payment_intent.payment_failed but invoice is active for customer: '.$customerId); + // send_internal_notification('payment_intent.payment_failed but invoice is active for customer: '.$customerId); return; } @@ -146,7 +146,7 @@ public function events(Request $request) $subscriptionId = data_get($data, 'items.data.0.subscription'); $planId = data_get($data, 'items.data.0.plan.id'); if (Str::contains($excludedPlans, $planId)) { - send_internal_notification('Subscription excluded.'); + // send_internal_notification('Subscription excluded.'); break; } $subscription = Subscription::where('stripe_customer_id', $customerId)->first(); @@ -156,11 +156,11 @@ public function events(Request $request) } if (! $subscription) { if ($status === 'incomplete_expired') { - send_internal_notification('Subscription incomplete expired for customer: '.$customerId); + // send_internal_notification('Subscription incomplete expired for customer: '.$customerId); return response('Subscription incomplete expired', 200); } - send_internal_notification('No subscription found for: '.$customerId); + // send_internal_notification('No subscription found for: '.$customerId); return response('No subscription found', 400); } @@ -194,7 +194,7 @@ public function events(Request $request) $subscription->update([ 'stripe_invoice_paid' => false, ]); - send_internal_notification('Subscription paused or incomplete for customer: '.$customerId); + // send_internal_notification('Subscription paused or incomplete for customer: '.$customerId); } // Trial ended but subscribed, reactive servers @@ -208,13 +208,13 @@ public function events(Request $request) if ($comment) { $reason .= ' with comment: \''.$comment."'"; } - send_internal_notification($reason); + // send_internal_notification($reason); } if ($alreadyCancelAtPeriodEnd !== $cancelAtPeriodEnd) { if ($cancelAtPeriodEnd) { // send_internal_notification('Subscription cancelled at period end for team: ' . $subscription->team->id); } else { - send_internal_notification('customer.subscription.updated for customer: '.$customerId); + // send_internal_notification('customer.subscription.updated for customer: '.$customerId); } } break; @@ -233,7 +233,7 @@ public function events(Request $request) 'stripe_invoice_paid' => false, 'stripe_trial_already_ended' => true, ]); - send_internal_notification('customer.subscription.deleted for customer: '.$customerId); + // send_internal_notification('customer.subscription.deleted for customer: '.$customerId); break; case 'customer.subscription.trial_will_end': // Not used for now @@ -258,7 +258,7 @@ public function events(Request $request) 'stripe_invoice_paid' => false, ]); SubscriptionTrialEndedJob::dispatch($team); - send_internal_notification('Subscription paused for customer: '.$customerId); + // send_internal_notification('Subscription paused for customer: '.$customerId); break; default: // Unhandled event type