mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
Update TopUpModal.tsx
This commit is contained in:
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user