File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
packages/web/app/src/lib/billing Expand file tree Collapse file tree 2 files changed +19
-0
lines changed 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';
10
10
import { getStripePublicKey } from './stripe-public-key' ;
11
11
12
12
export const HiveStripeWrapper : FC < { children : ReactNode } > = ( { children } ) => {
13
+ const [ blocked , setBlocked ] = useState ( false ) ;
13
14
// eslint-disable-next-line react/hook-use-state -- we don't need setter
14
15
const [ stripe ] = useState < ReturnType < typeof loadStripe > | void > ( async ( ) => {
15
16
if ( env . nodeEnv !== 'production' ) {
@@ -25,6 +26,7 @@ export const HiveStripeWrapper: FC<{ children: ReactNode }> = ({ children }) =>
25
26
try {
26
27
return await loadStripe ( stripePublicKey ) ;
27
28
} catch ( e ) {
29
+ setBlocked ( true ) ;
28
30
const message =
29
31
e instanceof Error ? e . message : typeof e === 'string' ? e : 'Failed to load Stripe.js' ;
30
32
captureMessage ( message , {
@@ -34,6 +36,18 @@ export const HiveStripeWrapper: FC<{ children: ReactNode }> = ({ children }) =>
34
36
}
35
37
} ) ;
36
38
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
+
37
51
if ( ! stripe ) {
38
52
return children ;
39
53
}
You can’t perform that action at this time.
0 commit comments