diff --git a/src/components/TopUpModal.tsx b/src/components/TopUpModal.tsx index bde9b70..0ebcd3d 100644 --- a/src/components/TopUpModal.tsx +++ b/src/components/TopUpModal.tsx @@ -210,21 +210,23 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top // openInvoice requires WebApp version 6.1+ const supportsInvoice = webApp?.openInvoice && webApp?.isVersionAtLeast && webApp.isVersionAtLeast('6.1'); - if (!supportsInvoice) { - setError(t('balance.errors.starsOnlyInTelegram')); - return; - } - try { - webApp.openInvoice(data.invoice_url, (status) => { - if (status === 'paid') { - setError(null); - onClose(); - } else if (status === 'failed') { - setError(t('wheel.starsPaymentFailed')); - } - }); - } catch (e) { - setError(t('balance.errors.generic', { details: String(e) })); + if (supportsInvoice) { + try { + webApp.openInvoice(data.invoice_url, (status) => { + if (status === 'paid') { + setError(null); + onClose(); + } else if (status === 'failed') { + setError(t('wheel.starsPaymentFailed')); + } + }); + } catch (e) { + setError(t('balance.errors.generic', { details: String(e) })); + } + } else { + // Fallback: open invoice URL in Telegram (browser or unsupported WebApp version) + window.open(data.invoice_url, '_blank', 'noopener,noreferrer'); + onClose(); } }, onError: (err: unknown) => { diff --git a/src/locales/en.json b/src/locales/en.json index 5fd1701..0411129 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -597,6 +597,7 @@ "starsPaymentSuccess": "Payment successful! Spin result sent to Telegram.", "starsPaymentSuccessCheckHistory": "Payment successful! Check history or Telegram for the result.", "starsPaymentFailed": "Payment failed. Please try again.", + "starsPaymentRedirected": "Telegram will open for payment. Refresh the page after payment.", "youWon": "You won", "noPrize": "No luck this time...", "noHistory": "No spin history yet", diff --git a/src/locales/fa.json b/src/locales/fa.json index 2b3e356..0faf228 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -518,6 +518,7 @@ "processingPayment": "در حال پردازش...", "starsPaymentSuccess": "پرداخت موفق! نتیجه به تلگرام ارسال شد.", "starsPaymentFailed": "پرداخت ناموفق. دوباره تلاش کنید.", + "starsPaymentRedirected": "تلگرام برای پرداخت باز می‌شود. پس از پرداخت صفحه را بازخوانی کنید.", "noHistory": "هنوز تاریخچه‌ای نیست", "banner": { "title": "شانس خود را امتحان کنید!", diff --git a/src/locales/ru.json b/src/locales/ru.json index f25d954..34501a3 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -620,6 +620,7 @@ "starsPaymentSuccess": "Оплата прошла! Результат спина отправлен в Telegram.", "starsPaymentSuccessCheckHistory": "Оплата прошла! Проверьте историю или Telegram для результата.", "starsPaymentFailed": "Ошибка оплаты. Попробуйте еще раз.", + "starsPaymentRedirected": "Откроется Telegram для оплаты. После оплаты обновите страницу.", "youWon": "Вы выиграли", "noPrize": "В этот раз не повезло...", "noHistory": "История вращений пуста", diff --git a/src/locales/zh.json b/src/locales/zh.json index 7ca75f4..1bbcbfc 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -522,6 +522,7 @@ "processingPayment": "处理中...", "starsPaymentSuccess": "支付成功!抽奖结果已发送到Telegram。", "starsPaymentFailed": "支付失败。请重试。", + "starsPaymentRedirected": "将打开Telegram进行支付。支付后请刷新页面。", "noHistory": "暂无抽奖记录", "banner": { "title": "试试运气!", diff --git a/src/pages/Wheel.tsx b/src/pages/Wheel.tsx index b6efc99..4f7c6cd 100644 --- a/src/pages/Wheel.tsx +++ b/src/pages/Wheel.tsx @@ -299,20 +299,21 @@ export default function Wheel() { } }); } else { - // openInvoice not available - show error + // Fallback: open invoice URL in Telegram (browser or unsupported WebApp version) setIsPayingStars(false); + window.open(data.invoice_url, '_blank', 'noopener,noreferrer'); setSpinResult({ - success: false, + success: true, prize_id: null, prize_type: null, prize_value: 0, prize_display_name: '', - emoji: '😔', - color: '#EF4444', + emoji: '⭐', + color: '#8B5CF6', rotation_degrees: 0, - message: t('wheel.errors.starsNotAvailable'), + message: t('wheel.starsPaymentRedirected'), promocode: null, - error: 'stars_not_available', + error: null, }); setShowResultModal(true); }