diff --git a/plugins/billing-assets/lang/cs.json b/plugins/billing-assets/lang/cs.json index 60c1399a89e..8ef381735d7 100644 --- a/plugins/billing-assets/lang/cs.json +++ b/plugins/billing-assets/lang/cs.json @@ -56,6 +56,8 @@ "Of": "z", "UpgradePlan": "Upgradovat plán", "LimitReached": "Dosažen limit pracovního prostoru, některé funkce mohou být zakázány. Upgradujte pro obnovení plného přístupu.", - "RestrictedPlans": "Pouze vlastník pracovního prostoru nebo správce fakturace může změnit plán předplatného." + "RestrictedPlans": "Pouze vlastník pracovního prostoru nebo správce fakturace může změnit plán předplatného.", + "SubscriptionOperationFailed": "Operace s předplatným se nezdařila", + "SubscriptionErrorMessage": "Něco se pokazilo. Zkuste to znovu nebo kontaktujte podporu." } } diff --git a/plugins/billing-assets/lang/de.json b/plugins/billing-assets/lang/de.json index 59f6b583f38..2dea3bd4937 100644 --- a/plugins/billing-assets/lang/de.json +++ b/plugins/billing-assets/lang/de.json @@ -56,6 +56,8 @@ "Of": "von", "UpgradePlan": "Plan upgraden", "LimitReached": "Arbeitsbereich-Limit erreicht, einige Funktionen könnten deaktiviert sein. Upgraden Sie für vollen Zugriff.", - "RestrictedPlans": "Nur der Arbeitsbereichsbesitzer oder Abrechnungsmanager kann den Abonnementplan ändern." + "RestrictedPlans": "Nur der Arbeitsbereichsbesitzer oder Abrechnungsmanager kann den Abonnementplan ändern.", + "SubscriptionOperationFailed": "Abonnementvorgang fehlgeschlagen", + "SubscriptionErrorMessage": "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut oder kontaktieren Sie den Support." } } diff --git a/plugins/billing-assets/lang/en.json b/plugins/billing-assets/lang/en.json index ce394bf2e4f..246b462a578 100644 --- a/plugins/billing-assets/lang/en.json +++ b/plugins/billing-assets/lang/en.json @@ -56,6 +56,8 @@ "Of": "of", "UpgradePlan": "Upgrade Plan", "LimitReached": "Workspace limit reached, some functionality may be disabled. Upgrade to restore full access.", - "RestrictedPlans": "Only the workspace owner or billing manager can change the subscription plan" + "RestrictedPlans": "Only the workspace owner or billing manager can change the subscription plan", + "SubscriptionOperationFailed": "Subscription operation failed", + "SubscriptionErrorMessage": "Something went wrong. Please try again or contact support." } } diff --git a/plugins/billing-assets/lang/es.json b/plugins/billing-assets/lang/es.json index 3264943a544..08c523dc4fc 100644 --- a/plugins/billing-assets/lang/es.json +++ b/plugins/billing-assets/lang/es.json @@ -56,6 +56,8 @@ "Of": "de", "UpgradePlan": "Actualizar Plan", "LimitReached": "Límite del espacio de trabajo alcanzado, algunas funciones pueden estar deshabilitadas. Actualiza para restaurar acceso completo.", - "RestrictedPlans": "Solo el propietario del espacio de trabajo o el administrador de facturación pueden cambiar el plan de suscripción." + "RestrictedPlans": "Solo el propietario del espacio de trabajo o el administrador de facturación pueden cambiar el plan de suscripción.", + "SubscriptionOperationFailed": "Error en la operación de suscripción", + "SubscriptionErrorMessage": "Algo ha ido mal. Inténtelo de nuevo o contacte con soporte." } } diff --git a/plugins/billing-assets/lang/fr.json b/plugins/billing-assets/lang/fr.json index 3b5c152371f..993cace5d39 100644 --- a/plugins/billing-assets/lang/fr.json +++ b/plugins/billing-assets/lang/fr.json @@ -56,6 +56,8 @@ "Of": "de", "UpgradePlan": "Mettre à niveau le plan", "LimitReached": "Limite de l'espace de travail atteinte, certaines fonctionnalités peuvent être désactivées. Mettez à niveau pour restaurer l'accès complet.", - "RestrictedPlans": "Seul le propriétaire de l'espace de travail ou le gestionnaire de facturation peut modifier le plan d'abonnement." + "RestrictedPlans": "Seul le propriétaire de l'espace de travail ou le gestionnaire de facturation peut modifier le plan d'abonnement.", + "SubscriptionOperationFailed": "Échec de l'opération d'abonnement", + "SubscriptionErrorMessage": "Une erreur s'est produite. Veuillez réessayer ou contacter le support." } } diff --git a/plugins/billing-assets/lang/it.json b/plugins/billing-assets/lang/it.json index 4d5aa2464c7..3e8c45049d7 100644 --- a/plugins/billing-assets/lang/it.json +++ b/plugins/billing-assets/lang/it.json @@ -56,6 +56,8 @@ "Of": "di", "UpgradePlan": "Aggiorna Piano", "LimitReached": "Limite workspace raggiunto, alcune funzionalità potrebbero essere disabilitate. Aggiorna per ripristinare l'accesso completo.", - "RestrictedPlans": "Solo il proprietario del workspace o il responsabile della fatturazione può modificare il piano di abbonamento." + "RestrictedPlans": "Solo il proprietario del workspace o il responsabile della fatturazione può modificare il piano di abbonamento.", + "SubscriptionOperationFailed": "Operazione di abbonamento non riuscita", + "SubscriptionErrorMessage": "Qualcosa è andato storto. Riprova o contatta l'assistenza." } } diff --git a/plugins/billing-assets/lang/ja.json b/plugins/billing-assets/lang/ja.json index 350fc794364..b0ab982ca10 100644 --- a/plugins/billing-assets/lang/ja.json +++ b/plugins/billing-assets/lang/ja.json @@ -56,6 +56,8 @@ "Of": "/", "UpgradePlan": "プランをアップグレード", "LimitReached": "ワークスペースの制限に達しました。一部の機能が無効になる場合があります。アップグレードして完全アクセスを復元してください。", - "RestrictedPlans": "ワークスペースの所有者または請求管理者のみがサブスクリプションプランを変更できます。" + "RestrictedPlans": "ワークスペースの所有者または請求管理者のみがサブスクリプションプランを変更できます。", + "SubscriptionOperationFailed": "サブスクリプション操作に失敗しました", + "SubscriptionErrorMessage": "問題が発生しました。もう一度お試しいただくか、サポートにお問い合わせください。" } } diff --git a/plugins/billing-assets/lang/pt.json b/plugins/billing-assets/lang/pt.json index 210b9dc66e7..8359b59142a 100644 --- a/plugins/billing-assets/lang/pt.json +++ b/plugins/billing-assets/lang/pt.json @@ -56,6 +56,8 @@ "Of": "de", "UpgradePlan": "Atualizar Plano", "LimitReached": "Limite do workspace atingido, algumas funcionalidades podem estar desabilitadas. Atualize para restaurar acesso completo.", - "RestrictedPlans": "Apenas o proprietário do workspace ou o administrador de faturamento podem alterar o plano de assinatura." + "RestrictedPlans": "Apenas o proprietário do workspace ou o administrador de faturamento podem alterar o plano de assinatura.", + "SubscriptionOperationFailed": "Falha na operação de assinatura", + "SubscriptionErrorMessage": "Algo deu errado. Tente novamente ou entre em contato com o suporte." } } diff --git a/plugins/billing-assets/lang/ru.json b/plugins/billing-assets/lang/ru.json index 1e865d8f5bf..675e9236089 100644 --- a/plugins/billing-assets/lang/ru.json +++ b/plugins/billing-assets/lang/ru.json @@ -56,6 +56,8 @@ "Of": "из", "UpgradePlan": "Обновить план", "LimitReached": "Достигнут лимит рабочего пространства, некоторые функции могут быть отключены. Обновите план для восстановления полного доступа.", - "RestrictedPlans": "Только владелец рабочего пространства или администратор биллинга может изменить план подписки." + "RestrictedPlans": "Только владелец рабочего пространства или администратор биллинга может изменить план подписки.", + "SubscriptionOperationFailed": "Ошибка операции с подпиской", + "SubscriptionErrorMessage": "Что-то пошло не так. Попробуйте ещё раз или обратитесь в поддержку." } } diff --git a/plugins/billing-assets/lang/tr.json b/plugins/billing-assets/lang/tr.json index f835664d1f4..ca937fad69a 100644 --- a/plugins/billing-assets/lang/tr.json +++ b/plugins/billing-assets/lang/tr.json @@ -56,6 +56,8 @@ "Of": "/", "UpgradePlan": "Planı Yükselt", "LimitReached": "Çalışma alanı limiti aşıldı, bazı işlevler devre dışı bırakılabilir. Tam erişimi geri yüklemek için yükseltin.", - "RestrictedPlans": "Abonelik planını yalnızca çalışma alanı sahibi veya faturalama yöneticisi değiştirebilir." + "RestrictedPlans": "Abonelik planını yalnızca çalışma alanı sahibi veya faturalama yöneticisi değiştirebilir.", + "SubscriptionOperationFailed": "Abonelik işlemi başarısız oldu", + "SubscriptionErrorMessage": "Bir şeyler yanlış gitti. Lütfen tekrar deneyin veya destek ile iletişime geçin." } } diff --git a/plugins/billing-assets/lang/zh.json b/plugins/billing-assets/lang/zh.json index cea06151267..733ebdbc1ee 100644 --- a/plugins/billing-assets/lang/zh.json +++ b/plugins/billing-assets/lang/zh.json @@ -56,6 +56,8 @@ "Of": "/", "UpgradePlan": "升级计划", "LimitReached": "已达到工作空间限制,某些功能可能被禁用。请升级以恢复完全访问权限。", - "RestrictedPlans": "只有工作空间所有者或计费管理员才能更改订阅计划。" + "RestrictedPlans": "只有工作空间所有者或计费管理员才能更改订阅计划。", + "SubscriptionOperationFailed": "订阅操作失败", + "SubscriptionErrorMessage": "出了点问题。请重试或联系支持。" } } diff --git a/plugins/billing-resources/src/components/BillingErrorNotification.svelte b/plugins/billing-resources/src/components/BillingErrorNotification.svelte new file mode 100644 index 00000000000..dd29a8d9cf8 --- /dev/null +++ b/plugins/billing-resources/src/components/BillingErrorNotification.svelte @@ -0,0 +1,31 @@ + + + + + + +
+ {notification.subTitle} +
+
+
diff --git a/plugins/billing-resources/src/components/Subscriptions.svelte b/plugins/billing-resources/src/components/Subscriptions.svelte index 6d9b277ac65..672afcbec4e 100644 --- a/plugins/billing-resources/src/components/Subscriptions.svelte +++ b/plugins/billing-resources/src/components/Subscriptions.svelte @@ -16,7 +16,7 @@ import { type SubscriptionData, SubscriptionType } from '@hcengineering/account-client' import { type SubscribeRequest, type CheckoutStatus } from '@hcengineering/payment-client' import { Tier } from '@hcengineering/billing' - import { getMetadata } from '@hcengineering/platform' + import { getMetadata, translate } from '@hcengineering/platform' import presentation, { getClient, MessageBox } from '@hcengineering/presentation' import { type Ref, SortingOrder, UsageStatus } from '@hcengineering/core' import { @@ -29,7 +29,9 @@ themeStore, getLocation, navigate, - showPopup + showPopup, + addNotification, + NotificationSeverity } from '@hcengineering/ui' import { onMount, onDestroy } from 'svelte' @@ -37,6 +39,7 @@ import { getAccountClient, getPaymentClient } from '../utils' import UsageSection from './UsageSection.svelte' + import BillingErrorNotification from './BillingErrorNotification.svelte' const client = getClient() const paymentClient = getPaymentClient() @@ -83,10 +86,21 @@ const { checkoutUrl } = await paymentClient.createSubscription(workspace, request) window.location.href = checkoutUrl } catch (error) { - console.error('error while upgrading plan:', error) + console.error('Error while upgrading plan:', error) + await showErrorNotification() } } + async function showErrorNotification (): Promise { + addNotification( + await translate(plugin.string.SubscriptionOperationFailed, {}, $themeStore.language), + await translate(plugin.string.SubscriptionErrorMessage, {}, $themeStore.language), + BillingErrorNotification, + undefined, + NotificationSeverity.Error + ) + } + async function showPlanChangeConfirmation (newPlan: string, newTier: Tier): Promise { if (currentTier === undefined) { return @@ -167,7 +181,8 @@ // It's a SubscriptionData - direct update successful currentSubscription = updateResult } catch (error) { - console.error('error updating subscription:', error) + console.error('Error updating subscription:', error) + await showErrorNotification() } finally { isUpdating = false } @@ -204,7 +219,8 @@ isCanceling = true currentSubscription = await paymentClient.cancelSubscription(currentSubscription.id) } catch (error) { - console.error('error canceling subscription:', error) + console.error('Error canceling subscription:', error) + await showErrorNotification() } finally { isCanceling = false } @@ -243,7 +259,8 @@ isUncanceling = true currentSubscription = await paymentClient.uncancelSubscription(currentSubscription.id) } catch (error) { - console.error('error uncanceling subscription:', error) + console.error('Error uncanceling subscription:', error) + await showErrorNotification() } finally { isUncanceling = false } @@ -261,7 +278,8 @@ const plan = currentSubscription?.plan currentTier = plan !== undefined ? tierByPlan[plan] : undefined } catch (err) { - console.error('error fetching current plan:', err) + console.error('Error fetching current plan:', err) + await showErrorNotification() } finally { loading = false } @@ -275,7 +293,8 @@ const workspaceInfo = await accountClient.getWorkspaceInfo(false) usageInfo = workspaceInfo.usageInfo ?? null } catch (err) { - console.error('error fetching usage stats:', err) + console.error('Error fetching usage stats:', err) + await showErrorNotification() usageInfo = null } } @@ -317,7 +336,8 @@ }, POLL_INTERVAL) } } catch (err) { - console.error('error polling checkout status:', err) + console.error('Error polling checkout status:', err) + await showErrorNotification() // Retry on error (up to max attempts) if (pollAttempts < MAX_POLL_ATTEMPTS) { pollTimer = setTimeout(() => { diff --git a/plugins/billing-resources/src/plugin.ts b/plugins/billing-resources/src/plugin.ts index 3eaa464710b..6a64e8ebde8 100644 --- a/plugins/billing-resources/src/plugin.ts +++ b/plugins/billing-resources/src/plugin.ts @@ -52,6 +52,8 @@ export default mergeIds(billingId, billing, { TrafficUsage: '' as IntlString, Usage: '' as IntlString, Of: '' as IntlString, - RestrictedPlans: '' as IntlString + RestrictedPlans: '' as IntlString, + SubscriptionOperationFailed: '' as IntlString, + SubscriptionErrorMessage: '' as IntlString } })