File tree Expand file tree Collapse file tree
packages/web/app/src/lib/billing Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' hive ' : minor
3+ ---
4+
5+ add user message when stripe is blocked
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { loadStripe } from '@stripe/stripe-js/pure';
1010import { getStripePublicKey } from './stripe-public-key' ;
1111
1212export const HiveStripeWrapper : FC < { children : ReactNode } > = ( { children } ) => {
13+ const [ blocked , setBlocked ] = useState ( false ) ;
1314 // eslint-disable-next-line react/hook-use-state -- we don't need setter
1415 const [ stripe ] = useState < ReturnType < typeof loadStripe > | void > ( async ( ) => {
1516 if ( env . nodeEnv !== 'production' ) {
@@ -25,6 +26,7 @@ export const HiveStripeWrapper: FC<{ children: ReactNode }> = ({ children }) =>
2526 try {
2627 return await loadStripe ( stripePublicKey ) ;
2728 } catch ( e ) {
29+ setBlocked ( true ) ;
2830 const message =
2931 e instanceof Error ? e . message : typeof e === 'string' ? e : 'Failed to load Stripe.js' ;
3032 captureMessage ( message , {
@@ -34,6 +36,18 @@ export const HiveStripeWrapper: FC<{ children: ReactNode }> = ({ children }) =>
3436 }
3537 } ) ;
3638
39+ if ( blocked ) {
40+ return (
41+ < div >
42+ < p > We couldn’t load Stripe. This might be caused by an ad blocker or privacy extension.</ p >
43+ < p >
44+ Please try disabling ad blocking for this site or allow requests to{ ' ' }
45+ < code > js.stripe.com</ code > , then refresh the page.
46+ </ p >
47+ </ div >
48+ ) ;
49+ }
50+
3751 if ( ! stripe ) {
3852 return children ;
3953 }
You can’t perform that action at this time.
0 commit comments