fix: remove cloud stripe notifications
This commit is contained in:
parent
50191221b9
commit
73692a0c73
@ -72,14 +72,14 @@ class Stripe extends Controller
|
|||||||
}
|
}
|
||||||
$subscription = Subscription::where('team_id', $teamId)->first();
|
$subscription = Subscription::where('team_id', $teamId)->first();
|
||||||
if ($subscription) {
|
if ($subscription) {
|
||||||
send_internal_notification('Old subscription activated for team: '.$teamId);
|
// send_internal_notification('Old subscription activated for team: '.$teamId);
|
||||||
$subscription->update([
|
$subscription->update([
|
||||||
'stripe_subscription_id' => $subscriptionId,
|
'stripe_subscription_id' => $subscriptionId,
|
||||||
'stripe_customer_id' => $customerId,
|
'stripe_customer_id' => $customerId,
|
||||||
'stripe_invoice_paid' => true,
|
'stripe_invoice_paid' => true,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
send_internal_notification('New subscription for team: '.$teamId);
|
// send_internal_notification('New subscription for team: '.$teamId);
|
||||||
Subscription::create([
|
Subscription::create([
|
||||||
'team_id' => $teamId,
|
'team_id' => $teamId,
|
||||||
'stripe_subscription_id' => $subscriptionId,
|
'stripe_subscription_id' => $subscriptionId,
|
||||||
@ -92,7 +92,7 @@ class Stripe extends Controller
|
|||||||
$customerId = data_get($data, 'customer');
|
$customerId = data_get($data, 'customer');
|
||||||
$planId = data_get($data, 'lines.data.0.plan.id');
|
$planId = data_get($data, 'lines.data.0.plan.id');
|
||||||
if (Str::contains($excludedPlans, $planId)) {
|
if (Str::contains($excludedPlans, $planId)) {
|
||||||
send_internal_notification('Subscription excluded.');
|
// send_internal_notification('Subscription excluded.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
||||||
@ -108,33 +108,33 @@ class Stripe extends Controller
|
|||||||
$customerId = data_get($data, 'customer');
|
$customerId = data_get($data, 'customer');
|
||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
||||||
if (! $subscription) {
|
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.');
|
return response('No subscription found in Coolify.');
|
||||||
}
|
}
|
||||||
$team = data_get($subscription, 'team');
|
$team = data_get($subscription, 'team');
|
||||||
if (! $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.');
|
return response('No team found in Coolify.');
|
||||||
}
|
}
|
||||||
if (! $subscription->stripe_invoice_paid) {
|
if (! $subscription->stripe_invoice_paid) {
|
||||||
SubscriptionInvoiceFailedJob::dispatch($team);
|
SubscriptionInvoiceFailedJob::dispatch($team);
|
||||||
send_internal_notification('Invoice payment failed: '.$customerId);
|
// send_internal_notification('Invoice payment failed: '.$customerId);
|
||||||
} else {
|
} else {
|
||||||
send_internal_notification('Invoice payment failed but already paid: '.$customerId);
|
// send_internal_notification('Invoice payment failed but already paid: '.$customerId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'payment_intent.payment_failed':
|
case 'payment_intent.payment_failed':
|
||||||
$customerId = data_get($data, 'customer');
|
$customerId = data_get($data, 'customer');
|
||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
||||||
if (! $subscription) {
|
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.');
|
return response('No subscription found in Coolify.');
|
||||||
}
|
}
|
||||||
if ($subscription->stripe_invoice_paid) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ class Stripe extends Controller
|
|||||||
$subscriptionId = data_get($data, 'items.data.0.subscription');
|
$subscriptionId = data_get($data, 'items.data.0.subscription');
|
||||||
$planId = data_get($data, 'items.data.0.plan.id');
|
$planId = data_get($data, 'items.data.0.plan.id');
|
||||||
if (Str::contains($excludedPlans, $planId)) {
|
if (Str::contains($excludedPlans, $planId)) {
|
||||||
send_internal_notification('Subscription excluded.');
|
// send_internal_notification('Subscription excluded.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
||||||
@ -156,11 +156,11 @@ class Stripe extends Controller
|
|||||||
}
|
}
|
||||||
if (! $subscription) {
|
if (! $subscription) {
|
||||||
if ($status === 'incomplete_expired') {
|
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);
|
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);
|
return response('No subscription found', 400);
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ class Stripe extends Controller
|
|||||||
$subscription->update([
|
$subscription->update([
|
||||||
'stripe_invoice_paid' => false,
|
'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
|
// Trial ended but subscribed, reactive servers
|
||||||
@ -208,13 +208,13 @@ class Stripe extends Controller
|
|||||||
if ($comment) {
|
if ($comment) {
|
||||||
$reason .= ' with comment: \''.$comment."'";
|
$reason .= ' with comment: \''.$comment."'";
|
||||||
}
|
}
|
||||||
send_internal_notification($reason);
|
// send_internal_notification($reason);
|
||||||
}
|
}
|
||||||
if ($alreadyCancelAtPeriodEnd !== $cancelAtPeriodEnd) {
|
if ($alreadyCancelAtPeriodEnd !== $cancelAtPeriodEnd) {
|
||||||
if ($cancelAtPeriodEnd) {
|
if ($cancelAtPeriodEnd) {
|
||||||
// send_internal_notification('Subscription cancelled at period end for team: ' . $subscription->team->id);
|
// send_internal_notification('Subscription cancelled at period end for team: ' . $subscription->team->id);
|
||||||
} else {
|
} else {
|
||||||
send_internal_notification('customer.subscription.updated for customer: '.$customerId);
|
// send_internal_notification('customer.subscription.updated for customer: '.$customerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -233,7 +233,7 @@ class Stripe extends Controller
|
|||||||
'stripe_invoice_paid' => false,
|
'stripe_invoice_paid' => false,
|
||||||
'stripe_trial_already_ended' => true,
|
'stripe_trial_already_ended' => true,
|
||||||
]);
|
]);
|
||||||
send_internal_notification('customer.subscription.deleted for customer: '.$customerId);
|
// send_internal_notification('customer.subscription.deleted for customer: '.$customerId);
|
||||||
break;
|
break;
|
||||||
case 'customer.subscription.trial_will_end':
|
case 'customer.subscription.trial_will_end':
|
||||||
// Not used for now
|
// Not used for now
|
||||||
@ -258,7 +258,7 @@ class Stripe extends Controller
|
|||||||
'stripe_invoice_paid' => false,
|
'stripe_invoice_paid' => false,
|
||||||
]);
|
]);
|
||||||
SubscriptionTrialEndedJob::dispatch($team);
|
SubscriptionTrialEndedJob::dispatch($team);
|
||||||
send_internal_notification('Subscription paused for customer: '.$customerId);
|
// send_internal_notification('Subscription paused for customer: '.$customerId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unhandled event type
|
// Unhandled event type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user