Skip to content

Commit e5aa9bd

Browse files
authored
feat(app): show hint when stripe is blocked (#7085)
1 parent b02b1db commit e5aa9bd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.changeset/six-socks-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': minor
3+
---
4+
5+
add user message when stripe is blocked

packages/web/app/src/lib/billing/stripe.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { loadStripe } from '@stripe/stripe-js/pure';
1010
import { getStripePublicKey } from './stripe-public-key';
1111

1212
export 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
}

0 commit comments

Comments
 (0)