Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor invoice payment failure handling in webhooks.php

Andras Bacsaifd32cd04abf3
diff --git a/routes/webhooks.php b/routes/webhooks.php
index c831b88182..6af79ab637 100644
--- a/routes/webhooks.php
+++ b/routes/webhooks.php
@@ -824,8 +824,12 @@ Route::post('/payments/stripe/events', function () {
if (!$team) {
throw new Exception('No team found for subscription: ' . $subscription->id);
}
- SubscriptionInvoiceFailedJob::dispatch($team);
- send_internal_notification('Invoice payment failed: ' . $subscription->team->id);
+ if (!$subscription->stripe_invoice_paid) {
+ SubscriptionInvoiceFailedJob::dispatch($team);
+ send_internal_notification('Invoice payment failed: ' . $subscription->team->id);
+ } else {
+ send_internal_notification('Invoice payment failed but already paid: ' . $subscription->team->id);
+ }
break;
case 'payment_intent.payment_failed':
$customerId = data_get($data, 'customer');