Skip to content

fix: ignore subscription.create stripe webhooks to prevent rapid writes to AN during stripe payment#101

Merged
joaquimds merged 1 commit into
masterfrom
fix/ignore-subscription-create-stripe-webhooks
May 14, 2026
Merged

fix: ignore subscription.create stripe webhooks to prevent rapid writes to AN during stripe payment#101
joaquimds merged 1 commit into
masterfrom
fix/ignore-subscription-create-stripe-webhooks

Conversation

@joaquimds
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts Stripe webhook handling in StripeService::handleWebhook() to avoid Action Network/CRM state mutations during subscription creation flows, reducing rapid/duplicate writes while a /join request is in progress.

Changes:

  • Skip lapsing logic on invoice.payment_failed when the invoice billing_reason is subscription_create.
  • Skip un-lapsing logic on invoice.paid when the invoice billing_reason is subscription_create.
Comments suppressed due to low confidence (2)

packages/join-block/src/Services/StripeService.php:821

  • Same as above: the new billing_reason check assumes $invoice is an array; if data.object is missing/malformed, $invoice['billing_reason'] can emit PHP warnings. Consider an is_array($invoice) / isset($invoice['billing_reason']) guard before reading offsets.
                    $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;

packages/join-block/src/Services/StripeService.php:822

  • New behavior skips un-lapsing on invoice.paid for billing_reason === subscription_create, but it isn’t covered by existing PHPUnit tests (StripeWebhookTest/StripeServiceTest don’t exercise handleWebhook paths). Add coverage to prevent regressions (e.g., a test that asserts no JoinService toggles happen for subscription_create invoices).
                    $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;
                    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 786 to +790
$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.");
Comment on lines +789 to +792
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;
}
@joaquimds joaquimds merged commit 658e716 into master May 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants