From 038ea08ca7a7c10be870df23e8b2e687ff664e4f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 27 Oct 2023 10:26:35 +0200 Subject: [PATCH] add payment_intent.payment_failed to subs --- routes/webhooks.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routes/webhooks.php b/routes/webhooks.php index ef75bbea8..dc1caa7c4 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -172,7 +172,7 @@ Route::post('/source/github/events', function () { $found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first(); if ($found) { $found->delete(); - $container_name = generateApplicationContainerName($application,$pull_request_id); + $container_name = generateApplicationContainerName($application, $pull_request_id); // ray('Stopping container: ' . $container_name); instant_remote_process(["docker rm -f $container_name"], $application->destination->server); return response('Preview Deployment closed.'); @@ -288,6 +288,14 @@ Route::post('/payments/stripe/events', function () { 'stripe_invoice_paid' => true, ]); break; + case 'payment_intent.payment_failed': + $customerId = data_get($data, 'customer'); + $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail(); + $subscription->update([ + 'stripe_invoice_paid' => false, + ]); + send_internal_notification('Subscription payment failed: ' . $subscription->team->id); + break; case 'customer.subscription.updated': $customerId = data_get($data, 'customer'); $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();