Skip to content

Main - #3215

Merged
charlietlamb merged 4 commits into
devfrom
main
Sep 2, 2026
Merged

Main#3215
charlietlamb merged 4 commits into
devfrom
main

Conversation

@charlietlamb

@charlietlamb charlietlamb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary by cubic

Fixes a bug where promoting pending customer products erased the activated plan from billing and product webhooks after Stripe checkout.

Bug Fixes

  • promotePendingCustomerProducts now returns an updated billing plan instead of mutating the original.
  • Billing plan execution uses the returned plan, so the original plan data still feeds webhook events.

Written for commit db5f003. Summary will update on new commits.

Review in cubic

Greptile Summary

The PR preserves promoted pending products for post-checkout event generation while excluding them from database insertion during final plan execution.

  • Bug fixes: Return a filtered billing-plan copy after pending products are promoted, preventing those existing records from being inserted again.
  • Bug fixes: Execute deferred and Stripe-checkout billing with the filtered copy while retaining the original plan for activation webhooks and checkout rewards.
  • Improvements: Extend checkout integration coverage to require both the product update and billing activation events.

Confidence Score: 5/5

The PR appears safe to merge, with the execution and webhook paths deliberately using separate billing-plan views for their respective responsibilities.

All current callers consume the filtered plan, unmatched planned inserts remain intact, and retained webhook history makes the expanded integration assertion safe from post-checkout polling races.

Important Files Changed

Filename Overview
server/src/internal/billing/v2/execute/promotePendingCustomerProducts.ts Returns a copy of the billing plan with successfully promoted products removed from the insertion list.
server/src/internal/billing/v2/execute/executeDeferredBillingPlan.ts Executes deferred billing with the filtered plan while preserving the original plan for downstream event generation.
server/src/external/stripe/webhookHandlers/handleStripeCheckoutSessionCompleted/tasks/handleCheckoutSessionMetadataV2/handleCheckoutSessionMetadataV2.ts Uses the filtered plan for checkout completion execution without erasing promoted products needed by webhooks and rewards.
server/tests/integration/billing/autumn-webhooks/billing-updated/billing-updated-attach.test.ts Verifies that completed checkout emits both product-update and billing-activation events.

Sequence Diagram

sequenceDiagram
  participant Stripe
  participant Checkout as Checkout handler
  participant Promote as Pending-product promotion
  participant Execute as Billing-plan execution
  participant Events as Webhook delivery
  Stripe->>Checkout: Checkout completed
  Checkout->>Promote: Promote pending products
  Promote-->>Checkout: Return plan excluding promoted inserts
  Checkout->>Execute: Execute filtered plan
  Execute-->>Checkout: Persist remaining billing changes
  Checkout->>Events: Emit product and billing updates from original plan
Loading

Reviews (1): Last reviewed commit: "Merge pull request #3214 from useautumn/..." | Re-trigger Greptile

Context used:

@charlietlamb
charlietlamb merged commit cf40d96 into dev Sep 2, 2026
25 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