-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Use dubCustomerExternalId in Stripe integration for consistency #3224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughMultiple Stripe webhook handlers, a customer-creation util, and two guide docs were updated to prefer Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touchesβ Passed checks (3 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
π Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro π Files selected for processing (7)
π§° Additional context usedπ§ Learnings (2)π Learning: 2025-07-17T06:41:45.620ZApplied to files:
π Learning: 2025-06-19T01:46:45.723ZApplied to files:
π Additional comments (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (1)
apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts (1)
242-253: Critical: Condition must check for both metadata fields.The condition on line 242 only checks for
dubCustomerId, which means customers with onlydubCustomerExternalIdin their metadata will be skipped. This breaks the new field support.Apply this diff to fix the condition:
- if (connectedCustomer?.metadata.dubCustomerId) { + if (connectedCustomer?.metadata.dubCustomerExternalId || connectedCustomer?.metadata.dubCustomerId) { dubCustomerExternalId = connectedCustomer.metadata.dubCustomerExternalId || connectedCustomer.metadata.dubCustomerId;
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (4)
apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts(2 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/customer-updated.ts(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts(1 hunks)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
π Additional comments (4)
apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts (1)
9-11: LGTM! Backward-compatible fallback implemented correctly.The fallback pattern ensures existing integrations using
dubCustomerIdcontinue to work while supporting the newdubCustomerExternalIdfield. The||operator correctly handles all falsy values.apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts (2)
45-46: LGTM! Consistent fallback pattern.The extraction correctly prefers
dubCustomerExternalIdand falls back todubCustomerIdfor backward compatibility.
243-245: LGTM! Extraction logic is correct.The fallback pattern properly supports both the new
dubCustomerExternalIdand legacydubCustomerIdfields. However, this code's effectiveness depends on fixing the conditional check at line 242.apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts (1)
42-44: LGTM! Proper use of optional chaining with fallback.The extraction correctly handles potentially undefined
connectedCustomerwith optional chaining while maintaining backward compatibility through the fallback todubCustomerId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (2)
apps/web/guides/stripe-checkout.md (1)
9-9: Consider documenting backwards compatibility.The documentation now shows only
dubCustomerExternalId, but the implementation (increate-new-customer.ts) maintains fallback support for the legacydubCustomerIdkey. Consider adding a note that existing integrations usingdubCustomerIdwill continue to work, to avoid confusion or unnecessary migration concerns.Example addition:
metadata: { dubCustomerExternalId: user.id, // the unique user ID of the customer in your database }, + // Note: The legacy 'dubCustomerId' key is still supported for backwards compatibilityAlso applies to: 29-29
apps/web/guides/stripe-customers.md (1)
3-3: Consider adding backwards compatibility note.Similar to the Stripe Checkout guide, this documentation now shows only
dubCustomerExternalIdin both the customer creation and update flows. Consider adding a note that the legacydubCustomerIdkey remains supported for backwards compatibility, helping users understand that immediate migration is optional.Example addition:
metadata: { dubCustomerExternalId: user.id, dubClickId: dub_id, }, + // Note: The legacy 'dubCustomerId' key is still supported for backwards compatibilityAlso applies to: 20-20, 26-26, 41-41
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (4)
apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts(2 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts(1 hunks)apps/web/guides/stripe-checkout.md(2 hunks)apps/web/guides/stripe-customers.md(3 hunks)
π§ Files skipped from review as they are similar to previous changes (1)
- apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
π Additional comments (1)
apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts (1)
21-23: LGTM! Fallback pattern is consistently implemented across all webhook handlers.The implementation in lines 21-23 correctly uses the fallback from
dubCustomerExternalIdtodubCustomerId. Verified that the same pattern is consistently applied across all Stripe webhook handlers (invoice-paid.ts, customer-created.ts, customer-updated.ts, checkout-session-completed.ts, and create-new-customer.ts).
|
@coderabbitai full review |
β Actions performedFull review triggered. |
Summary by CodeRabbit
Bug Fixes
Documentation
βοΈ Tip: You can customize this high-level summary in your review settings.