From da2e516cf178f081dfc77e4137e04d849e6b24c0 Mon Sep 17 00:00:00 2001 From: Joaquim d'Souza Date: Thu, 14 May 2026 17:29:07 +0200 Subject: [PATCH] fix: ignore subscription.create stripe webhooks to prevent rapid writes to AN during stripe payment --- packages/join-block/src/Services/StripeService.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/join-block/src/Services/StripeService.php b/packages/join-block/src/Services/StripeService.php index 059230a..c8010b2 100644 --- a/packages/join-block/src/Services/StripeService.php +++ b/packages/join-block/src/Services/StripeService.php @@ -786,6 +786,11 @@ public static function handleWebhook($event) $invoice = $event['data']['object'] ?? null; $customerId = $invoice['customer'] ?? '(unknown)'; + if (($invoice['billing_reason'] ?? null) === 'subscription_create') { + $joinBlockLog->info("Skipping invoice.payment_failed lapsing for Stripe customer $customerId: subscription_create invoice, /join endpoint will handle Action Network state."); + break; + } + if (empty($invoice['next_payment_attempt'])) { $joinBlockLog->warning("Final payment attempt failed for Stripe customer $customerId. No retries will be attempted."); if (!empty($invoice['customer'])) { @@ -811,6 +816,10 @@ public static function handleWebhook($event) $invoice = $event['data']['object'] ?? null; $customerId = $invoice['customer'] ?? '(unknown)'; $joinBlockLog->info("Invoice paid for Stripe customer $customerId"); + if (($invoice['billing_reason'] ?? null) === 'subscription_create') { + $joinBlockLog->info("Skipping invoice.paid un-lapsing for Stripe customer $customerId: subscription_create invoice, /join endpoint will handle Action Network state."); + break; + } if (!empty($invoice['customer'])) { $email = self::getEmailForCustomer($customerId); if ($email) {