Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
fix(clerk-js, chrome-extension): Hide stripe.js dependant flows from UP and OP#6754
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a6d7acf87c928b24dcd1e86acc8a286f5d1File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/chrome-extension': patch | ||
| --- | ||
| Hide flows inside UserProfile and OrganizationProfile that depend on Stripe.js when remotely hosted code is not permitted. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -191,7 +191,7 @@ const CheckoutFormElements = () => { | ||
| const { data: paymentSources } = usePaymentMethods(); | ||
| const [paymentMethodSource, setPaymentMethodSource] = useState<PaymentMethodSource>(() => | ||
| paymentSources.length > 0 ? 'existing' : 'new', | ||
| paymentSources.length > 0 || __BUILD_DISABLE_RHC__ ? 'existing' : 'new', | ||
| ); | ||
| if (!id) { | ||
| @@ -204,24 +204,28 @@ const CheckoutFormElements = () => { | ||
| gap={4} | ||
| sx={t => ({ padding: t.space.$4 })} | ||
| > | ||
| {/* only show if there are payment sources and there is a total due now */} | ||
| {paymentSources.length > 0 && (totals.totalDueNow.amount > 0 || !!freeTrialEndsAt) && ( | ||
| <SegmentedControl.Root | ||
| aria-label='Payment method source' | ||
| value={paymentMethodSource} | ||
| onChange={value => setPaymentMethodSource(value as PaymentMethodSource)} | ||
| size='lg' | ||
| fullWidth | ||
| > | ||
| <SegmentedControl.Button | ||
| value='existing' | ||
| text={localizationKeys('commerce.paymentMethods')} | ||
| /> | ||
| <SegmentedControl.Button | ||
| value='new' | ||
| text={localizationKeys('commerce.addPaymentMethod')} | ||
| /> | ||
| </SegmentedControl.Root> | ||
| {__BUILD_DISABLE_RHC__ ? null : ( | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider introducing a | ||
| <> | ||
| {/* only show if there are payment sources and there is a total due now */} | ||
| {paymentSources.length > 0 && (totals.totalDueNow.amount > 0 || !!freeTrialEndsAt) && ( | ||
| <SegmentedControl.Root | ||
| aria-label='Payment method source' | ||
| value={paymentMethodSource} | ||
| onChange={value => setPaymentMethodSource(value as PaymentMethodSource)} | ||
| size='lg' | ||
| fullWidth | ||
| > | ||
| <SegmentedControl.Button | ||
| value='existing' | ||
| text={localizationKeys('commerce.paymentMethods')} | ||
| /> | ||
| <SegmentedControl.Button | ||
| value='new' | ||
| text={localizationKeys('commerce.addPaymentMethod')} | ||
| /> | ||
| </SegmentedControl.Root> | ||
| )} | ||
| </> | ||
| )} | ||
panteliselef marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| {paymentMethodSource === 'existing' && ( | ||
| @@ -231,7 +235,7 @@ const CheckoutFormElements = () => { | ||
| /> | ||
| )} | ||
| {paymentMethodSource === 'new' && <AddPaymentSourceForCheckout />} | ||
| {__BUILD_DISABLE_RHC__ ? null : paymentMethodSource === 'new' && <AddPaymentSourceForCheckout />} | ||
| </Col> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Verification agent
🧩 Analysis chain
Avoid “dead-end” checkout when RHC is disabled and there are no payment sources.
With
__BUILD_DISABLE_RHC__true, state initializes to'existing'. IfpaymentSources.length === 0, users can't add a method and the submit path will likely fail (emptypayment_source_id). Provide an empty-state/fallback or disable the submit path.Minimal in-scope guard (render a localized notice instead of a broken form):
And adjust rendering (below, see 231–239 diff) to show an empty-state when
__BUILD_DISABLE_RHC__ && paymentSources.length === 0.Additionally, make
paymentSourceIdoptional on submit so free-trial/zero-due flows don’t break:If
ConfirmCheckoutParamsrequires a discriminator, please confirm and adapt accordingly.🏁 Script executed:
Length of output: 140
🏁 Script executed:
Length of output: 28472
Fix dead-end checkout when RHC is disabled and no payment sources
Render an explicit empty-state / disable submit when BUILD_DISABLE_RHC && paymentSources.length === 0 so users aren’t stuck on the “existing” path. (packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx — CheckoutFormElements; state init ~lines 193–195; segmented-control/rendering ~lines 207–239)
Make payWithExistingPaymentSource tolerate a missing payment_source_id before calling confirm:
(location: payWithExistingPaymentSource, ~lines 162–171). ConfirmCheckoutParams accepts optional fields; passing {} is safe.
🤖 Prompt for AI Agents