Update TopUpModal.tsx

This commit is contained in:
Egor
2026-01-28 21:12:03 +03:00
committed by GitHub
parent 56c2d7be90
commit 80eb2a25d2

View File

@@ -210,21 +210,23 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top
// openInvoice requires WebApp version 6.1+ // openInvoice requires WebApp version 6.1+
const supportsInvoice = const supportsInvoice =
webApp?.openInvoice && webApp?.isVersionAtLeast && webApp.isVersionAtLeast('6.1'); webApp?.openInvoice && webApp?.isVersionAtLeast && webApp.isVersionAtLeast('6.1');
if (!supportsInvoice) { if (supportsInvoice) {
setError(t('balance.errors.starsOnlyInTelegram')); try {
return; webApp.openInvoice(data.invoice_url, (status) => {
} if (status === 'paid') {
try { setError(null);
webApp.openInvoice(data.invoice_url, (status) => { onClose();
if (status === 'paid') { } else if (status === 'failed') {
setError(null); setError(t('wheel.starsPaymentFailed'));
onClose(); }
} else if (status === 'failed') { });
setError(t('wheel.starsPaymentFailed')); } catch (e) {
} setError(t('balance.errors.generic', { details: String(e) }));
}); }
} catch (e) { } else {
setError(t('balance.errors.generic', { details: String(e) })); // Fallback: open invoice URL in Telegram (browser or unsupported WebApp version)
window.open(data.invoice_url, '_blank', 'noopener,noreferrer');
onClose();
} }
}, },
onError: (err: unknown) => { onError: (err: unknown) => {