fix: ignore subscription.create stripe webhooks to prevent rapid writes to AN during stripe payment#101
Merged
Conversation
…es to AN during stripe payment
Contributor
There was a problem hiding this comment.
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_failedwhen the invoicebilling_reasonissubscription_create. - Skip un-lapsing logic on
invoice.paidwhen the invoicebilling_reasonissubscription_create.
Comments suppressed due to low confidence (2)
packages/join-block/src/Services/StripeService.php:821
- Same as above: the new
billing_reasoncheck assumes$invoiceis an array; ifdata.objectis missing/malformed,$invoice['billing_reason']can emit PHP warnings. Consider anis_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.paidforbilling_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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.