mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
Update TopUpModal.tsx
This commit is contained in:
@@ -210,10 +210,7 @@ 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'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
webApp.openInvoice(data.invoice_url, (status) => {
|
webApp.openInvoice(data.invoice_url, (status) => {
|
||||||
if (status === 'paid') {
|
if (status === 'paid') {
|
||||||
@@ -226,6 +223,11 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(t('balance.errors.generic', { details: String(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) => {
|
onError: (err: unknown) => {
|
||||||
const axiosError = err as { response?: { data?: { detail?: string }; status?: number } };
|
const axiosError = err as { response?: { data?: { detail?: string }; status?: number } };
|
||||||
|
|||||||
Reference in New Issue
Block a user