Skip to content

📨 The ultimate agentic social media scheduling tool 🤖

fix(billing): show a message when Stripe.js fails to load instead of crashing

Gilad Resisicdaf61d638e6
diff --git a/apps/frontend/src/components/billing/first.billing.component.tsx b/apps/frontend/src/components/billing/first.billing.component.tsx
index 9ea7482a8..d2b9e53f8 100644
--- a/apps/frontend/src/components/billing/first.billing.component.tsx
+++ b/apps/frontend/src/components/billing/first.billing.component.tsx
@@ -51,6 +51,7 @@ export const FirstBillingComponent = () => {
const user = useUser();
const dub = useDubClickId();
const [stripe, setStripe] = useState<null | Promise<Stripe>>(null);
+ const [stripeFailed, setStripeFailed] = useState(false);
const [tier, setTier] = useState('STANDARD');
const [period, setPeriod] = useState('MONTHLY');
const fetch = useFetch();
@@ -60,7 +61,9 @@ export const FirstBillingComponent = () => {
const [datafast_session_id] = useCookie('datafast_session_id', '');
useEffect(() => {
- setStripe(loadStripe(stripeClient));
+ const stripePromise = loadStripe(stripeClient);
+ stripePromise.catch(() => setStripeFailed(true));
+ setStripe(stripePromise);
}, []);
const loadCheckout = useCallback(async () => {
@@ -212,6 +215,13 @@ export const FirstBillingComponent = () => {
'Another account with this email already has an active subscription. Please log off and sign in to that account to manage your subscription.'
)}
</div>
+ ) : stripeFailed ? (
+ <div className="mt-[24px] p-[24px] rounded-[20px] border-[1.5px] border-newColColor text-[16px] font-[500]">
+ {t(
+ 'billing_stripe_load_failed',
+ 'The payment form could not be loaded. Please disable ad blockers or privacy extensions for this page and reload.'
+ )}
+ </div>
) : !isLoading && data && stripe ? (
<EmbeddedBilling
stripe={stripe}
diff --git a/i18n.lock b/i18n.lock
index d14328450..6f5597c7d 100644
--- a/i18n.lock
+++ b/i18n.lock
@@ -509,6 +509,7 @@ checksums:
delete_integration: ccc879ccfcf7f85bcfe09f2bc3fa0dd3
start_writing_your_post: 471efc4f2a7e2cf02a065a2de34e7213
billing_other_account_subscribed: 6c12b4a726d55ee88b0594bd22ec556c
+ billing_stripe_load_failed: b578d90bcd0abe8bacc2c1e6d37ddc1a
already_subscribed: 3694e02bcb0a41286ea6b79615e6cdbf
ok: e2d6579a83aba07c4180c21c5fe9893d
billing_join_over: 6e1c237241ba00ddbb07fd603344c5c3
@@ -534,6 +535,7 @@ checksums:
billing_advanced_picture_editor: 329a6c2e8b2685f81609859a4de07b0f
billing_ai_images_per_month: 5073aa90b32654abe6200d426a97f03e
billing_ai_videos_per_month: c786199d8dc9bded54fab8f92c350b19
+ billing_clipping_minutes_per_month: e8337650fb3b1836ba1194e5e7730fd6
billing_billing_address: 48980a775bfc7292b0c4f9b74b4d352e
billing_payment: 95142d3fd8b6a6f551aba771842e9c11
billing_powered_by_stripe: f2767a22c2cd93d4e8fe5c5d6ee05ad1
diff --git a/libraries/react-shared-libraries/src/translation/locales/ar/translation.json b/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
index b914b7134..34a1030e1 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "حذف التكامل",
"start_writing_your_post": "ابدأ بكتابة منشورك لمعاينة",
"billing_other_account_subscribed": "هناك حساب آخر يستخدم هذا البريد الإلكتروني لديه اشتراك نشط بالفعل. يرجى تسجيل الخروج وتسجيل الدخول إلى ذلك الحساب لإدارة اشتراكك.",
+ "billing_stripe_load_failed": "تعذّر تحميل نموذج الدفع. يرجى تعطيل أدوات حظر الإعلانات أو ملحقات الخصوصية لهذه الصفحة وإعادة تحميلها.",
"already_subscribed": "مشترك بالفعل",
"ok": "موافق",
"billing_join_over": "انضم إلى أكثر من",
diff --git a/libraries/react-shared-libraries/src/translation/locales/bn/translation.json b/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
index a0c5580d9..d52209baa 100644
--- a/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "ইন্টিগ্রেশন মুছে ফেলুন",
"start_writing_your_post": "প্রিভিউর জন্য আপনার পোস্ট লেখা শুরু করুন",
"billing_other_account_subscribed": "এই ইমেইলটি ব্যবহার করে অন্য একটি অ্যাকাউন্টে ইতিমধ্যে সক্রিয় সাবস্ক্রিপশন রয়েছে। দয়া করে লগ আউট করুন এবং সাবস্ক্রিপশনটি পরিচালনা করতে ঐ অ্যাকাউন্টে সাইন ইন করুন।",
+ "billing_stripe_load_failed": "পেমেন্ট ফর্মটি লোড করা যায়নি। দয়া করে এই পৃষ্ঠার জন্য বিজ্ঞাপন ব্লকার বা গোপনীয়তা এক্সটেনশনগুলো নিষ্ক্রিয় করুন এবং পৃষ্ঠাটি পুনরায় লোড করুন।",
"already_subscribed": "ইতিমধ্যে সাবস্ক্রাইব করা হয়েছে",
"ok": "ঠিক আছে",
"billing_join_over": "যোগ দিন",
diff --git a/libraries/react-shared-libraries/src/translation/locales/de/translation.json b/libraries/react-shared-libraries/src/translation/locales/de/translation.json
index b398c5721..c9de6e6b4 100644
--- a/libraries/react-shared-libraries/src/translation/locales/de/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/de/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Integration löschen",
"start_writing_your_post": "Beginne, deinen Beitrag für eine Vorschau zu schreiben",
"billing_other_account_subscribed": "Ein anderes Konto mit dieser E-Mail-Adresse hat bereits ein aktives Abonnement. Bitte melden Sie sich ab und melden Sie sich mit diesem Konto an, um Ihr Abonnement zu verwalten.",
+ "billing_stripe_load_failed": "Das Zahlungsformular konnte nicht geladen werden. Bitte deaktivieren Sie Werbeblocker oder Datenschutz-Erweiterungen für diese Seite und laden Sie sie erneut.",
"already_subscribed": "Bereits abonniert",
"ok": "OK",
"billing_join_over": "Schließen Sie sich über",
diff --git a/libraries/react-shared-libraries/src/translation/locales/en/translation.json b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
index 726b72ca4..290bc15df 100644
--- a/libraries/react-shared-libraries/src/translation/locales/en/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Delete Integration",
"start_writing_your_post": "Start writing your post for a preview",
"billing_other_account_subscribed": "Another account with this email already has an active subscription. Please log off and sign in to that account to manage your subscription.",
+ "billing_stripe_load_failed": "The payment form could not be loaded. Please disable ad blockers or privacy extensions for this page and reload.",
"already_subscribed": "Already subscribed",
"ok": "OK",
"billing_join_over": "Join Over",
diff --git a/libraries/react-shared-libraries/src/translation/locales/es/translation.json b/libraries/react-shared-libraries/src/translation/locales/es/translation.json
index e5a1f4142..864587858 100644
--- a/libraries/react-shared-libraries/src/translation/locales/es/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/es/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Eliminar integración",
"start_writing_your_post": "Comienza a escribir tu publicación para obtener una vista previa",
"billing_other_account_subscribed": "Otra cuenta con este correo electrónico ya tiene una suscripción activa. Por favor, cierra sesión e inicia sesión con esa cuenta para gestionar tu suscripción.",
+ "billing_stripe_load_failed": "No se pudo cargar el formulario de pago. Por favor, desactiva los bloqueadores de anuncios o las extensiones de privacidad para esta página y vuelve a cargarla.",
"already_subscribed": "Ya está suscrito",
"ok": "OK",
"billing_join_over": "Únete a más de",
diff --git a/libraries/react-shared-libraries/src/translation/locales/fr/translation.json b/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
index 37cb76106..23d93eca0 100644
--- a/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Supprimer l'intégration",
"start_writing_your_post": "Commencez à écrire votre post pour un aperçu",
"billing_other_account_subscribed": "Un autre compte avec cet e-mail a déjà un abonnement actif. Veuillez vous déconnecter et vous connecter à ce compte pour gérer votre abonnement.",
+ "billing_stripe_load_failed": "Le formulaire de paiement n’a pas pu être chargé. Veuillez désactiver les bloqueurs de publicités ou les extensions de confidentialité pour cette page, puis rechargez-la.",
"already_subscribed": "Déjà abonné",
"ok": "OK",
"billing_join_over": "Rejoignez plus de",
diff --git a/libraries/react-shared-libraries/src/translation/locales/he/translation.json b/libraries/react-shared-libraries/src/translation/locales/he/translation.json
index 125353ec1..0ba46e14d 100644
--- a/libraries/react-shared-libraries/src/translation/locales/he/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/he/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "מחק אינטגרציה",
"start_writing_your_post": "התחל לכתוב את הפוסט שלך לתצוגה מקדימה",
"billing_other_account_subscribed": "קיים חשבון אחר עם כתובת האימייל הזו שכבר יש לו מנוי פעיל. נא להתנתק ולהתחבר לחשבון הזה כדי לנהל את המנוי שלך.",
+ "billing_stripe_load_failed": "לא ניתן היה לטעון את טופס התשלום. נא להשבית חוסמי פרסומות או תוספי פרטיות עבור עמוד זה ולרענן את הדף.",
"already_subscribed": "כבר רשום כמנוי",
"ok": "אישור",
"billing_join_over": "הצטרפו ליותר מ-",
diff --git a/libraries/react-shared-libraries/src/translation/locales/it/translation.json b/libraries/react-shared-libraries/src/translation/locales/it/translation.json
index 953bd1a83..63f6eaf46 100644
--- a/libraries/react-shared-libraries/src/translation/locales/it/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/it/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Elimina integrazione",
"start_writing_your_post": "Inizia a scrivere il tuo post per un'anteprima",
"billing_other_account_subscribed": "Un altro account con questa email ha già un abbonamento attivo. Disconnettiti e accedi a quell'account per gestire il tuo abbonamento.",
+ "billing_stripe_load_failed": "Impossibile caricare il modulo di pagamento. Disattiva i blocchi pubblicitari o le estensioni per la privacy per questa pagina e ricarica.",
"already_subscribed": "Già abbonato",
"ok": "OK",
"billing_join_over": "Unisciti a oltre",
diff --git a/libraries/react-shared-libraries/src/translation/locales/ja/translation.json b/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
index 9f36b8bce..870166c1c 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "連携を削除",
"start_writing_your_post": "プレビュー用に投稿を書き始めてください",
"billing_other_account_subscribed": "このメールアドレスを持つ別のアカウントですでに有効なサブスクリプションがあります。サブスクリプションを管理するには、そのアカウントからサインアウトし、該当するアカウントでサインインしてください。",
+ "billing_stripe_load_failed": "お支払いフォームを読み込めませんでした。このページの広告ブロッカーやプライバシー拡張機能を無効にして、再読み込みしてください。",
"already_subscribed": "すでに登録済みです",
"ok": "OK",
"billing_join_over": "すでに参加している",
diff --git a/libraries/react-shared-libraries/src/translation/locales/ko/translation.json b/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
index b546bae95..e3469e4bc 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "통합 삭제",
"start_writing_your_post": "미리보기를 위해 게시글 작성을 시작하세요",
"billing_other_account_subscribed": "이 이메일로 이미 활성화된 구독이 있는 다른 계정이 있습니다. 구독을 관리하려면 로그아웃한 후 해당 계정으로 다시 로그인해 주세요.",
+ "billing_stripe_load_failed": "결제 양식을 불러올 수 없습니다. 이 페이지에 대한 광고 차단기나 프라이버시 확장 기능을 비활성화한 후 다시 불러와 주세요.",
"already_subscribed": "이미 구독됨",
"ok": "확인",
"billing_join_over": "이미 가입한",
diff --git a/libraries/react-shared-libraries/src/translation/locales/pt/translation.json b/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
index 3f04a924e..13e301c5e 100644
--- a/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Excluir integração",
"start_writing_your_post": "Comece a escrever sua postagem para visualizar",
"billing_other_account_subscribed": "Outra conta com este e-mail já possui uma assinatura ativa. Por favor, faça logout e acesse essa conta para gerenciar sua assinatura.",
+ "billing_stripe_load_failed": "O formulário de pagamento não pôde ser carregado. Por favor, desative bloqueadores de anúncios ou extensões de privacidade para esta página e recarregue.",
"already_subscribed": "Já inscrito",
"ok": "OK",
"billing_join_over": "Junte-se a mais de",
diff --git a/libraries/react-shared-libraries/src/translation/locales/ru/translation.json b/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
index 60bae1f6f..c3cb03dd7 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Удалить интеграцию",
"start_writing_your_post": "Начните писать свой пост для предварительного просмотра",
"billing_other_account_subscribed": "Другой аккаунт с этим адресом электронной почты уже имеет активную подписку. Пожалуйста, выйдите из системы и войдите в этот аккаунт, чтобы управлять своей подпиской.",
+ "billing_stripe_load_failed": "Не удалось загрузить платежную форму. Пожалуйста, отключите блокировщики рекламы или расширения для защиты приватности для этой страницы и перезагрузите её.",
"already_subscribed": "Уже подписаны",
"ok": "ОК",
"billing_join_over": "Присоединяйтесь к",
diff --git a/libraries/react-shared-libraries/src/translation/locales/tr/translation.json b/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
index 2f19c57a7..2ec5eaffa 100644
--- a/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Entegrasyonu Sil",
"start_writing_your_post": "Önizleme için gönderinizi yazmaya başlayın",
"billing_other_account_subscribed": "Bu e-posta ile başka bir hesapta zaten aktif bir abonelik var. Aboneliğinizi yönetmek için lütfen çıkış yapıp o hesaba giriş yapın.",
+ "billing_stripe_load_failed": "Ödeme formu yüklenemedi. Lütfen bu sayfa için reklam engelleyicileri veya gizlilik eklentilerini devre dışı bırakıp sayfayı yeniden yükleyin.",
"already_subscribed": "Zaten abone olundu",
"ok": "Tamam",
"billing_join_over": "Katılan",
diff --git a/libraries/react-shared-libraries/src/translation/locales/vi/translation.json b/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
index a306467c8..197691d3a 100644
--- a/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "Xóa tích hợp",
"start_writing_your_post": "Bắt đầu viết bài của bạn để xem trước",
"billing_other_account_subscribed": "Một tài khoản khác sử dụng email này đã có đăng ký đang hoạt động. Vui lòng đăng xuất và đăng nhập vào tài khoản đó để quản lý đăng ký của bạn.",
+ "billing_stripe_load_failed": "Không thể tải biểu mẫu thanh toán. Vui lòng tắt trình chặn quảng cáo hoặc các tiện ích mở rộng bảo mật cho trang này và tải lại.",
"already_subscribed": "Đã đăng ký",
"ok": "OK",
"billing_join_over": "Tham gia cùng hơn",
diff --git a/libraries/react-shared-libraries/src/translation/locales/zh/translation.json b/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
index aa2fd9030..c7a089b1b 100644
--- a/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
@@ -505,6 +505,7 @@
"delete_integration": "删除集成",
"start_writing_your_post": "开始写你的帖子以预览",
"billing_other_account_subscribed": "此邮箱已关联其他账户并有有效订阅。请注销当前账户并使用该账户登录以管理您的订阅。",
+ "billing_stripe_load_failed": "无法加载付款表单。请为此页面禁用广告拦截器或隐私扩展程序,然后重新加载。",
"already_subscribed": "已订阅",
"ok": "确定",
"billing_join_over": "已有超过",